Commit 476e938a authored by zsinx6's avatar zsinx6

fixed strong with spaces after or before

parent f030dcfd
...@@ -34,6 +34,7 @@ string = """ ...@@ -34,6 +34,7 @@ string = """
<b><i>bold italic</i></b> <b><i>bold italic</i></b>
<em>em</em> <em>em</em>
<strong>strong</strong> <strong>strong</strong>
<strong> strong </strong>
</p> </p>
<hr/> <hr/>
......
...@@ -75,7 +75,7 @@ INLINE_ELEMENTS = { ...@@ -75,7 +75,7 @@ INLINE_ELEMENTS = {
'img_single_no_close': '<img.*?src="(.*?)".*?>', 'img_single_no_close': '<img.*?src="(.*?)".*?>',
'a': '<a.*?href="(.*?)".*?>(.*?)</a>', 'a': '<a.*?href="(.*?)".*?>(.*?)</a>',
'em': '<em.*?>(.*?)</em>', 'em': '<em.*?>(.*?)</em>',
'strong': '<strong.*?>(.*?)</strong>', 'strong': '<strong.*?>(\s*)(.*?)(\s*)</strong>',
'tbody': '<tbody.*?>((.|\n)*)</tbody>', 'tbody': '<tbody.*?>((.|\n)*)</tbody>',
} }
...@@ -166,7 +166,10 @@ class Element: ...@@ -166,7 +166,10 @@ class Element:
self.construct_table() self.construct_table()
else: else:
wrapper = MARKDOWN.get(tag) wrapper = MARKDOWN.get(tag)
self.content = re.sub(pattern, '{}\g<1>{}'.format(wrapper[0], wrapper[1]), self.content) if tag == "strong":
self.content = re.sub(pattern, '{}\g<2>{}'.format(wrapper[0], wrapper[1]), self.content)
else:
self.content = re.sub(pattern, '{}\g<1>{}'.format(wrapper[0], wrapper[1]), self.content)
if self.tag == "e_p" and self.content[-1:] != '\n' and len(self.content) > 2: if self.tag == "e_p" and self.content[-1:] != '\n' and len(self.content) > 2:
# focusing on div, add new line if not there (and if content is long enough) # focusing on div, add new line if not there (and if content is long enough)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment