Skip to content

Commit

Permalink
Merge pull request torchbox#62 from torchbox/zerolab-patch-1
Browse files Browse the repository at this point in the history
Add code highlighting notes to README
  • Loading branch information
kevinhowbrook authored Sep 9, 2019
2 parents e6860c3 + 1ff2e3a commit 621bb24
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The markdown rendered is based on `python-markdown`, but with several
extensions to make it actually useful in Wagtail:

* Tables.
* Code highlighting.
* [Code highlighting](#syntax-highlighting).
* Inline links to pages (`<:My page name|link title>`) and documents
(`<:doc:My fancy document.pdf>`), and inline images
(`<:image:My pretty image.jpeg>`).
Expand All @@ -28,6 +28,37 @@ that shouldn't be difficult to implement (patches welcome).
### Installation
Alpha release is available on Pypi - https://pypi.org/project/wagtail-markdown/ - installable via `pip install wagtail-markdown`. It's not a production ready release.

The SimpleMDE editor uses FontAwesome for its widget icons. You can install [Wagtail FontAwesome](https://gitlab.com/alexgleason/wagtailfontawesome) via `pip install wagtailfontawesome`, or if you already have the stylesheet, add the following to a `wagtail_hooks` module in a registered app in your project:

``` python
@hooks.register('insert_global_admin_css')
def import_fontawesome_stylesheet():
elem = '<link rel="stylesheet" href="{}path/to/font-awesome.min.css">'.format(
settings.STATIC_URL
)
return format_html(elem)
```

#### Syntax highlighting

Syntax highlighting using codehilite is an optional feature, which works by
adding CSS classes to the generated HTML. To use these classes, you will need
to install Pygments (`pip install Pygments`), and to generate an appropriate
stylesheet. You can generate one as per the [Pygments
documentation](http://pygments.org/docs/quickstart/), with:

``` python
>>> from pygments.formatters import HtmlFormatter
>>> print HtmlFormatter().get_style_defs('.codehilite')
```

Save the output to a file and reference it somewhere that will be
picked up on pages rendering the relevant output, e.g. your base template:

``` html+django
<link rel="stylesheet" type="text/css" href="{% static 'path/to/pygments.css' %}">
```


### Using it

Expand Down

0 comments on commit 621bb24

Please sign in to comment.