Skip to content

Use .md for README, and include relative link to demo template #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions README

This file was deleted.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
django-pygments
===============

django-pygments is a Django app that provides a template tag and 2 filters for doing syntax highlighting with [Pygments](http://pygments.org/).

#### Dependencies:
- pygments

#### Installation:
- Add `django_pygments` to your project directory and to `INSTALLED_APPS` in your `settings.py`
- If you want to see the integrated demo page, add a urls.py entry and copy/link the media files in the proper dir

#### Usage:
- Enclose your code snippet in a pre tag with the non-standard "lang" attribute set to a supported language like this:
`<pre lang="python">....</pre>`
- [See the view and demo](django_pygments/templates/django_pygments/demo.html) template for examples on how to use the `pygmentify` and `pygmentify_inline` filters (the later is rather useful for RSS feeds) or the `pygment` tag
- While using the `pygment` template tag, you can pass keyword arguments that you would pass to Pygments HtmlFormatter class constructor by passing them as with keyword arguments along with the pygment tag. Look at demo template for examples. There is one caveat with this feature still. You can only pass Python values as argument values (like Strings wrapped within quotes or True or False boolean values, etc.). It doesn't support Django template/context variables as arguments yet.

#### Notes:
- The custom HTML formatter class displays each line as an ordered list element, thus implementing line numbering without interfering with copy/pasting
- To see a list of supported languages, look at the `lexer_names` variable in utils.py

The project's site is here: [od-eon.com/labs/django-pygments/](http://od-eon.com/labs/django-pygments/).
For technical support use the github issue tracker or contact us at [email protected]