Skip to content

link-patterns extra shouldn't apply <url> and label of [label][url] #385

@jun66j5

Description

@jun66j5

link-patterns extra shouldn't apply <url> and label of [label][url].

>>> import sys, re, markdown2
>>> sys.version
'2.7.5 (default, Nov 16 2020, 22:23:17) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]'
>>> markdown2.__version__
'2.3.10'
>>> patterns = [
...     (re.compile(r'#([1-9][0-9]*)'), r'http://localhost/issue/\1'),
... ]
>>> m = markdown2.Markdown(extras=['link-patterns'], link_patterns=patterns)
>>> print(m.convert("""\
... Issue #42
...
... <http://localhost/#42>
...
... [Issue #42](http://localhost/)
... """))
<p>Issue <a href="http://localhost/issue/42">#42</a></p>

<p><http://localhost/<a href="http://localhost/issue/42">#42</a>&gt;</p>

<p><a href="http://localhost/">Issue <a href="http://localhost/issue/42">#42</a></a></p>

<http://localhost/#42> should be rendered even with link-patterns:

<a href="http://localhost/#42">http://localhost/#42</a>

[Issue #42](http://localhost/) should be rendered even with link-patterns:

<p><a href="http://localhost/">Issue #42</a></p>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions