Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add textile and markdown2 renderers.

Closes #76.
  • Loading branch information...
commit 78d59fd1802867ff614ee9678092786cbcf309ad 1 parent 1f51fd4
@mythmon authored
Showing with 61 additions and 12 deletions.
  1. +9 −6 docs/content/docs/content.mkd
  2. +52 −6 wok/renderers.py
View
15 docs/content/docs/content.mkd
@@ -1,12 +1,9 @@
title: Content
category: docs
---
-Content can be written in various markup languages (currently [Markdown][mkd] or [reStructuredText][rst]), with a
-[YAML][yaml] header, separated by 3 hyphens alone on a line. For example:
-
-[mkd]: http://daringfireball.net/projects/markdown/
-[rst]: http://docutils.sourceforge.net/rst.html
-[yaml]: http://www.yaml.org/
+Content can be written in various markup languages (currently [Markdown][mkd],
+[reStructuredText][rst], and [Textile][]), with a [YAML][yaml] header, separated by 3 hyphens
+alone on a line. For example:
::text
title: Sample Post
@@ -20,6 +17,12 @@ Content can be written in various markup languages (currently [Markdown][mkd] or
ligula porta vestibulum et ut sem. Cras hendrerit pulvinar metus at
imperdiet.
+[mkd]: http://daringfireball.net/projects/markdown/
+[rst]: http://docutils.sourceforge.net/rst.html
+[textile]: http://textile.sitemonks.com/
+[yaml]: http://www.yaml.org/
+
+
Metadata
--------
These are the variables that affect the rending, layout, and categorization of pages in the YAML metadata.
View
58 wok/renderers.py
@@ -32,10 +32,15 @@ def render(cls, plain):
# Include markdown, if it is available.
try:
- from markdown import markdown
+ # Try to get the faster cMarkdown
+ try:
+ from cMarkdown import markdown
+ except ImportError:
+ from markdown import markdown
+
class Markdown(Renderer):
"""Markdown renderer."""
- extensions = ['markdown', 'mkd']
+ extensions = ['markdown', 'mkd', 'md']
plugins = ['def_list', 'footnotes']
if have_pygments:
@@ -48,7 +53,29 @@ def render(cls, plain):
all.append(Markdown)
except ImportError:
- logging.info('Markdown not enabled.')
+ logging.debug("markdown isn't available, trying markdown2")
+ markdown = None
+
+# Try Markdown2
+if markdown is None:
+ try:
+ import markdown2
+ class Markdown(Renderer):
+ """Markdown2 renderer."""
+ extensions = ['markdown', 'mkd', 'md']
+
+ extras = ['def_list', 'footnotes']
+ if have_pygments:
+ extras.append('fenced-code-blocks')
+
+ @classmethod
+ def render(cls, plain):
+ return markdown2.markdown(plain, extras=extras)
+
+ all.append(Markdown2)
+ except:
+ logging.info('Markdown not enabled.')
+
# Include ReStructuredText Parser, if we have docutils
try:
@@ -74,7 +101,26 @@ def render(cls, plain):
except:
logging.info('reStructuredText not enabled.')
+
+# Try Textile
+try:
+ import textile
+ class Textile(Renderer):
+ """Textile renderer."""
+ extensions = ['textile']
+
+ @classmethod
+ def render(cls, plain):
+ return textile.textile(plain)
+
+ all.append(Markdown2)
+except:
+ logging.info('Markdown not enabled.')
+
+
+
if len(all) <= 2:
- print('You probably want to install either Markdown or docutils '
- '(reStructuredText). Otherwise only plain text input will be '
- 'supported.')
+ print("You probably want to install either a Markdown library (one of "
+ "'Markdown', or 'markdown2'), 'docutils' (for reStructuredText), or "
+ "'textile'. Otherwise only plain text input will be supported. You "
+ "can install any of these like 'sudo pip install PACKAGE'.")
Please sign in to comment.
Something went wrong with that request. Please try again.