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.

The config file is considered the "source" for the Pygments stylesheet, so you must create the configuration file (it can be empty) or Lektor's build will prune pygments.css.

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

lektor_markdown_highlighter-0.3.2-py2.py3-none-any.whl (4.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file lektor_markdown_highlighter-0.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for lektor_markdown_highlighter-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8af5468928f039106cb760844d1c78556b7838c47ee792c13dc81ca45a5d2ad0
MD5 42d96fb605002c69f18a4082811449a7
BLAKE2b-256 90a13a111391644bbbf2b76bea5c80a0bbcfd8cb12b4b2ffdeac60e23b5458d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page