Code snippet highlighter for LibreOffice Writer, Calc and Impress.
Switch branches/tags
Clone or download
Latest commit c2fabdf Mar 18, 2018
Permalink
Failed to load latest commit information.
codehighlighter Add build.sh Mar 18, 2018
screenshots Code Highlighter v1.0 May 2, 2017
.gitignore Initial commit Nov 24, 2015
LICENSE Code Highlighter v1.0 May 2, 2017
README.md Update instaalation guide Nov 7, 2017
build.sh Add build.sh Mar 18, 2018

README.md

libreoffice-code-highlighter

Code snippet highlighter for LibreOffice Writer and Impress.

INSTALLATION

Install Dependencies

Note: Close all the LibreOffice products before installing the dependencies

Linux Users

Install libreoffice-script-provider-python

sudo apt-get install libreoffice-script-provider-python

The above command is for Ubuntu and its derivatives. Other Linux users, may not need this package. If you encounter any problems after installing the extension, please check whether you have this or similar pacakge.

Install pygments for Python 3:

sudo pip3 install pygments

Windows Users

Windows users can install pygments using the following command

pip3 install pygments

After installation, set the environment variable: PYTHONPATH pointing to: C:\Users\<UserName>\AppData\Local\Programs\Python\Python<PythonVersion>\Lib\site-packages. Here <UserName> must be replaced by your Windows username.

Check this StackOverflow Answer to see how to set PYTHONPATH on Windows.

Install Extension

Open LibreOffice, go to Tools -> Extension Manager... and add the extension codehighlighter.oxt

You can download the extension either from the official LibreOffice extensions page or from releases. If you have downloaded the codehighlighter.oxt.zip file from GitHub releases, extract it before adding to the LibreOffice.

Assign keyboard shortcut to selected languages (Optional)

Open the LibreOffice Writer and goto Tools -> Customize -> Keyboard

  • Select the LibreOffice option button (Available on top left corner)
  • Select any desired shortcut
  • Select user/codehighlighter.oxt/highlight/highlight_<language-name>_default under the LibreOffice Macros Category
  • Click on the Modify button to set the shortcut

USAGE

  • Open LibreOffice.
  • Insert a Text Box (Insert -> Text Box).
  • Copy and paste any code snippet into that Text Box.
  • Select the Text Box.
  • Tools -> Highlight Code -> Select the language (Or use the shortcut key)

LICENSE

  • GPL v3