Code Highlighter
This extension highlights the code snippets over 350 languages in LibreOffice.
latest release: 2023-11-27 20:50:20
Description
To highlight a code snippet, follow these steps:
- Insert a new Text Box (Insert -> Text Box)
- Copy and paste/write your code snippet into the text box (You can choose any fonts based on your preference)
- Select the text box
- Go to Tools -> Highlight Code -> <Language of the code>
That's it. Your code should be colored based on the syntax.
I have tested only a few languages. If you find any bugs, please report them at GiHub Issues.
Note: This extension uses pygments to color the code. Pygments does not highlight some languages properly. Therefore, you may not get the best outcome for some languages. Sorry for the inconvenience.
Requirements (Close all LibreOffice products before installing these dependencies):
Python 3
python3-pygments
libreoffice-script-provider-python
(May be optional)
Ubuntu and its derivatives users can install the dependencies using the following commands:
sudo apt install libreoffice-script-provider-python python3-pip
sudo pip3 install pygments
Windows users can install the dependencies using the following commands:
pip3 install pygments
Mac users can install it by following the instructions given at
- https://github.com/slgobinath/libreoffice-code-highlighter/issues/10
- https://github.com/slgobinath/libreoffice-code-highlighter/issues/14
Windows requires the environment variable: PYTHONPATH
pointing to: C:\Users\<UserName>\AppData\Local\Programs\Python\Python<PythonVersion>\Lib\site-packages
-
https://github.com/slgobinath/libreoffice-code-highlighter/issues/25
-
https://github.com/slgobinath/libreoffice-code-highlighter/issues/29
-
https://github.com/slgobinath/libreoffice-code-highlighter/issues/26
Additional documentation: https://github.com/slgobinath/libreoffice-code-highlighter
Homepage: https://github.com/slgobinath/libreoffice-code-highlighter
Release | Description | Compatibility | Operating Systems | License | Release notes | Updated | |
---|---|---|---|---|---|---|---|
1.2 | - Support automatic language detection - Long list of languages are categorized into submenus |
4.0 | Linux, Windows, macOS | GPL | 2020-03-05 22:50:10 | Download | |
1.0 | Code Highlighter 1.0 379 Languages Tested with LO 5.3.2.2 |
4.0 | Linux | GPL | Supports 379 languages Tested with LibreOffice Writer, Calc and Impress 5.3.2.2 Tested languages: Java Python C |
2020-03-05 22:50:09 | Download |
1.1 | Fixed error when coloring Yaml | 4.0 | Linux | GPL | The pygments' language lexers and styles have some conflicting tokens which caused to runtime errors in this extension. Such bugs are fixed in this release. See GitHub issue #5 |
2020-03-05 22:50:09 | Download |
1.5 | Fix script error in highlighting text selection in LO Impress | 4.0 | Linux, Windows, macOS | GPL | 2020-03-05 22:50:08 | Download | |
1.4 | Release 1.4 | 4.0 | Linux, Windows | GPL | Release 1.4 | 2020-03-05 22:50:07 | Download |
1.6 | Include a dialog to select custom styles | 4.0 | Linux, Windows, macOS | GPL | 2020-03-05 22:50:06 | Download | |
1.3 | Support C++ | 4.0 | Linux, Windows, macOS | GPL | Support C++ | 2020-03-05 22:50:05 | Download |
★ ★ ☆ ☆ ☆
Post your review
You cannot post reviews until you have logged in. Login Here.
Reviews
Jorge Charry Jun 18, 2022, 6:13 PM (2 years ago)
★ ★ ★ ★ ★
Works perfectly for Fortran!
stefan pofahl Jul 26, 2021, 11:20 AM (3 years ago)
★ ★ ☆ ☆ ☆
Phyton code seems to be broken.
Installation of LibreOffice was done via PortableApps.com
My Version is: 7.1.4.2 (x86)
pythonscript.py", line 1046, in getScript
storageUri = self.provCtx.getStorageUrlFromPersistentUrl(
File "C:\bin\PortableApps\LibreOfficePortable\App\libreoffice\program\pythonscript.py", line 417, in getStorageUrlFromPersistentUrl
package = self.mapPackageName2Path[ packageName ]
Alex Nov 21, 2020, 2:53 PM (4 years ago)
★ ★ ★ ★ ☆
Works very nicely! Not sure what all the fuss is about here. Simply install the dependencies, then go to the Github releases page, click the oxt file. This should open your LO application and install the extension. Worked flawlessly for me. (v1.6 with LO 7.x on Debian) I’m not to fond of the usability (once you have applied a style, it is not associated with the selected text), but that’s a different story.
G Nov 1, 2020, 7:32 PM (4 years ago)
★ ★ ★ ★ ☆
Worked perfectly for me after renaming it from edb...-whatever-....oxt to simply codehighlighter.oxt and then installing it after taking care of the dependencies
Bruce Oct 23, 2020, 6:12 PM (4 years ago)
★ ☆ ☆ ☆ ☆
Difficult to install, So left it.
Ego Ipse Sep 11, 2020, 3:19 AM (4 years ago)
★ ☆ ☆ ☆ ☆
It doesn't work. LibreOffice 7.0.1
Will Jul 2, 2020, 3:39 PM (4 years ago)
☆ ☆ ☆ ☆ ☆
Same as
https://github.com/slgobinath/libreoffice-code-highlighter/issues/29#issuecomment-635216707
I had to remove the prefix in the installation file name to have it work as intended.
Otherwise very good work !
Alex ndm Jun 24, 2020, 12:29 PM (4 years ago)
★ ★ ★ ★ ★
Thanks for you work !
If, after installing the python package "pygments" (required by code-highlighter), you get the following error message when trying to run the add-on : "Message: <class 'ImportError'>: No module named 'pygments' ...", it may be because LibreOffice embeds its own version of python, independant of the one running on your system.
In order to properly install pygments to the LibreOffice embedded version of python on linux, you can add it to the folder "/opt/libreofficeX.X/program/python-core-X.X.X/lib/site-packages" where the Xs depend the version of LibreOffice (and its embbeded python) you are running. There should be an equivalent fix for other OSs.
admin Jun 14, 2020, 7:04 PM (4 years ago)
★ ☆ ☆ ☆ ☆
download extension file and rename it to codehighlighter.oxt
then install
FG Jun 9, 2020, 10:29 AM (4 years ago)
☆ ☆ ☆ ☆ ☆
Same with me. LibreOffice 6.4.3.2 on Ubuntu, with OpenJDK-JRE and openoffice-java-common.
1 2 next »
No one has commented on this page yet.
RSS feed for reviews on this page | RSS feed for all reviews