How to implement auto-formatting of text (e.g. syntax highlighting of code snippets)?

C. Boemann cbo at boemann.dk
Tue Jul 24 13:01:10 BST 2012


On Tuesday 24 July 2012 13:30:50 Inge Wallin wrote:
> On Tuesday, July 24, 2012 13:12:01 C. Boemann wrote:
> > On Tuesday 24 July 2012 03:08:27 Friedrich W. H. Kossebau wrote:
> > > Hi,
> > > 
> > > feature, not bug this time :)
> > > 
> > > As software developer you often have sourcecode snippets in your
> > > documents or slides. Now, ideally that code snippet has some syntax
> > > highlighting like you are used from your sourcecode editor.
> > > 
> > > Of course, that should be done automatically, like in the editor, after
> > > you set the type of syntax.
> > > 
> > > How do I implement this in Calligra? As a shape? Or is it hopefully
> > > possible to have some text style which updates the formatting of the
> > > text it is set for on every text change? What about the linebreaks? Is
> > > there a way to group a range of paragraphs? How eats entered series of
> > > whitespaces (and all at begin of line), or are they just ignored in
> > > normal styles? Is there something in ODF which supports that (besides
> > > setting some calligra- namespaced attribute, which  to a text
> > > paragraph in the storage format)?
> > > 
> > > Could it be similar to how either tables are embedded in the text flow,
> > > or by how e.g. a multi-paragraph quote is done, by having three
> > > paragraph styles for codes (begin paragraph style, middle paragraphs
> > > style, end paragraph style), which Calligra is smart enough to detect
> > > and then have a special handler which cares for the autoformatting?
> > > For roundtrips with non-Calligra programs the text would be just saved
> > > as normally formatted text, just with additional annotation that tells
> > > Calligra to use autoformatting for it.
> > > 
> > > Anyone ever started on this?
> > > 
> > > I dream of being able to reuse Kate's syntax highlighting engine for
> > > that, for maximal reuse and consistency :)
> > > 
> > > Is autoformatting perhaps also something to consider to add to ODF 1.3?
> > > Any other autoformatting use cases besides syntax highlighting for
> > > sourcecode?
> > > 
> > > Cheers
> > > Friedrich
> > > _______________________________________________
> > > calligra-devel mailing list
> > > calligra-devel at kde.org
> > > https://mail.kde.org/mailman/listinfo/calligra-devel
> > 
> > Hi
> > 
> > The textediting plugins seems like what you are after. We already have
> > autocorrection, and it sounds like it's just an advanced autocorrection
> > you want.
> > 
> > see plugins/textediting
> > 
> > As for odf support i somehow doubt it is relevant enough. Maybe we can
> > just reuse the language tags. That is sort of what it is actually
> 
> I think the best way to just have textediting plugin like Boemann says and
> let the tool work on the selection. If you want auto-rehighlighting then
> perhaps using RDF metadata to mark the text could be used. No idea if
> there is an ontology for code but it wouldn't surprise me.
> 
Considering we may make rdf tagged text clickable in the future it may not be 
such a smart idea to use rdf for this, and i was not kidding about reusing the 
language markup (code is a form of language after all)

for clickable rdf see: http://monkeyiq.blogspot.com/2012/07/rdf-abiword-and-
calligra.html



More information about the calligra-devel mailing list