Skip to content

Commit

Permalink
Merge branch 'markdown-builtin-exts' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tankywoo committed Jun 2, 2017
2 parents a530883 + 01db484 commit 7ef2bf2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
24 changes: 11 additions & 13 deletions simiki/generators.py
Expand Up @@ -244,10 +244,18 @@ def _parse_markup(self, markup_text):

def _set_markdown_extensions(self):
"""Set the extensions for markdown parser"""
# Base markdown extensions support "fenced_code".
markdown_extensions_config = {"fenced_code": {}}
# Default enabled extensions
markdown_extensions_config = {
"fenced_code": {},
"nl2br": {},
"toc": {"title": "Table of Contents"},
"extra": {},
}
# Handle pygments
markdown_extensions_config.update(self._set_pygments())
if self.site_config["pygments"]:
markdown_extensions_config.update({
"codehilite": {"css_class": "hlcode"}
})
# Handle markdown_ext
# Ref: https://pythonhosted.org/Markdown/extensions/index.html#officially-supported-extensions # noqa
if "markdown_ext" in self.site_config:
Expand All @@ -263,16 +271,6 @@ def _set_markdown_extensions(self):

return markdown_extensions

def _set_pygments(self):
"""Set the pygments settings for markdown parser"""
if self.site_config["pygments"]:
return {
"extra": {},
"codehilite": {"css_class": "hlcode"},
"toc": {"title": "Table of Contents"}
}
return {}

def get_relation(self):
rn = []
if self._tags and 'tag' in self.meta:
Expand Down
Expand Up @@ -8,3 +8,5 @@ date: 2013-10-17 00:03

Simiki is a simple wiki framework, written in Python.

Line 1
Line 2
2 changes: 2 additions & 0 deletions tests/mywiki_for_generator/expected_output.html
Expand Up @@ -24,6 +24,8 @@

<p><a class="wikilink" href="/simiki/">simiki</a></p>
<p>Simiki is a simple wiki framework, written in Python.</p>
<p>Line 1<br />
Line 2</p>
</div>
<div id="footer">
<span>
Expand Down
6 changes: 4 additions & 2 deletions tests/test_generators.py
Expand Up @@ -62,7 +62,8 @@ def test_get_meta_and_content(self):
self.assertEqual(meta, expected_meta)
self.assertEqual(content, '<p>[[simiki]]</p>\n'
'<p>Simiki is a simple wiki '
'framework, written in Python.</p>')
'framework, written in Python.</p>'
'\n<p>Line 1<br />\nLine 2</p>')

# get meta notaion error
src_file = os.path.join(self.wiki_path, 'content', 'foo目录',
Expand All @@ -86,7 +87,8 @@ def test_get_template_vars(self):
u'category': u'foo\u76ee\u5f55',
u'content': u'<p>[[simiki]]</p>\n'
'<p>Simiki is a simple wiki '
'framework, written in Python.</p>',
'framework, written in Python.</p>'
'\n<p>Line 1<br />\nLine 2</p>',
u'filename': u'foo_page_\u4e2d\u6587.html',
u'date': '2013-10-17 00:03',
u'layout': 'page',
Expand Down

0 comments on commit 7ef2bf2

Please sign in to comment.