|
|
# Syntax Highlighting Plugin for Gajim
|
|
|
|
|
|
Plugin that highlights source code blocks in chatbox.
|
|
|
|
|
|
[Gajim](https://gajim.org) Plugin that highlights source code blocks in chat window.
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
Use Plugin Installer.
|
|
|
The recommended way of installing this plugin is to use
|
|
|
Gajim's Plugin Installer.
|
|
|
|
|
|
For more information and instruction on how to install plugins manually, please
|
|
|
refer to the [Gajim Plugin Wiki](https://dev.gajim.org/gajim/gajim-plugins/wikis/home#how-to-install-plugins).
|
|
|
|
|
|
|
|
|
This plugin also requires [Pygments](http://pygments.org/) to be installed on your system.
|
|
|
## Usage
|
|
|
|
|
|
This plugin uses markdown-style syntax to identify which parts of a message
|
|
|
should be formatted as code in the chat window.
|
|
|
|
|
|
## Example
|
|
|
```
|
|
|
Inline source code will be highlighted when placed in between `two single
|
|
|
back-ticks`.
|
|
|
```
|
|
|
|
|
|
![gajim](/uploads/d91b55e6e21d73eed7c94e2af27407d4/gajim.png)
|
|
|
The language used to highlight the syntax of inline code is selected as the default language in the plugin settings.
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
Source code between `@@` tags will be highlighted in the chatbox. You can test it by copying and sending the following text to one of your contacts:
|
|
|
Multi-line code blocks are started by three back-ticks followed by a newline.
|
|
|
Optionally, a language can be specified directly after the opening back-ticks and
|
|
|
before the line break:
|
|
|
|
|
|
````
|
|
|
```language
|
|
|
Note, that the last line of a code block may only contain the closing back-ticks,
|
|
|
i.e. there must be a newline here.
|
|
|
```
|
|
|
@@def test():
|
|
|
````
|
|
|
|
|
|
In case no languge is specified with the opening tag or the specified language
|
|
|
could not be identified, the default languge configured in the settings is
|
|
|
used.
|
|
|
|
|
|
You can test it by copying and sending the following text to one of your
|
|
|
contacts:
|
|
|
````
|
|
|
```python
|
|
|
def test():
|
|
|
print("Hello, world!")
|
|
|
@@
|
|
|
```
|
|
|
````
|
|
|
(**Note:** The contact will not receive highlighted text unless the plugin is installed on their computer as well.)
|
|
|
|
|
|
(**Note:** Your contact will receive highlighted text only if the plugin is installed.)
|
|
|
## Configuration
|
|
|
|
|
|
If you want to send code written in a programming language other than the default, you can specify the language between the first `@@` and one additional `@` tag:
|
|
|
The configuration can be found via 'Gajim' > 'Plugins', then select the
|
|
|
'Source Code Syntax Highlight' Plugin and click the gears symbol.
|
|
|
The configuration options let you specify many details how code is formatted,
|
|
|
including default language, style, font settings, background color and formatting
|
|
|
of the code markers.
|
|
|
|
|
|
```
|
|
|
@@bash@
|
|
|
echo "Hello, world"
|
|
|
@@
|
|
|
```
|
|
|
In the configuration window, the current settings are displayed in an
|
|
|
interactive preview panel. This allows you to directly check how code would
|
|
|
look like in the message
|
|
|
window.
|
|
|
|
|
|
## Report Bugs and Feature Requests
|
|
|
|
|
|
For bug reports, please report them to the [Gajim Plugin Issue tracker](https://dev.gajim.org/gajim/gajim-plugins/issues/new?issue[FlorianMuenchbach]=&issue[description]=Gajim%20Version%3A%20%0APlugin%20Version%3A%0AOperating%20System%3A&issue[title]=[syntax_highlight]).
|
|
|
|
|
|
Please make sure that the issue you create contains `[syntax_highlight]` in the
|
|
|
title and information such as Gajim version, Plugin version, Operating system,
|
|
|
etc.
|
|
|
|
|
|
## Debug
|
|
|
|
|
|
The plugin adds its own logger. It can be used to set a specific debug level
|
|
|
for this plugin and/or filter log messages.
|
|
|
|
|
|
Run the following command in a terminal to display the debug messages:
|
|
|
|
|
|
Run
|
|
|
```
|
|
|
gajim --loglevel gajim.plugin_system.syntax_highlight=DEBUG
|
|
|
```
|
|
|
in a terminal to display the debug messages.
|
|
|
|
|
|
|
|
|
## Known Issues / ToDo
|
|
|
|
|
|
* Gajim crashes when correcting a message containing highlighted code.
|
|
|
* ~~Gajim crashes when correcting a message containing highlighted code.~~
|
|
|
(fixed in version 1.1.0)
|
|
|
|
|
|
|
|
|
## Credits
|
|
|
|
|
|
Since I had no experience in writing Plugins for Gajim, I used the [Latex Plugin](./LatexPlugin) written by Yves Fischer and Yann Leboulanger as an example and copied a big portion of initial code. Therefore, credits go to the authors of the Latex Plugin for providing an example.
|
|
|
Since I had no experience in writing Plugins for Gajim, I used the
|
|
|
[Latex Plugin](https://dev.gajim.org/gajim/gajim-plugins/wikis/LatexPlugin)
|
|
|
written by Yves Fischer and Yann Leboulanger as an example and copied a big
|
|
|
portion of initial code. Therefore, credits go to the authors of the Latex
|
|
|
Plugin for providing an example.
|
|
|
|
|
|
The syntax highlighting itself is done by [pygments](http://pygments.org/). |