Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index




On 11/28/2011 09:03 AM, drew wrote:
On Mon, 2011-11-28 at 13:50 +0000, e-letter wrote:
Perhaps try to create a style (e.g. call it 'source code text', then
format that style in terms of size, font, colour, indentation etc. and
apply the style accordingly.

There is an extension for this already - it's available (sometimes) from
the old OO.o extension site. Andrew Pitonyak is the author - I'll drop
him a line and maybe he can be nudged into adding to the LibO extension
site.

//drew



I am currently waiting on approval to upload the extension.

The extension uses styles to colorize source code for easy/pretty viewing.

If you need / desire a copy before it is approved for the LO site, drop me a line and I will e-mail it to you.

I am currently seeing it here:

http://extensions.libreoffice.org/extension-center/code-colorizer-formatter/

I cannot upload a copy there until they approve it. I am hesitant to load it on my web site since it should live on the original site.

The text that I created (in case it is not currently visible) is:

Colorize Basic, C++, Java, Perl, Python, R, XML, and C#.

A simple parser is used to identify elements in the supported languages; for example, keywords, literals, comments, and operators. Each element type is set to use a specific character style. The style sets the color used for that portion. In BASIC, the colors resemble those used by the Basic IDE. This allows for "pretty" code fragments in a Writer document.

Menu options exist to "colorize" selected text in the specified language.

I format my code snippets using paragraph styles. I place the cursor in the code snippet and then use Tools > Addons > MacroFormatterADP > Colorize Basic to colorize the current paragraph and all adjacent paragraphs that use a paragraph style that identifies the paragraph as code. The currently supported paragraph styles are "_OOoComputerCode", "_OOoComputerCodeInTable", "_OOoComputerCodeLastLine", "_code", "_code_first_line", "_code_last_line", and "_code_one_line".

It is up to the user to make sure code is formatted using a paragraph style with one of the supported names. Note that my macro documents contain these styles, and, they can be created in the current document using Tools > Addons > MacroFormatterADP > Create Paragraph Styles. When a paragraph style is created, it must have a next paragraph style. Some of the styles assume that the next paragraph style is a code type; for example, _OOoComputerCode style assumes that the next paragraph style is _OOoComputerCode. OOoComputerCodeLastLine, however, assumes that the next paragraph style is OOoTextBody. This is used when the paragraph styles are created. Use Tools > Addons > MacroFormatterADP > Configure to set the Font name, the next paragraph style, text size, and where tab stops should be set.

I attempted to configure appropriate localizations for English, French, German, Spanish, Russian, and Japanese. I have no abilities in some of these languages, so, feel free to provide corrections.



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php


--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.