... | @@ -4,29 +4,24 @@ |
... | @@ -4,29 +4,24 @@ |
|
|
|
|
|
## Installation
|
|
## Installation
|
|
|
|
|
|
The recommended way of installing this plugin is to use
|
|
On Linux, the recommended way of installing this plugin is to use the package provided by your distribution. If there is none, you can install the plugin manually using Gajim’s plugin installer (and install `pygments` manually).
|
|
Gajim's Plugin Installer.
|
|
|
|
|
|
|
|
For more information and instruction on how to install plugins manually, please
|
|
On Windows, simply use Gajim’s plugin installer.
|
|
refer to the [Gajim Plugin Wiki](https://dev.gajim.org/gajim/gajim-plugins/wikis/home#how-to-install-plugins).
|
|
|
|
|
|
|
|
|
|
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).
|
|
|
|
|
|
## Usage
|
|
## Usage
|
|
|
|
|
|
This plugin uses markdown-style syntax to identify which parts of a message
|
|
This plugin uses markdown-style syntax to identify which parts of a message should be formatted as code in the chat window.
|
|
should be formatted as code in the chat window.
|
|
|
|
|
|
|
|
```
|
|
```
|
|
Inline source code will be highlighted when placed in between `two single
|
|
Inline source code will be highlighted when placed inbetween `two single back-ticks`.
|
|
back-ticks`.
|
|
|
|
```
|
|
```
|
|
|
|
|
|
The language used to highlight the syntax of inline code is selected as the default language in the plugin settings.
|
|
The language used to highlight the syntax of inline code is selected as the default language in the plugin settings.
|
|
|
|
|
|
|
|
|
|
Multi-line code blocks are started by three back-ticks followed by a newline.
|
|
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
|
|
Optionally, a language can be specified directly after the opening back-ticks and before the line break:
|
|
before the line break:
|
|
|
|
|
|
|
|
````
|
|
````
|
|
```language
|
|
```language
|
... | @@ -35,40 +30,26 @@ i.e. there must be a newline here. |
... | @@ -35,40 +30,26 @@ i.e. there must be a newline here. |
|
```
|
|
```
|
|
````
|
|
````
|
|
|
|
|
|
In case no languge is specified with the opening tag or the specified language
|
|
In case no languge is specified with the opening tag or the specified language could not be identified, the default language defined in the plugin configuration will be used.
|
|
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:
|
|
|
|
|
|
You can test it by copying and sending the following text to one of your
|
|
|
|
contacts:
|
|
|
|
````
|
|
````
|
|
```python
|
|
```python
|
|
def test():
|
|
def test():
|
|
print("Hello, world!")
|
|
print("Hello, world!")
|
|
```
|
|
```
|
|
````
|
|
````
|
|
(**Note:** The contact will not receive highlighted text unless the plugin is installed on their computer as well.)
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
The configuration can be found via 'Gajim' > 'Plugins', then select the
|
|
(**Note:** The contact will not receive highlighted text unless the plugin is installed on their decive as well.)
|
|
'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.
|
|
|
|
|
|
|
|
In the configuration window, the current settings are displayed in an
|
|
## Configuration
|
|
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]).
|
|
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 how code is formatted,
|
|
|
|
including default language, style, font settings, background color and formatting of the code markers.
|
|
|
|
|
|
Please make sure that the issue you create contains `[syntax_highlight]` in the
|
|
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.
|
|
title and information such as Gajim version, Plugin version, Operating system,
|
|
|
|
etc.
|
|
|
|
|
|
|
|
## Debug
|
|
## Debug
|
|
|
|
|
... | @@ -77,23 +58,29 @@ for this plugin and/or filter log messages. |
... | @@ -77,23 +58,29 @@ for this plugin and/or filter log messages. |
|
|
|
|
|
Run
|
|
Run
|
|
```
|
|
```
|
|
gajim --loglevel gajim.plugin_system.syntax_highlight=DEBUG
|
|
gajim -l gajim.plugin_system.syntax_highlight=DEBUG
|
|
```
|
|
```
|
|
in a terminal to display the debug messages.
|
|
in a terminal to display the debug messages.
|
|
|
|
## Relation to XEP-0393 - 'Message Styling'
|
|
|
|
|
|
|
|
https://xmpp.org/extensions/xep-0393.html#pre-block
|
|
|
|
|
|
|
|
In [XEP-0393](https://xmpp.org/extensions/xep-0393.html),
|
|
|
|
the back-tick based syntax is defined as markup for preformatted
|
|
|
|
text blocks, respectively inline preformatted text.
|
|
|
|
Formatting of such text blocks with mono-spaced fonts is recommended by the XEP.
|
|
|
|
|
|
## Known Issues / ToDo
|
|
By using the same syntax as defined in XEP-0393 XMPP clients with only XEP-0393 support but without syntax highlighting can at least present their users blocks of preformatted text.
|
|
|
|
|
|
* ~~Gajim crashes when correcting a message containing highlighted code.~~
|
|
Since text inbetween the back-tick markers is not further formatted by this plugin, it can be considered 'preformatted'.
|
|
(fixed in version 1.1.0)
|
|
Hence, this plugin is compatible to the formatting options defined by XEP-0393, [section 5.1.2, "Preformatted Text"](https://xmpp.org/extensions/xep-0393.html#pre-block)
|
|
|
|
and [section 5.2.5, "Preformatted Span"](https://xmpp.org/extensions/xep-0393.html#mono).
|
|
|
|
|
|
|
|
Nevertheless, syntax highlighting for source code is not part of XEP but rather a non-standard extension introduced with this plugin.
|
|
|
|
|
|
## Credits
|
|
## Credits
|
|
|
|
|
|
Since I had no experience in writing Plugins for Gajim, I used the
|
|
Since I (Florian Muenchbach) had no experience in writing Plugins for Gajim, I used the [Latex Plugin](https://dev.gajim.org/gajim/gajim-plugins/wikis/LatexPlugin)
|
|
[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.
|
|
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/). |
|
The syntax highlighting itself is done by [pygments](http://pygments.org/). |