html: Add markdown render flag option (#616)
New "flags" option in the [markdown] section to customize Misaka's Markdown HTML rendering. By default, no flags are set. ``` [markup] flags = skip-html, escape, hard-wrap ``` Update CHANGES.rst and add the section to the sample isso.conf and isso-dev.conf
This commit is contained in:
parent
2a4e8c231e
commit
86b65f817e
@ -4,6 +4,14 @@ Changelog for Isso
|
||||
0.12.3 (UNRELEASED)
|
||||
-------------------
|
||||
|
||||
- New "flags" option in the [markdown] section to customize Misaka's Markdown
|
||||
HTML rendering. By default, no flags are set.
|
||||
|
||||
[markup]
|
||||
flags = skip-html, escape, hard-wrap
|
||||
|
||||
Check docs/configuration/server.rst for more details.
|
||||
|
||||
0.12.2 (2019-01-21)
|
||||
-------------------
|
||||
|
||||
|
@ -298,12 +298,20 @@ supported, but new languages are relatively easy to add.
|
||||
|
||||
[markup]
|
||||
options = strikethrough, superscript, autolink
|
||||
flags = skip-html, escape, hard-wrap
|
||||
allowed-elements =
|
||||
allowed-attributes =
|
||||
|
||||
options
|
||||
`Misaka-specific Markdown extensions <http://misaka.61924.nl/#api>`_, all
|
||||
flags starting with `EXT_` can be used there, separated by comma.
|
||||
`Misaka-specific Markdown extensions <https://misaka.61924.nl/#api>`_, all
|
||||
extension flags can be used there, separated by comma, either by their name
|
||||
or as `EXT_`_.
|
||||
|
||||
flags
|
||||
`Misaka-specific HTML rendering flags
|
||||
<https://misaka.61924.nl/#html-render-flags>`_, all html rendering flags
|
||||
can be used here, separated by comma, either by their name or as `HTML_`_.
|
||||
Per Misaka's defaults, no flags are set.
|
||||
|
||||
allowed-elements
|
||||
Additional HTML tags to allow in the generated output, comma-separated. By
|
||||
|
@ -89,6 +89,7 @@ class TestHTML(unittest.TestCase):
|
||||
conf = config.new({
|
||||
"markup": {
|
||||
"options": "autolink",
|
||||
"flags": "",
|
||||
"allowed-elements": "",
|
||||
"allowed-attributes": ""
|
||||
}
|
||||
|
@ -5,6 +5,11 @@ from __future__ import unicode_literals
|
||||
import bleach
|
||||
import misaka
|
||||
|
||||
try:
|
||||
from backports.configparser import NoOptionError
|
||||
except ImportError:
|
||||
from configparser import NoOptionError
|
||||
|
||||
|
||||
class Sanitizer(object):
|
||||
|
||||
@ -49,9 +54,9 @@ class Sanitizer(object):
|
||||
|
||||
|
||||
def Markdown(extensions=("strikethrough", "superscript", "autolink",
|
||||
"fenced-code")):
|
||||
"fenced-code"), flags=[]):
|
||||
|
||||
renderer = Unofficial()
|
||||
renderer = Unofficial(flags=flags)
|
||||
md = misaka.Markdown(renderer, extensions=extensions)
|
||||
|
||||
def inner(text):
|
||||
@ -80,7 +85,11 @@ class Markup(object):
|
||||
|
||||
def __init__(self, conf):
|
||||
|
||||
parser = Markdown(conf.getlist("options"))
|
||||
try:
|
||||
conf_flags = conf.getlist("flags")
|
||||
except NoOptionError:
|
||||
conf_flags = []
|
||||
parser = Markdown(extensions=conf.getlist("options"), flags=conf_flags)
|
||||
sanitizer = Sanitizer(
|
||||
conf.getlist("allowed-elements"),
|
||||
conf.getlist("allowed-attributes"))
|
||||
|
@ -28,6 +28,7 @@ enabled = false
|
||||
|
||||
[markup]
|
||||
options = strikethrough, autolink, fenced_code, no_intra_emphasis
|
||||
flags =
|
||||
allowed-elements =
|
||||
allowed-attributes =
|
||||
|
||||
|
@ -185,6 +185,11 @@ require-email = false
|
||||
# there, separated by comma.
|
||||
options = strikethrough, autolink, fenced_code, no_intra_emphasis
|
||||
|
||||
# Misaka-specific HTML rendering flags, all html rendering flags can be used
|
||||
# here, separated by comma, either by their name or as HTML_<flag>.
|
||||
# Per Misaka's defaults, no flags are set.
|
||||
flags =
|
||||
|
||||
# Additional HTML tags to allow in the generated output, comma-separated. By
|
||||
# default, only a, blockquote, br, code, del, em, h1, h2, h3, h4, h5, h6, hr,
|
||||
# ins, li, ol, p, pre, strong, table, tbody, td, th, thead and ul are allowed.
|
||||
|
Loading…
Reference in New Issue
Block a user