This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Warning

django-rstify is not in active development! Please take a look at it’s successor django-markup. https://github.com/bartTC/django-markup

django-rstify - A restructured text filter for django templates

django-rstify is a set of template filters to provide easy conversion from restructured text to HTML. Besides this basic functionality this application allows you to highlight sourcecode snippets inside your text using the pygments library.

Hint

Django already provides a simple restructured text filter. If you don’t need the extras in this application, I recommend to use the core version.

Installation

There are several ways to install this application:

  1. Checkout the latest version from my git repository:

    git clone git://github.com/bartTC/django-rstify.git
    
Then either put the directory rstify into your pythonpath or switch to django-rstify and do python setup.py install.
  1. Install this application using easy_install:

    easy_install django-rstify
    

Finally, put rstify into your INSTALLED_APPS setting in your django project.

How to use it in templates

To convert a restructured text from an object to HTML simply apply the rstify filter on it:

{% load rstify_tags %}

{{ entry.content|rstify }}

If you want to convert inline content, use the filter templatetag around:

{% load rstify_tags %}

{% filter rstify %}
This is some *restructured text*.
{% endfilter %}

How to use it in sourcecode

Applying this filter inside your code is easy:

>>> from rstify import rstify
>>>
>>> print rstify('This is *restructured text*.')
<p>This is <em>restructured text</em>.</p>

Initial Header Level

By default the initial heading in your restructured text becomes a <h1> in HTML:

>>> header = '''
... ================
... This is a Header
... ================
... '''
>>> print rstify(header)
<div class="section">
<h1><a id="this-is-a-header" name="this-is-a-header">This is a Header</a></h1>
</div>

You can override this by setting the initial_header_level to an integer from 1 to 6:

>>> print rstify(header, initial_header_level=3)
<div class="section">
<h3><a id="this-is-a-header" name="this-is-a-header">This is a Header</a></h3>
</div>

In your template just set this as the first option of the rstify filter:

{{ entry.content|rstify:"3" }}

Syntax Highlighting

django-rstify provides syntax highlighting using the pygments library. To highlight parts of your restructured text, simply put it in a sourcecode directive:

Here is some text. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Integer porttitor nulla sed dui. Aenean lorem mi, tincidunt et, porttitor
nec, condimentum venenatis, felis. Maecenas ornare blandit leo.

.. sourcecode:: python

    def foo(bar):
        return bar*2

Continue with text. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Integer porttitor nulla sed dui. Aenean lorem mi, tincidunt et, porttitor nec,
condimentum venenatis, felis. Maecenas ornare blandit leo.

Pygments provides a bunch of highlighters (also called lexer), just replace python with a lexer of your choice. Here is a complete set of available lexers. Read pygments styles how to colorize the output using css.

License

This application is licensed under the New BSD License. See LICENSE for details. django-rstify comes bundled with a pygments directive which is released under BSD License. See rstify/pygments_directive.py for details.

Release History

Release History

0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-rstify-0.2.tar.gz (5.2 kB) Copy SHA256 Checksum SHA256 Source Sep 16, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting