Commit ce7e3855 authored by gaojiuli's avatar gaojiuli

Add <strong> support

parent 8981046f
from tomd import Tomd
import tomd import tomd
from tomd import Tomd
string = """ string = """
<h1>h1</h1> <h1>h1</h1>
<h2>h2</h2> <h2>h2</h2>
...@@ -29,6 +30,8 @@ string = """ ...@@ -29,6 +30,8 @@ string = """
<b>bold</b> <b>bold</b>
<i>italic</i> <i>italic</i>
<b><i>bold italic</i></b> <b><i>bold italic</i></b>
<em>em</em>
<strong>strong</strong>
</p> </p>
<hr/> <hr/>
...@@ -49,6 +52,7 @@ string = """ ...@@ -49,6 +52,7 @@ string = """
<td>td</td> <td>td</td>
<td>td</td> <td>td</td>
</tr></tbody></table> </tr></tbody></table>
""" """
print(Tomd(string).markdown) print(Tomd(string).markdown)
......
...@@ -15,6 +15,7 @@ MARKDOWN = { ...@@ -15,6 +15,7 @@ MARKDOWN = {
'li': ('- ', ''), 'li': ('- ', ''),
'blockquote': ('\n> ', '\n'), 'blockquote': ('\n> ', '\n'),
'em': ('**', '**'), 'em': ('**', '**'),
'strong': ('**', '**'),
'block_code': ('\n```\n', '\n```\n'), 'block_code': ('\n```\n', '\n```\n'),
'span': ('', ''), 'span': ('', ''),
'p': ('\n', '\n'), 'p': ('\n', '\n'),
...@@ -66,7 +67,8 @@ INLINE_ELEMENTS = { ...@@ -66,7 +67,8 @@ INLINE_ELEMENTS = {
'li': '<li.*?>(.*?)</li>', 'li': '<li.*?>(.*?)</li>',
'img': '<img.*?src="(.*?)".*?>(.*?)</img>', 'img': '<img.*?src="(.*?)".*?>(.*?)</img>',
'a': '<a.*?href="(.*?)".*?>(.*?)</a>', 'a': '<a.*?href="(.*?)".*?>(.*?)</a>',
'em': '<em.*?>(.*?)</em>' 'em': '<em.*?>(.*?)</em>',
'strong': '<strong.*?>(.*?)</strong>'
} }
DELETE_ELEMENTS = ['<span.*?>', '</span>', '<div.*?>', '</div>'] DELETE_ELEMENTS = ['<span.*?>', '</span>', '<div.*?>', '</div>']
......
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