wagtail-markdown


Namewagtail-markdown JSON
Version 0.12.1 PyPI version JSON
download
home_page
SummaryMarkdown support for Wagtail
upload_time2024-03-09 15:23:08
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords wagtail django markdown
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ## wagtail-markdown: Markdown fields and blocks for Wagtail

[![Build status](https://img.shields.io/github/actions/workflow/status/torchbox/wagtail-markdown/ci.yml?branch=main)](https://github.com/torchbox/wagtail-markdown/actions)
[![PyPI](https://img.shields.io/pypi/v/wagtail-markdown.svg)](https://pypi.org/project/wagtail-markdown/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/torchbox/wagtail-markdown/main.svg)](https://results.pre-commit.ci/latest/github/torchbox/wagtail-markdown/main)


Tired of annoying rich text editors getting in the way of your content
input?  Wish Wagtail worked more like a wiki?  Well, now it can.

`wagtail-markdown` provides Markdown field support for [Wagtail](https://github.com/torchbox/wagtail/).
Specifically, it provides:

* A `wagtailmarkdown.blocks.MarkdownBlock` for use in StreamFields.
* A `wagtailmarkdown.fields.MarkdownField` for use in Page models.
* A `markdown` template tag.

The markdown rendered is based on `python-markdown`, but with several
extensions to make it actually useful in Wagtail:

* [Code highlighting](#syntax-highlighting).
* [Inline links](#inline-links).
* Inline Markdown preview using [EasyMDE](https://github.com/Ionaru/easy-markdown-editor)
* Tables

These are implemented using the `python-markdown` extension interface.

### Installation
Available on PyPI - https://pypi.org/project/wagtail-markdown/.

Install using pip (`pip install wagtail-markdown`), poetry (`poetry add wagtail-markdown`) or your package manager of choice.

After installing the package, add `wagtailmarkdown` to the list of installed apps in your settings file:

```python
# settings.py

INSTALLED_APPS = [
    # ...
    "wagtailmarkdown",
]
```

### Configuration

All `wagtail-markdown` settings are defined in a single `WAGTAILMARKDOWN` dictionary in your settings file:

```python
# settings.py

WAGTAILMARKDOWN = {
    "autodownload_fontawesome": False,
    "allowed_tags": [],  # optional. a list of HTML tags. e.g. ['div', 'p', 'a']
    "allowed_styles": [],  # optional. a list of styles
    "allowed_attributes": {},  # optional. a dict with HTML tag as key and a list of attributes as value
    "allowed_settings_mode": "extend",  # optional. Possible values: "extend" or "override". Defaults to "extend".
    "extensions": [],  # optional. a list of python-markdown supported extensions
    "extension_configs": {},  # optional. a dictionary with the extension name as key, and its configuration as value
    "extensions_settings_mode": "extend",  # optional. Possible values: "extend" or "override". Defaults to "extend".
    "tab_length": 4,  # optional. Sets the length of tabs used by python-markdown to render the output. This is the number of spaces used to replace with a tab character. Defaults to 4.
}
```

Note: `allowed_tags`, `allowed_styles`, `allowed_attributes`, `extensions` and `extension_configs` are added to the
[default wagtail-markdown settings](https://github.com/torchbox/wagtail-markdown/blob/main/src/wagtailmarkdown/constants.py).


#### Custom FontAwesome Configuration - `autodownload_fontawesome`
The EasyMDE editor is compatible with [FontAwesome 5](https://fontawesome.com/how-to-use/graphql-api/intro/getting-started).
By default, EasyMDE will get version 4.7.0 from a CDN. To specify your own version, set

```python
# settings.py

WAGTAILMARKDOWN = {
    # ...
    "autodownload_fontawesome": False,
}
```

Get the desired FontAwesome version. For the latest version you can use:

```sh
curl -H "Content-Type: application/json" \
-d '{ "query": "query { release(version: \"latest\") { version } }" }' \
https://api.fontawesome.com
```

then add the following to a `wagtail_hooks` module in a registered app in your application:

```python
# Content of app_name/wagtail_hooks.py
from wagtail import hooks
from django.conf import settings
from django.utils.html import format_html


@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)
```

Note that due to the way EasyMDE defines the toolbar icons it is not compatible with
[Wagtail FontAwesome](https://gitlab.com/alexgleason/wagtailfontawesome)

##### Using with django-compressor

You may have your own SCSS sources that you want to precompile on the fly.
We can invoke django-compressor to fetch our Font Awesome SCSS sources like this:

```python
# Content of app_name/wagtail_hooks.py
from compressor.css import CssCompressor
from wagtail import hooks
from django.conf import settings
from django.utils.html import format_html


@hooks.register("insert_global_admin_css")
def import_fontawesome_stylesheet():
    elem = '<link rel="stylesheet" type="text/x-scss" href="{}scss/fontawesome.scss">'.format(
        settings.STATIC_URL
    )
    compressor = CssCompressor("css", content=elem)
    output = ""
    for s in compressor.hunks():
        output += s
    return format_html(output)
```


#### Markdown extensions - `extensions`/`extension_configs`

You can configure wagtail-markdown to use additional Markdown extensions using the `extensions` setting.

For example, to enable the [Table of Contents](https://python-markdown.github.io/extensions/toc/) and
[Sane Lists](https://python-markdown.github.io/extensions/sane_lists/) extensions:

```python
WAGTAILMARKDOWN = {
    # ...
    "extensions": ["toc", "sane_lists"]
}
```

Extensions can be configured too:

```python
WAGTAILMARKDOWN = {
    # ...
    "extension_configs": {"pymdownx.arithmatex": {"generic": True}}
}
```

#### Allowed HTML - `allowed_styles` / `allowed_attributes` / `allowed_tags`

wagtail-markdown uses [bleach](https://github.com/mozilla/bleach) to sanitise the input. To extend the default
bleach configurations, you can add your own allowed tags, styles or attributes:

```python
WAGTAILMARKDOWN = {
    # ...
    "allowed_tags": ["i"],
    "allowed_styles": ["some_style"],
    "allowed_attributes": {"i": ["aria-hidden"]},
}
```

#### 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' %}">
```

#### EasyMDE configuration

You can customise the [EasyMDE options](https://github.com/Ionaru/easy-markdown-editor#configuration). To do this,
create a JavaScript file in your app (for example `my_app_name/static/js/easymde_custom.js`) and add the following:

```js
window.wagtailMarkdown = window.wagtailMarkdown || {};
window.wagtailMarkdown.options = window.wagtailMarkdown.options || {};
window.wagtailMarkdown.options.spellChecker = false;
```

This overrides a specific option and leaves any other ones untouched. If you want to override all options, you can do:

```js
window.wagtailMarkdown = window.wagtailMarkdown || {};
window.wagtailMarkdown.options = {
    spellChecker: false,
}
```

To make sure that your JavaScript is executed, create a hook in `my_app_name/wagtail_hooks.py`:

```python
from django.templatetags.static import static
from django.utils.html import format_html

from wagtail import hooks


@hooks.register("insert_global_admin_js", order=100)
def global_admin_js():
    """Add /static/js/admin/easymde_custom.js to the admin."""
    return format_html('<script src="{}"></script>', static("js/easymde_custom.js"))
```

#### Inline links

wagtail-markdown supports custom inline links syntax:

| Link to                                | Syntax                                                              | Notes                                                                                                                                                                |
|----------------------------------------|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Pages                                  | `[title](page:PAGE_ID)`                                             | `PAGE_ID` is the page ID                                                                                                                                             |
| Documents                              | `[title](doc:DOCUMENT_ID)`                                          | `DOCUMENT_ID` is the document ID                                                                                                                                     |
| Media                                  | `[title](media:MEDIA_ID)`                                           | Needs [wagtailmedia](https://github.com/torchbox/wagtailmedia). `MEDIA_ID` is the media item ID                                                                      |
| Images                                 | `![alt text](image:IMAGE_ID)`                                       | Renders an image tag. `IMAGE_ID` is the image ID                                                                                                                     |
| ↳ with class attribute                 | `![alt text](image:IMAGE_ID,class=the-class-name)`                  | adds `class="the-class-name" to the `<img>` tag                                                                                                                      |
| ↳ with rendition filter                | `![alt text](image:IMAGE_ID,filter=fill-200x200&#x7c;format-webp)`  | Uses the same format as [generating renditions in Python](https://docs.wagtail.org/en/stable/advanced_topics/images/renditions.html#generating-renditions-in-python) |
| ↳ class name and filter can be stacked | `![alt text](image:IMAGE_ID,class=the-class-name,filter=width-100)` |                                                                                                                                                                      |



Previously we supported custom link tags that used the target object title. They had the following form:
* `<:My page name|link title>` or `<:page:My page title>`
* `<:doc:My fancy document.pdf>`
* `<:image:My pretty image.jpeg>`, `<:image:My pretty image.jpeg|left>` (`left` classname),
  `<:image:My pretty image.jpeg|right>` (`right` classname), `<:image:My pretty image.jpeg|full>` (`full-name` classname),
  `<:image:My pretty image.jpeg|width=123>` (outputs a rendition with `width-123`, and class `left`)

⚠️ these types of tags are not reliable as titles can and will change. Support for  will be removed in the future.

### Usage

You can use it as a `StreamField` block:

```python
from wagtail.blocks import StreamBlock

from wagtailmarkdown.blocks import MarkdownBlock


class MyStreamBlock(StreamBlock):
    markdown = MarkdownBlock(icon="code")
    # ...
```

<img src="https://i.imgur.com/4NFcfHd.png" width="728px" alt="">

Or use as a page field:

```python
from wagtail.admin.panels import FieldPanel
from wagtail.models import Page

from wagtailmarkdown.fields import MarkdownField


class MyPage(Page):
    body = MarkdownField()

    content_panels = [
        FieldPanel("title", classname="full title"),
        FieldPanel("body"),
    ]
```

And render the content in a template:

```html+django
{% load wagtailmarkdown %}
<article>
{{ self.body|markdown }}
</article>
```

<img src="https://i.imgur.com/Sj1f4Jh.png" width="728px" alt="">


## Compatibility

wagtail-markdown supports Wagtail 4.1 and above, python-markdown 3.3 and above.

## Contributing

All contributions are welcome!

### Installation

To make changes to this project, first clone this repository:

```shell
git clone git@github.com:torchbox/wagtail-markdown.git
cd wagtail-markdown
```

With your preferred Python virtual environment activated, install testing dependencies:

```shell
pip install -e '.[testing]' -U
```

### pre-commit

Note that this project uses [pre-commit](https://github.com/pre-commit/pre-commit). To set up locally:

```shell
# if you don't have it yet
$ pip install pre-commit
# go to the project directory
$ cd wagtail-markdown
# initialize pre-commit
$ pre-commit install

# Optional, run all checks once for this, then the checks will run only on the changed files
$ pre-commit run --all-files
```

### How to run tests

To run all tests in all environments:

```sh
tox -p
```

To run tests for a specific environment:

```shell
tox -e py312-django5.0-wagtail6.0
```

or, a specific test

```shell
tox -e py312-django5.0-wagtail6.0 -- tests.testapp.tests.test_admin.TestFieldsAdmin
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "wagtail-markdown",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Dan Braghis <dan.braghis@torchbox.com>",
    "keywords": "Wagtail,Django,Markdown",
    "author": "",
    "author_email": "Felicity Tarnell  <hello@torchbox.com>",
    "download_url": "https://files.pythonhosted.org/packages/e2/4b/d7b76d1e0c4b29fcd074bd75839232fb2c4aae55d28fb59c0c2edab37e94/wagtail_markdown-0.12.1.tar.gz",
    "platform": null,
    "description": "## wagtail-markdown: Markdown fields and blocks for Wagtail\n\n[![Build status](https://img.shields.io/github/actions/workflow/status/torchbox/wagtail-markdown/ci.yml?branch=main)](https://github.com/torchbox/wagtail-markdown/actions)\n[![PyPI](https://img.shields.io/pypi/v/wagtail-markdown.svg)](https://pypi.org/project/wagtail-markdown/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/torchbox/wagtail-markdown/main.svg)](https://results.pre-commit.ci/latest/github/torchbox/wagtail-markdown/main)\n\n\nTired of annoying rich text editors getting in the way of your content\ninput?  Wish Wagtail worked more like a wiki?  Well, now it can.\n\n`wagtail-markdown` provides Markdown field support for [Wagtail](https://github.com/torchbox/wagtail/).\nSpecifically, it provides:\n\n* A `wagtailmarkdown.blocks.MarkdownBlock` for use in StreamFields.\n* A `wagtailmarkdown.fields.MarkdownField` for use in Page models.\n* A `markdown` template tag.\n\nThe markdown rendered is based on `python-markdown`, but with several\nextensions to make it actually useful in Wagtail:\n\n* [Code highlighting](#syntax-highlighting).\n* [Inline links](#inline-links).\n* Inline Markdown preview using [EasyMDE](https://github.com/Ionaru/easy-markdown-editor)\n* Tables\n\nThese are implemented using the `python-markdown` extension interface.\n\n### Installation\nAvailable on PyPI - https://pypi.org/project/wagtail-markdown/.\n\nInstall using pip (`pip install wagtail-markdown`), poetry (`poetry add wagtail-markdown`) or your package manager of choice.\n\nAfter installing the package, add `wagtailmarkdown` to the list of installed apps in your settings file:\n\n```python\n# settings.py\n\nINSTALLED_APPS = [\n    # ...\n    \"wagtailmarkdown\",\n]\n```\n\n### Configuration\n\nAll `wagtail-markdown` settings are defined in a single `WAGTAILMARKDOWN` dictionary in your settings file:\n\n```python\n# settings.py\n\nWAGTAILMARKDOWN = {\n    \"autodownload_fontawesome\": False,\n    \"allowed_tags\": [],  # optional. a list of HTML tags. e.g. ['div', 'p', 'a']\n    \"allowed_styles\": [],  # optional. a list of styles\n    \"allowed_attributes\": {},  # optional. a dict with HTML tag as key and a list of attributes as value\n    \"allowed_settings_mode\": \"extend\",  # optional. Possible values: \"extend\" or \"override\". Defaults to \"extend\".\n    \"extensions\": [],  # optional. a list of python-markdown supported extensions\n    \"extension_configs\": {},  # optional. a dictionary with the extension name as key, and its configuration as value\n    \"extensions_settings_mode\": \"extend\",  # optional. Possible values: \"extend\" or \"override\". Defaults to \"extend\".\n    \"tab_length\": 4,  # optional. Sets the length of tabs used by python-markdown to render the output. This is the number of spaces used to replace with a tab character. Defaults to 4.\n}\n```\n\nNote: `allowed_tags`, `allowed_styles`, `allowed_attributes`, `extensions` and `extension_configs` are added to the\n[default wagtail-markdown settings](https://github.com/torchbox/wagtail-markdown/blob/main/src/wagtailmarkdown/constants.py).\n\n\n#### Custom FontAwesome Configuration - `autodownload_fontawesome`\nThe EasyMDE editor is compatible with [FontAwesome 5](https://fontawesome.com/how-to-use/graphql-api/intro/getting-started).\nBy default, EasyMDE will get version 4.7.0 from a CDN. To specify your own version, set\n\n```python\n# settings.py\n\nWAGTAILMARKDOWN = {\n    # ...\n    \"autodownload_fontawesome\": False,\n}\n```\n\nGet the desired FontAwesome version. For the latest version you can use:\n\n```sh\ncurl -H \"Content-Type: application/json\" \\\n-d '{ \"query\": \"query { release(version: \\\"latest\\\") { version } }\" }' \\\nhttps://api.fontawesome.com\n```\n\nthen add the following to a `wagtail_hooks` module in a registered app in your application:\n\n```python\n# Content of app_name/wagtail_hooks.py\nfrom wagtail import hooks\nfrom django.conf import settings\nfrom django.utils.html import format_html\n\n\n@hooks.register(\"insert_global_admin_css\")\ndef import_fontawesome_stylesheet():\n    elem = '<link rel=\"stylesheet\" href=\"{}path/to/font-awesome.min.css\">'.format(\n        settings.STATIC_URL\n    )\n    return format_html(elem)\n```\n\nNote that due to the way EasyMDE defines the toolbar icons it is not compatible with\n[Wagtail FontAwesome](https://gitlab.com/alexgleason/wagtailfontawesome)\n\n##### Using with django-compressor\n\nYou may have your own SCSS sources that you want to precompile on the fly.\nWe can invoke django-compressor to fetch our Font Awesome SCSS sources like this:\n\n```python\n# Content of app_name/wagtail_hooks.py\nfrom compressor.css import CssCompressor\nfrom wagtail import hooks\nfrom django.conf import settings\nfrom django.utils.html import format_html\n\n\n@hooks.register(\"insert_global_admin_css\")\ndef import_fontawesome_stylesheet():\n    elem = '<link rel=\"stylesheet\" type=\"text/x-scss\" href=\"{}scss/fontawesome.scss\">'.format(\n        settings.STATIC_URL\n    )\n    compressor = CssCompressor(\"css\", content=elem)\n    output = \"\"\n    for s in compressor.hunks():\n        output += s\n    return format_html(output)\n```\n\n\n#### Markdown extensions - `extensions`/`extension_configs`\n\nYou can configure wagtail-markdown to use additional Markdown extensions using the `extensions` setting.\n\nFor example, to enable the [Table of Contents](https://python-markdown.github.io/extensions/toc/) and\n[Sane Lists](https://python-markdown.github.io/extensions/sane_lists/) extensions:\n\n```python\nWAGTAILMARKDOWN = {\n    # ...\n    \"extensions\": [\"toc\", \"sane_lists\"]\n}\n```\n\nExtensions can be configured too:\n\n```python\nWAGTAILMARKDOWN = {\n    # ...\n    \"extension_configs\": {\"pymdownx.arithmatex\": {\"generic\": True}}\n}\n```\n\n#### Allowed HTML - `allowed_styles` / `allowed_attributes` / `allowed_tags`\n\nwagtail-markdown uses [bleach](https://github.com/mozilla/bleach) to sanitise the input. To extend the default\nbleach configurations, you can add your own allowed tags, styles or attributes:\n\n```python\nWAGTAILMARKDOWN = {\n    # ...\n    \"allowed_tags\": [\"i\"],\n    \"allowed_styles\": [\"some_style\"],\n    \"allowed_attributes\": {\"i\": [\"aria-hidden\"]},\n}\n```\n\n#### Syntax highlighting\n\nSyntax highlighting using codehilite is an optional feature, which works by\nadding CSS classes to the generated HTML. To use these classes, you will need\nto install Pygments (`pip install Pygments`), and to generate an appropriate\nstylesheet. You can generate one as per the [Pygments documentation](http://pygments.org/docs/quickstart/), with:\n\n```python\nfrom pygments.formatters import HtmlFormatter\n\nprint(HtmlFormatter().get_style_defs(\".codehilite\"))\n```\n\nSave the output to a file and reference it somewhere that will be\npicked up on pages rendering the relevant output, e.g. your base template:\n\n```html+django\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{% static 'path/to/pygments.css' %}\">\n```\n\n#### EasyMDE configuration\n\nYou can customise the [EasyMDE options](https://github.com/Ionaru/easy-markdown-editor#configuration). To do this,\ncreate a JavaScript file in your app (for example `my_app_name/static/js/easymde_custom.js`) and add the following:\n\n```js\nwindow.wagtailMarkdown = window.wagtailMarkdown || {};\nwindow.wagtailMarkdown.options = window.wagtailMarkdown.options || {};\nwindow.wagtailMarkdown.options.spellChecker = false;\n```\n\nThis overrides a specific option and leaves any other ones untouched. If you want to override all options, you can do:\n\n```js\nwindow.wagtailMarkdown = window.wagtailMarkdown || {};\nwindow.wagtailMarkdown.options = {\n    spellChecker: false,\n}\n```\n\nTo make sure that your JavaScript is executed, create a hook in `my_app_name/wagtail_hooks.py`:\n\n```python\nfrom django.templatetags.static import static\nfrom django.utils.html import format_html\n\nfrom wagtail import hooks\n\n\n@hooks.register(\"insert_global_admin_js\", order=100)\ndef global_admin_js():\n    \"\"\"Add /static/js/admin/easymde_custom.js to the admin.\"\"\"\n    return format_html('<script src=\"{}\"></script>', static(\"js/easymde_custom.js\"))\n```\n\n#### Inline links\n\nwagtail-markdown supports custom inline links syntax:\n\n| Link to                                | Syntax                                                              | Notes                                                                                                                                                                |\n|----------------------------------------|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Pages                                  | `[title](page:PAGE_ID)`                                             | `PAGE_ID` is the page ID                                                                                                                                             |\n| Documents                              | `[title](doc:DOCUMENT_ID)`                                          | `DOCUMENT_ID` is the document ID                                                                                                                                     |\n| Media                                  | `[title](media:MEDIA_ID)`                                           | Needs [wagtailmedia](https://github.com/torchbox/wagtailmedia). `MEDIA_ID` is the media item ID                                                                      |\n| Images                                 | `![alt text](image:IMAGE_ID)`                                       | Renders an image tag. `IMAGE_ID` is the image ID                                                                                                                     |\n| \u21b3 with class attribute                 | `![alt text](image:IMAGE_ID,class=the-class-name)`                  | adds `class=\"the-class-name\" to the `<img>` tag                                                                                                                      |\n| \u21b3 with rendition filter                | `![alt text](image:IMAGE_ID,filter=fill-200x200&#x7c;format-webp)`  | Uses the same format as [generating renditions in Python](https://docs.wagtail.org/en/stable/advanced_topics/images/renditions.html#generating-renditions-in-python) |\n| \u21b3 class name and filter can be stacked | `![alt text](image:IMAGE_ID,class=the-class-name,filter=width-100)` |                                                                                                                                                                      |\n\n\n\nPreviously we supported custom link tags that used the target object title. They had the following form:\n* `<:My page name|link title>` or `<:page:My page title>`\n* `<:doc:My fancy document.pdf>`\n* `<:image:My pretty image.jpeg>`, `<:image:My pretty image.jpeg|left>` (`left` classname),\n  `<:image:My pretty image.jpeg|right>` (`right` classname), `<:image:My pretty image.jpeg|full>` (`full-name` classname),\n  `<:image:My pretty image.jpeg|width=123>` (outputs a rendition with `width-123`, and class `left`)\n\n\u26a0\ufe0f these types of tags are not reliable as titles can and will change. Support for  will be removed in the future.\n\n### Usage\n\nYou can use it as a `StreamField` block:\n\n```python\nfrom wagtail.blocks import StreamBlock\n\nfrom wagtailmarkdown.blocks import MarkdownBlock\n\n\nclass MyStreamBlock(StreamBlock):\n    markdown = MarkdownBlock(icon=\"code\")\n    # ...\n```\n\n<img src=\"https://i.imgur.com/4NFcfHd.png\" width=\"728px\" alt=\"\">\n\nOr use as a page field:\n\n```python\nfrom wagtail.admin.panels import FieldPanel\nfrom wagtail.models import Page\n\nfrom wagtailmarkdown.fields import MarkdownField\n\n\nclass MyPage(Page):\n    body = MarkdownField()\n\n    content_panels = [\n        FieldPanel(\"title\", classname=\"full title\"),\n        FieldPanel(\"body\"),\n    ]\n```\n\nAnd render the content in a template:\n\n```html+django\n{% load wagtailmarkdown %}\n<article>\n{{ self.body|markdown }}\n</article>\n```\n\n<img src=\"https://i.imgur.com/Sj1f4Jh.png\" width=\"728px\" alt=\"\">\n\n\n## Compatibility\n\nwagtail-markdown supports Wagtail 4.1 and above, python-markdown 3.3 and above.\n\n## Contributing\n\nAll contributions are welcome!\n\n### Installation\n\nTo make changes to this project, first clone this repository:\n\n```shell\ngit clone git@github.com:torchbox/wagtail-markdown.git\ncd wagtail-markdown\n```\n\nWith your preferred Python virtual environment activated, install testing dependencies:\n\n```shell\npip install -e '.[testing]' -U\n```\n\n### pre-commit\n\nNote that this project uses [pre-commit](https://github.com/pre-commit/pre-commit). To set up locally:\n\n```shell\n# if you don't have it yet\n$ pip install pre-commit\n# go to the project directory\n$ cd wagtail-markdown\n# initialize pre-commit\n$ pre-commit install\n\n# Optional, run all checks once for this, then the checks will run only on the changed files\n$ pre-commit run --all-files\n```\n\n### How to run tests\n\nTo run all tests in all environments:\n\n```sh\ntox -p\n```\n\nTo run tests for a specific environment:\n\n```shell\ntox -e py312-django5.0-wagtail6.0\n```\n\nor, a specific test\n\n```shell\ntox -e py312-django5.0-wagtail6.0 -- tests.testapp.tests.test_admin.TestFieldsAdmin\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Markdown support for Wagtail",
    "version": "0.12.1",
    "project_urls": {
        "Changelog": "https://github.com/torchbox/wagtail-markdown/blob/main/CHANGELOG.md",
        "Repository": "https://github.com/torchbox/wagtail-markdown"
    },
    "split_keywords": [
        "wagtail",
        "django",
        "markdown"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d0c1a87dbb0f38aae30ff5e7c38bf0ab1ce7cc7c1d8d1e94a74173d55a3b397",
                "md5": "4c095a76c472761a7cff4fce55f8d9f2",
                "sha256": "bb5f02b6bdfef74b50a74e7aa3f255c7bc9787cec8d03dae50fc9404a0097dba"
            },
            "downloads": -1,
            "filename": "wagtail_markdown-0.12.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4c095a76c472761a7cff4fce55f8d9f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 128401,
            "upload_time": "2024-03-09T15:23:06",
            "upload_time_iso_8601": "2024-03-09T15:23:06.212754Z",
            "url": "https://files.pythonhosted.org/packages/0d/0c/1a87dbb0f38aae30ff5e7c38bf0ab1ce7cc7c1d8d1e94a74173d55a3b397/wagtail_markdown-0.12.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e24bd7b76d1e0c4b29fcd074bd75839232fb2c4aae55d28fb59c0c2edab37e94",
                "md5": "df036fcd8a808aa309114e9ff86e0614",
                "sha256": "54f1ba375348e86e03f4eca7d2ac3d33245ead9f854028d7ee9c479448f1e678"
            },
            "downloads": -1,
            "filename": "wagtail_markdown-0.12.1.tar.gz",
            "has_sig": false,
            "md5_digest": "df036fcd8a808aa309114e9ff86e0614",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 126684,
            "upload_time": "2024-03-09T15:23:08",
            "upload_time_iso_8601": "2024-03-09T15:23:08.134385Z",
            "url": "https://files.pythonhosted.org/packages/e2/4b/d7b76d1e0c4b29fcd074bd75839232fb2c4aae55d28fb59c0c2edab37e94/wagtail_markdown-0.12.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-09 15:23:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "torchbox",
    "github_project": "wagtail-markdown",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "wagtail-markdown"
}
        
Elapsed time: 0.20687s