Hey Miguel,
thank you for you reply.
This the kind of macro I need but it does not seem to work with LibreOffice
4 unfortunately.
I think I'm going to make a snapshot of my codes and include them as a
picture.
Éric.
Hey Miguel,
thank you for you reply.
This the kind of macro I need but it does not seem to work with LibreOffice
4 unfortunately.
I think I'm going to make a snapshot of my codes and include them as a
picture.
Éric.
I do this all the time using the syntax highlighter in Notepad++.
If you don't have Notepad++ (my favorite code/text editor), get it here: http://notepad-plus-plus.org/
Here's how to get syntax highlighted code into your LibreOffice documents:
1: Open source file with Notepad++
2: In Notepad++ click Plugins > NppExport > Export to RTF
You will now have a syntax highlighted copy of your source file however, it will be double spaced. To remove the extra spaces proceed as follows:
1: With any editor, open the .rtf file you just created
2: Search and replace "\par" with "\line"
3: Save file
Open the .rtf file with LibreOffice Writer, select all (CTRL-A), copy & paste into your working document.
This sounds like a bit of an ordeal, but I do this quite frequently, and once you've done it a few times, it becomes very fast and easy.
Good luck,
-Bill
I used NoteTab [free] and NotePad ++ as my first Windows programming and HTML editor.
Having the extension to do the highlighting in Writer is a good idea though.
If I remember correctly, for the Note. . . editors you can find "add ons" that are specific to the programming code. I have not tried them in a few years, but they were a real big aid to my early programming within the Windows environment. I do not remember when I installed the first one, but it was in the early days of my having dial-up Internet access, or a little later. I do not remember if I got online with Win 95 or 98 era. but I know I used them when I was using he "new" Windows version - XP.
Would you tell us how large of a document these code samples will be in?
Are you writing a programming guide type of documentation?
Hopefully the RTF formatting option works. Sometimes pictures of text do not work well, since the snapshot resolution and the print resolution could be very different. I tend to have to make 600 DPI scanned images to get a decent "near 1 to 1 size" image when I print out a "best" print option.
If you need to do the snapshot, I would run the image through a scaling option, with a edge smoothing "effect", to make the image in a large enough DPI and actual print size for your needs that actually look well.
If none of the suggestions you have received already work for you. You might want to look at Andrew Pitonyak's book [1]. It has syntax highlighted basic code. I don't know if you can tell how he did by looking at the document though.
[1] http://www.pitonyak.org/book/
Regards, JIm
Hi
There are a lot of text-editors out there. Gedit show colour-coding and is available on Windows too. It's OpenSource and uses the GPL License. SciTe also does colour-coding and may do some more fancy stuff too. I'm sure there are lots of others. The main thing is to avoid using Notepad (without the double + at the end of it's name) as that is the only one that is really painful. The rest are a plateau above it and each has it's own advantages or quirks.
Regards from
Tom
Dear all,
Thank for all your suggestion.
I use Linux and Notepad++ or NoteTab are available on widows only.
I think I'll try the RTF generation option.
Thanks again.
Éric..
Hi
Is that RTF as in "Rich Text Format" if so then it's a dying format owned by
Microsoft. They stopped developing it a few years ago so any bugs or
problems with it will remain unpatched. Apparently it's inconsistent across
different programs and different platforms and support for it is dropping
away. It might still work as an intermediary format for getting output into
Writer or something but is not good for long-term storage or for sharing
documents with other people.
Almost every other format can hold colour information so i'm not sure why
this is such a struggle. Is it the question of getting the colour
information into LibreOffice?
Regards from
Tom
aihaike wrote
If you are using NetBeans (available on most Linux flavors) you can export to HTML by clicking File > Print to HTML.
-Bill
Eric,
I use Kate in KDE to do my source coding and it does color syntax highlighting. I am sure there are other Linux plain text editors that do it too. However, those colors are only in Kate and do not exist in the edited file. One thing you might try is to capture the screen and insert it into your LO document as an image. I have done that to print something and the colors do exist in the LO document. However, if your source file is long, that could get tedious fast.
Another nice feature of Kate is that you can define projects, Kate calls them "sessions", which may include several files. Opening a saved session, opens all the files and they can be listed in a hierarchical list in a left window pane. This makes copying and pasting from one file to another simple.
Hope this helps.
Girvin Herr
I use it in LO 4 all the time, what error do you receive?
I did it using the referenced plug-in. My macro documents is the reason I wrote the plug-in in the first place. I add new languages as I need to highlight them. I have added some by special request.
I am currently using that plug-in in LO 4. I have not used it in the latest version of LO because when I installed the latest version, I was suddenly not able to open any of my password protected files. I do not know if it was related to some other issue (like LO was damaged when I updated from Fedora 18 to Fedora 19), but removing the latest and going back one version allowed me to open my password protected files again....