Escape RST special character '*' in final output
(cherry picked from commit 7cb39811d4)
This commit is contained in:
committed by
Axel Kohlmeyer
parent
55022d1263
commit
3f312244a0
@ -57,10 +57,15 @@ class RSTMarkup(Markup):
|
||||
return text
|
||||
|
||||
def convert(self, text):
|
||||
text = self.escape_rst_chars(text)
|
||||
text = super().convert(text)
|
||||
text = self.inline_math(text)
|
||||
return text
|
||||
|
||||
def escape_rst_chars(self, text):
|
||||
text = text.replace('*', '\\*')
|
||||
return text
|
||||
|
||||
def inline_math(self, text):
|
||||
start_pos = text.find("\\(")
|
||||
end_pos = text.find("\\)")
|
||||
|
||||
@ -77,6 +77,10 @@ class TestMarkup(unittest.TestCase):
|
||||
self.assertEqual("**bold** = [bold]\n"
|
||||
"*italic* = {italic}\n", s)
|
||||
|
||||
def test_escape_rst_characters(self):
|
||||
s = self.markup.convert("[*bold] and {italic*}")
|
||||
self.assertEqual("**\*bold** and *italic\**", s)
|
||||
|
||||
def test_paragraph_with_italic(self):
|
||||
self.assertEqual("A sentence with a *italic* word", self.markup.convert("A sentence with a {italic} word"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user