Skip to main content

PyPI version

Markdown XBlock

Based on the HTML XBlock by OpenCraft

Introduction

This XBlock allows course authors to create and edit course content in Markdown and displays it as HTML.

Installation with Tutor

You may install the markdown-xblock to your Tutor environment by adding it to the OPENEDX_EXTRA_PIP_REQUIREMENTS list in config.yml:

OPENEDX_EXTRA_PIP_REQUIREMENTS:
- markdown-xblock==2.4.0

Or, if you prefer to install directly from Git:

OPENEDX_EXTRA_PIP_REQUIREMENTS:
- git+https://github.com/cleura/markdown-xblock.git@v2.4.0

For additional information, please refer to the official documentation.

The minimum supported Python version is 3.8.

To enable this block, add "markdown" to the course's advanced module list. The option Markdown will appear in the advanced components.

Once you've added a new Markdown component to your course, you can also add custom CSS classes to the component by selecting EDIT/Settings and adding to the classes list (Note: use double quotes " "). Example:

["custom-css-class-1", "custom-css-class-2"]

The Markdown block uses markdown2 to translate the content into HTML, by default the following extras are included:

  • "code-friendly"
  • "fenced-code-blocks"
  • "footnotes"
  • "tables"
  • "use-file-vars"

Configuration

It is possible to configure more extras, by adding to the extras list under "markdown" key in XBLOCK_SETTINGS in your Tutor plugin that patches openedx-common-settings

By default, the safe_mode for markdown2 library is enabled and set to replace, which means that writing inline HTML is not allowed and if written, all tags will be replaced with [HTML_REMOVED]. You can also set safe_mode to escape, which only replaces <, > and & with &lt;, &gt; and &amp;. To disable safe mode altogether and allow inline HTML, you'll need to set safe_mode to False or None in XBLOCK_SETTINGS. Please note that setting safe_mode to the empty string ('') also disables safe mode.

Example (YAML plugin):

name: markdown
version: 1.0.0
patches:
  openedx-common-settings: |
    XBLOCK_SETTINGS["markdown"] = {
        "extras": [
            "code-friendly",
            "fenced-code-blocks",
            "footnotes",
            "tables",
            "header-ids",
            "metadata",
            "pyshell",
            "smarty-pants",
            "strike",
            "target-blank-links",
            "use-file-vars",
            "wiki-tables",
            "tag-friendly"
        ],
        "safe_mode": "escape"
    }

Usage notes

Images

To include images in your markdown content, use the standard Markdown inline image syntax. Your course images will normally live in the static/images directory, relative to the root of your course, so you would include an image like this:

![alt text for example image](/static/images/example.png)

The XBlock will then mangle your image reference into a static asset reference.

If Markdown XBlock content contains links to another course, and your platform is configured with the XBlock's safe mode enabled, a link like

[link text](https://example.com/courses/course-v1:Org+Class+Version/about)

will, when rendered, turn its + characters into whitespace. That isn't actually wrong, because both + and the %20 escape sequence in URLs are meant to represent whitespace, yet Open edX uses the + character to mean something other than whitespace, and that's a bit of a problem.

To preserve Open edX course URL references, please explicitly encode the + character as %2B, like so:

[link text](https://example.com/courses/course-v1:Org%2BClass%2BVersion/about)

Development

If you'd like to develop on this repo in Tutor, follow the steps described in the documentation.

Running tests

The testing framework is built on tox. After installing tox, you can run tox from your Git checkout of this repository.

To throw away and rebuild the testing environment, run:

$ tox -r

For running PEP-8 checks only:

$ tox -e flake8

Metadata

Release files for markdown-xblock 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-xblock 2.4.0
File Size Uploaded Provenance
markdown_xblock-2.4.0.tar.gz 610.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for markdown-xblock 2.4.0
File Interpreter ABI Platform
markdown_xblock-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / markdown_xblock-2.4.0.tar.gz

Download URL markdown_xblock-2.4.0.tar.gz
Size 610.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7e6146bfbfd71e6419b87524ba12d96b2269fcfd5c6d244ba4c08e007f943199
BLAKE2b-256 checksum
How to use checksums
7cd519a3419ef5d7c81bfee7ac8643238b38fac40a56688ddf8ab807f13015af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Release files / markdown_xblock-2.4.0-py3-none-any.whl

Download URL markdown_xblock-2.4.0-py3-none-any.whl
Size 627.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c3b43452052b1241a14b00c193ae5092dcf9faba6fb5e10bdb675f517167f9e
BLAKE2b-256 checksum
How to use checksums
c17129eaaa57978e851a34b180d1c87774775454c326825293996f18dbe8e8b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Security for markdown-xblock 2.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for markdown_xblock-2.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page