forked from devs/PCv5
markdown: add ins (underline) and del (strikethrough) tags
This commit is contained in:
parent
c31cca6314
commit
6519cf4a6a
|
@ -1,7 +1,7 @@
|
|||
# Tags suitable for rendering markdown
|
||||
markdown_tags = [
|
||||
"h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"b", "i", "strong", "em", "tt",
|
||||
"b", "i", "strong", "em", "tt", "ins", "del",
|
||||
"p", "br",
|
||||
"span", "div", "blockquote", "code", "pre", "hr",
|
||||
"ul", "ol", "li", "dd", "dt",
|
||||
|
|
|
@ -7,6 +7,7 @@ from markdown.extensions.toc import TocExtension, slugify_unicode
|
|||
from bleach import clean
|
||||
from app.utils.bleach_allowlist import markdown_tags, markdown_attrs
|
||||
|
||||
from app.utils.markdown_extensions.del_ins import DelInsExtension
|
||||
from app.utils.markdown_extensions.pclinks import PCLinkExtension
|
||||
from app.utils.markdown_extensions.hardbreaks import HardBreakExtension
|
||||
from app.utils.markdown_extensions.escape_html import EscapeHtmlExtension
|
||||
|
@ -34,6 +35,7 @@ def md(text, prefix=None):
|
|||
# 'nl2br',
|
||||
'sane_lists',
|
||||
'tables',
|
||||
DelInsExtension(),
|
||||
CodeHiliteExtension(linenums=True, use_pygments=True),
|
||||
EscapeHtmlExtension(),
|
||||
FootnoteExtension(UNIQUE_IDS=True),
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from markdown.extensions import Extension
|
||||
from markdown.inlinepatterns import SimpleTagPattern
|
||||
|
||||
|
||||
class DelInsExtension(Extension):
|
||||
def extendMarkdown(self, md):
|
||||
DEL_RE = r'(~~)(.*?)~~'
|
||||
del_tag = SimpleTagPattern(DEL_RE, 'del')
|
||||
md.inlinePatterns.register(del_tag, 'del', 55)
|
||||
INS_RE = r'(__)(.*?)__'
|
||||
ins_tag = SimpleTagPattern(INS_RE, 'ins')
|
||||
md.inlinePatterns.register(ins_tag, 'ins', 55)
|
Loading…
Reference in New Issue