Update renderer to match Misaka 2.0 API
This commit is contained in:
parent
2ce48325c0
commit
4a97cbae90
@ -33,7 +33,7 @@ class TestHTML(unittest.TestCase):
|
|||||||
self.assertEqual(convert(input), expected)
|
self.assertEqual(convert(input), expected)
|
||||||
|
|
||||||
def test_github_flavoured_markdown(self):
|
def test_github_flavoured_markdown(self):
|
||||||
convert = html.Markdown(extensions=("fenced_code", ))
|
convert = html.Markdown(extensions=("fenced-code", ))
|
||||||
|
|
||||||
# without lang
|
# without lang
|
||||||
_in = textwrap.dedent("""\
|
_in = textwrap.dedent("""\
|
||||||
|
@ -59,11 +59,11 @@ def sanitize(tokenizer, document):
|
|||||||
return serializer.render(stream)
|
return serializer.render(stream)
|
||||||
|
|
||||||
|
|
||||||
def Markdown(extensions=("strikethrough", "superscript", "autolink")):
|
def Markdown(extensions=("strikethrough", "superscript", "autolink",
|
||||||
|
"fenced-code")):
|
||||||
|
|
||||||
flags = reduce(operator.xor, map(
|
renderer = Unofficial()
|
||||||
lambda ext: getattr(misaka, 'EXT_' + ext.upper()), extensions), 0)
|
md = misaka.Markdown(renderer, extensions=extensions)
|
||||||
md = misaka.Markdown(Unofficial(), extensions=flags)
|
|
||||||
|
|
||||||
def inner(text):
|
def inner(text):
|
||||||
rv = md(text).rstrip("\n")
|
rv = md(text).rstrip("\n")
|
||||||
@ -82,7 +82,7 @@ class Unofficial(misaka.HtmlRenderer):
|
|||||||
to <code class="$lang">, compatible with Highlight.js.
|
to <code class="$lang">, compatible with Highlight.js.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def block_code(self, text, lang):
|
def blockcode(self, text, lang):
|
||||||
lang = ' class="{0}"'.format(lang) if lang else ''
|
lang = ' class="{0}"'.format(lang) if lang else ''
|
||||||
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
|
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user