On 09/05/2009 09:04 AM, Clayton wrote:
Maybe one suggestion ("very nice to have"): would it be possible to
apply syntax coloring/highlighting to the example code? It would make it
so much easier for readers to orientate themselves in the code examples.
Something like applying the [g]vim syntax highlighting?

Would you be able/contemplate of adding it?

Hmmm... I'm not sure how easy this will be.  The code blocks are given a
"Preformatted" paragraph style which applies the grey background, and
the monospaced character styles.  Short of manually editing and applying
custom character styles through all code blocks, I'm not sure how it
could be done.

Exporting the existing syntax highlighting from the Wiki is beyond the
current capabilities of the Book (Collection) extension.

If anyone has any ideas on how this might be done... I'm definitely open
to them :-)


I have macros that do something similar in OOo. I apply character styles
to different portions of the text to colorize them. The primary macro
works based on a cursor selection. I have code that wades through an
entire document and color codes what it finds based on paragraph styles.
Because I am not aware of your process, I do not know how adaptable this
is for your export process.

I have code that can colorize starbasic, Java, C++, Perl, Python, and XML.

I use simplistic parsers, but the only error of which I am currently
aware (that I have not yet fixed) is that in Basic, I failed to list \
as an operator (integer division). Oops!
That might work.  The ODFs use a paragraph style for all of the code
blocks in the main text.  It can't hurt to give it a try - the ODFs are
all available on the Wiki Books page.

The export process uses the Collection/Book export to ODT, and from
there I simply import a template to it, tidy up a few places where the
template doesn't yet work quite right and publish.  The macro, if it
works, could be rolled into the template for future publish runs.

C.

I maintain the latest copy here:

http://extensions.services.openoffice.org/project/CodeFormatter

The code is open for use in any way you desire, with a request (not an insistence) to know of bugs, changes, what ever.

In its current state, a line is considered a single paragraph, not a new line character. This is of most importance when a comment is found, because the rest of the line is marked as a comment.

The algorithm is not perfect, but it is small. For example, a Print method on an object will be colorized as a key word (as in x.print()).

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to