rolandshoemaker/CommonMark-py — pull request #9 by eigenein (2014-10-16 20:41:13+00:00)
Title: Add support for syntax highlighting

In my opinion it is useful to be able to integrate syntax highlighting for code blocks. This commit will allow to use `CommonMark.HTMLRenderer` in a way like:

```python
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name, guess_lexer

def highlight_syntax(block_type, code, info_words):
if info_words:
lexer = get_lexer_by_name(info_words[0])
else:
lexer = guess_lexer(code)
return highlight(code, lexer, HtmlFormatter(nowrap=True))

print(CommonMark.HTMLRenderer(highlight_syntax).render(ast))
```