Skip to main content

Markdown for RichText content in Mezzanine.

Project description

This package provides widgets and filters for mezzanine that enable admins to use markdown formatting to create their site content, rather than using the tinymce editor to generate html used in rich content types, such as rich pages and blog posts.

Installation

Get the package

pip:

user@home:~$ pip install mezzanine-mdown

easy_install:

user@home:~$ easy_install mezzanine-mdown

Prep the static media

Using the excellent staticfiles app, mdown’s static files should get picked up automatically.

If the staticfiles app is not your style, you’ll need to locate the install location for the mdown package (usually your python interpreter’s site-packages directory) and copy/symlink mdown/static/mdown into your project site_media directory.

Configuration

First off, add mdown to your list of INSTALLED_APPS in your project settings module.

With the app installed, you need to make a couple choices. You’ll have to specify the RICHTEXT_WIDGET_CLASS and RICHTEXT_FILTER values in your settings module.

RICHTEXT_WIDGET_CLASS

This package provides 2 options for this setting.

mdown.forms.WmdWidget

Activates the WMD rich text editor. (recommended)

mdown.forms.PlainWidget

Use a plain Textarea (no rich text editor).

RICHTEXT_FILTER

Again, there are 2 options for this setting.

mdown.filters.codehilite

Renders the content using markdown with the codehilite extension enabled.

mdown.filters.plain

Renders the content using vanilla markdown formatting.

Extra Steps

Pygments Styles

Using the management command pygments_styles you can generate css to colorize code blocks parsed by the codehilite filter.

Note: this requires pygments to be installed (use pip install pygments or easy_install pygments to use this feature).

Invoke the command with no args to see a usage message and list of available color schemes on your system.:

user@home:~/mysite$ ./manage.py pygments_styles
Usage: ./manage.py pygments_styles <scheme_name>
Available color schemes:
  borland
  bw
  colorful
  default
  ... [ snip ] ...

Invoking with the scheme’s name as an argument will print the css to stdout, which you can redirect to a file like so:

user@home:~/mysite$ ./manage.py pygment_styles colorful > site_media/css/pygments.css

In additon to this single scheme method, the command also accepts the --all flag, which will generate styles for all available, but with one key difference: each scheme is prefixed with its name as a css class name. This is handy during theme development as you can quickly switch pygments schemes just by setting the class on the body tag to your choice of scheme without having to regenerate css files constantly.

Once you’ve got a css file generated, simply add it to your site’s base template to get your code “pretty” printed.

Updating Theme Templates

Themes that were based on the default theme and were created prior to Mezzanine’s 0.11.3 release will most likely not have the richtext_filter applied to rich content. To correct this, you simply have to update the templates for these content types so that the filter is used.

For example, in the default theme, the templates/blog/blog_post_detail.html had a line that was updated from:

{{ blog_post.content|safe }}

to:

{{ blog_post.content|richtext_filter|safe }}

Just ensure that the safe filter comes after the richtext_filter.

Project details


Download files

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

Source Distribution

mezzanine-mdown-0.1a3.tar.gz (58.7 kB view details)

Uploaded Source

File details

Details for the file mezzanine-mdown-0.1a3.tar.gz.

File metadata

File hashes

Hashes for mezzanine-mdown-0.1a3.tar.gz
Algorithm Hash digest
SHA256 1daf0bd8173ca9cd444777769a08fe0894543c05f507747b2828b6e0254dee48
MD5 71e92b52a78c8d360f8640b92eb73779
BLAKE2b-256 ba0c491485819ac9a5fd4d77d9e2f6d9b4cf2e9a5f3fbd466c0ce2a1a4a7f337

See more details on using hashes here.

Supported by

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