Commit e15d5c81 authored by Frédéric Mangano-Tarumi's avatar Frédéric Mangano-Tarumi Committed by Lukas Fleischer
Browse files

rendercomment: use python-markdown's new registration API

First, this gets rid of the deprecation warnings Python displayed.

Second, this fixes the case where a link contained a pair of
underscores, which used to be interpreted as an emphasis because the
linkify processor ran after the emphasis processor.

Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <>
parent 81faab99
......@@ -26,7 +26,8 @@ class LinkifyExtension(markdown.extensions.Extension):
def extendMarkdown(self, md, md_globals):
processor = markdown.inlinepatterns.AutolinkInlineProcessor(self._urlre, md)
md.inlinePatterns.add('linkify', processor, '_end')
# Register it right after the default <>-link processor (priority 120).
md.inlinePatterns.register(processor, 'linkify', 119)
class FlysprayLinksInlineProcessor(markdown.inlinepatterns.InlineProcessor):
......@@ -47,7 +48,7 @@ class FlysprayLinksInlineProcessor(markdown.inlinepatterns.InlineProcessor):
class FlysprayLinksExtension(markdown.extensions.Extension):
def extendMarkdown(self, md, md_globals):
processor = FlysprayLinksInlineProcessor(r'\bFS#(\d+)\b',md)
md.inlinePatterns.add('flyspray-links', processor, '_end')
md.inlinePatterns.register(processor, 'flyspray-links', 118)
class GitCommitsInlineProcessor(markdown.inlinepatterns.InlineProcessor):
......@@ -92,7 +93,7 @@ class GitCommitsExtension(markdown.extensions.Extension):
def extendMarkdown(self, md, md_globals):
processor = GitCommitsInlineProcessor(md, self._head)
md.inlinePatterns.add('git-commits', processor, '_end')
md.inlinePatterns.register(processor, 'git-commits', 117)
class HeadingTreeprocessor(markdown.treeprocessors.Treeprocessor):
......@@ -106,7 +107,8 @@ class HeadingTreeprocessor(markdown.treeprocessors.Treeprocessor):
class HeadingExtension(markdown.extensions.Extension):
def extendMarkdown(self, md, md_globals):
md.treeprocessors.add('heading', HeadingTreeprocessor(md), '_end')
# Priority doesn't matter since we don't conflict with other processors.
md.treeprocessors.register(HeadingTreeprocessor(md), 'heading', 30)
def get_comment(conn, commentid):
......@@ -52,7 +52,8 @@ test_expect_success 'Test HTML sanitizing.' '
test_expect_success 'Test link conversion.' '
cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (4, 1, "
Visit **.
Visit <>.
Visit \`\`.
Visit [Arch Linux](
......@@ -62,7 +63,8 @@ test_expect_success 'Test link conversion.' '
cat <<-EOD >expected &&
<p>Visit <a href=""></a>.
<p>Visit <a href=""></a>.
Visit <em><a href=""></a></em>.
Visit <a href=""></a>.
Visit <code></code>.
Visit <a href="">Arch Linux</a>.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment