Skip to content
Snippets Groups Projects
Commit 3f312244 authored by Richard Berger's avatar Richard Berger Committed by Axel Kohlmeyer
Browse files

Escape RST special character '*' in final output

(cherry picked from commit 7cb39811d47b1f364286597acea21c3afd010733)
parent 55022d12
No related branches found
No related tags found
No related merge requests found
......@@ -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"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment