Fix handling of backslashes in relation to code blocks (#203)
Backslashes are now correctly preserved inside code blocks while still allowing the user to escape a backtick. The handling of backticks and bold/italic wrappers was unified so that they share the same escaping code. Backslashes only escape Markdown wrapper characters (*, _, `). If they are encountered before another character, they are considered literal.
This commit is contained in:
parent
3cf5cc077e
commit
a5e6434c31
2 changed files with 60 additions and 31 deletions
|
|
@ -109,6 +109,16 @@ def test_input_line_markdown_various2():
|
|||
assert "norm** <code>code **code *code</code> norm `norm" \
|
||||
== formatted.to_html()
|
||||
|
||||
def test_input_line_backslash():
|
||||
def convert(s): return Formatted.from_input_line(s).to_html()
|
||||
assert "pre <em>italic* ital</em> norm" == convert("pre *italic\\* ital* norm")
|
||||
assert "*norm* norm" == convert("\\*norm* norm")
|
||||
assert "<em>*ital</em>" == convert("*\\*ital*")
|
||||
assert "<code>C:\\path</code>" == convert("`C:\\path`")
|
||||
assert "<code>with`tick</code>" == convert("`with\\`tick`")
|
||||
assert "`un`matched" == convert("`un\\`matched")
|
||||
assert "<strong>bold </strong><em><strong>*bital</strong></em> norm" == convert("**bold *\\*bital*** norm")
|
||||
|
||||
def test_conversion():
|
||||
formatted = Formatted.from_input_line("*Hello*")
|
||||
formatted2 = Formatted.from_html(formatted.to_html())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue