Skip to main content

Lektor plugin that adds syntax highlighting for markdown blocks with Pygments.

Project description

lektor-markdown-highlighter

This plugin adds support for syntax highlighting through Pygments to Lektor's markdown support.

Enabling the Plugin

To enable the plugin run this command:

$ lektor plugins add markdown-highlighter

Configuring the Plugin

The plugin has a config file that is used to configure a few things for Pygments. Just create a file named markdown-highlighter.ini into your configs/ folder. Currently only pygments.style is used:

[pygments]
style = tango

You can use this to select any of the built-in Pygments styles. Support for custom styles will come in the future.

In Markdown

To use the syntax highlighter you need to use fenced blocks and pass the name of the pygments lexer after the opening fence:

```python
print "Hello World!"
```

In Templates

In templates the plugin provides the get_pygments_stylesheet function which can be used to generate and retrieve a link to the pygments stylesheet:

<link rel="stylesheet" href="{{ get_pygments_stylesheet()|url }}">

In addition the |pygmentize filter can be used to highlight code from templates. It takes one argument which is the lexer name:

{{ 'print "Hello World!"'|pygmentize('python') }}

Project details


Release history Release notifications

This version
History Node

0.3

History Node

0.2

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
lektor_markdown_highlighter-0.3-py3-none-any.whl (3.1 kB) Copy SHA256 hash SHA256 Wheel py3 May 12, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page