On Mon, 28 Nov 2011, txapollo243 wrote:
I was wondering if there is a nice way of formatting source code snippets
in LibreOffice Writer (I use the 3.3.2 version). I know it can be done
manually by changing the source code's paragraph's font to something
distinct like Courier or Courier New, but I am looking for something more
aesthetically pleasing. I mean not only using an appropriate font, but also
reserved words-specific coloring, indentation, e.t.c. Is there a plugin to
do this? The question came to me because of an 8085 Assembly project at my
university, in which we have to provide reports to our instructor, but
certainly it could also be useful for writing reports for projects based on
other programming languages.
I have tried different googling combinations, but because of the common use
of the term "source code" in the context of development, all of the results
were irrelevant.
There are two options that I currently know of, and one I would like to
implement. The use-case is a bit different, but it does work. It's not a
plugin though, but maybe that's not that hard to do.
The options are:
- GNU source-highlight (with the .outlang from the asciidoc-odf project)
https://github.com/dagwieers/asciidoc-odf/tree/master/filters/source
- AsciiDoc's code-filter (with ODF support from the asciidoc-odf project)
https://github.com/dagwieers/asciidoc-odf/tree/master/filters/code
And potentially:
- pygments (ODF output does not exist yet, not a priority for me atm)
https://github.com/dagwieers/asciidoc-odf/issues/20
These programs output ODF when you provide it source-code either by
piping, or using an option. When you pipe source-code it usually
outputs ODF snippets (without styles). If you provide a file on
the command line, it generates a Flat ODF file.
AsciiDoc's code-filter is more basic and by default does not use colors.
GNU source-highlight works as expected and supports more languages.
Only yesterday I added placeholder README files, I still need to add
command line examples and more information, but I only yesterday received
feedback that code-filter would no longer ship with AsciiDoc.
The pygments implementation looks interesting, because of the wide support
of languages.
There are two options in using GNU source-highlight (and future pygments).
Either add/import the styles from another document (to have the colors) or
have GNU source-highligh create a complete separate .fodt and import the
document. Without the styles it won't show anything !
The asciidoc-odf project uses those three (mutual-exclusive) methods
during generating ODF, so it is well integrated.
I would like to have feedback on the default output of GNU
source-highlight. We might be able to improve the output before it gets
included in the upstream project.
Kind regards,
--
-- dag wieers, dag@wieers.com, http://dag.wieers.com/
-- dagit linux solutions, info@dagit.net, http://dagit.net/
[Any errors in spelling, tact or fact are transmission errors]
--
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.