Skip to content

Instantly share code, notes, and snippets.

@pistatium
Created January 7, 2014 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pistatium/8299577 to your computer and use it in GitHub Desktop.
Save pistatium/8299577 to your computer and use it in GitHub Desktop.
import markdown
md = markdown.Markdown()
sample_makedown = '''
An h1 header
============
Paragraphs are separated by a blank line.
2nd paragraph. *Italic*, **bold**, `monospace`. Itemized lists
look like:
* this one
* that one
* the other one
'''
# makedown -> html
print md.convert(sample_makedown)
import markdown
#キャッシュするためここで宣言、初期化しとく
md = markdown.Markdown()
@register.filter
@stringfilter
def mark2html(value):
return md.convert(value)
{% load myfilter %}
{{ markdown_text|mark2html }}
<h1>An h1 header</h1>
<p>Paragraphs are separated by a blank line.</p>
<p>2nd paragraph. <em>Italic</em>, <strong>bold</strong>, <code>monospace</code>. Itemized lists
look like:</p>
<ul>
<li>this one</li>
<li>that one</li>
<li>the other one</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment