diff --git a/CHANGES.rst b/CHANGES.rst index 6699198..636b921 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ------------------- diff --git a/docs/docs/configuration/server.rst b/docs/docs/configuration/server.rst index 4ae46c3..5013013 100644 --- a/docs/docs/configuration/server.rst +++ b/docs/docs/configuration/server.rst @@ -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 `_, all - flags starting with `EXT_` can be used there, separated by comma. + `Misaka-specific Markdown extensions `_, all + extension flags can be used there, separated by comma, either by their name + or as `EXT_`_. + +flags + `Misaka-specific HTML rendering 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 diff --git a/isso/tests/test_html.py b/isso/tests/test_html.py index 6eb037b..f7f497c 100644 --- a/isso/tests/test_html.py +++ b/isso/tests/test_html.py @@ -89,6 +89,7 @@ class TestHTML(unittest.TestCase): conf = config.new({ "markup": { "options": "autolink", + "flags": "", "allowed-elements": "", "allowed-attributes": "" } diff --git a/isso/utils/html.py b/isso/utils/html.py index 0cb4a80..81cd952 100644 --- a/isso/utils/html.py +++ b/isso/utils/html.py @@ -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")) diff --git a/share/isso-dev.conf b/share/isso-dev.conf index d417a19..7e70c16 100644 --- a/share/isso-dev.conf +++ b/share/isso-dev.conf @@ -28,6 +28,7 @@ enabled = false [markup] options = strikethrough, autolink, fenced_code, no_intra_emphasis +flags = allowed-elements = allowed-attributes = diff --git a/share/isso.conf b/share/isso.conf index ba8d983..ed706c8 100644 --- a/share/isso.conf +++ b/share/isso.conf @@ -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_. +# 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.