do not construct Markdown links in code spans and code blocks
Signed-off-by: chrispy <chrispy@synopsys.com>
This commit is contained in:
@@ -264,6 +264,8 @@ class MarkdownConverter(object):
|
|||||||
return '\n\n%s\n%s\n\n' % (text, pad_char * len(text)) if text else ''
|
return '\n\n%s\n%s\n\n' % (text, pad_char * len(text)) if text else ''
|
||||||
|
|
||||||
def convert_a(self, el, text, convert_as_inline):
|
def convert_a(self, el, text, convert_as_inline):
|
||||||
|
if el.find_parent(['pre', 'code', 'kbd', 'samp']):
|
||||||
|
return text
|
||||||
prefix, suffix, text = chomp(text)
|
prefix, suffix, text = chomp(text)
|
||||||
if not text:
|
if not text:
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ def test_a_no_autolinks():
|
|||||||
assert md('<a href="https://google.com">https://google.com</a>', autolinks=False) == '[https://google.com](https://google.com)'
|
assert md('<a href="https://google.com">https://google.com</a>', autolinks=False) == '[https://google.com](https://google.com)'
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_in_code():
|
||||||
|
assert md('<code><a href="https://google.com">Google</a></code>') == '`Google`'
|
||||||
|
assert md('<pre><a href="https://google.com">Google</a></pre>') == '\n```\nGoogle\n```\n'
|
||||||
|
|
||||||
|
|
||||||
def test_b():
|
def test_b():
|
||||||
assert md('<b>Hello</b>') == '**Hello**'
|
assert md('<b>Hello</b>') == '**Hello**'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user