From b196d6cc17f5916f73e39dfb8983cd587b47a391 Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 12 Aug 2019 15:54:17 -0600 Subject: [PATCH] Markdown: add
+ to whitelist This allows creating collapsible sections, which will probably be especially useful in wiki pages. --- tildes/scss/_base.scss | 5 +++++ tildes/scss/_placeholders.scss | 6 ++++++ tildes/scss/modules/_topic.scss | 2 +- tildes/tildes/lib/markdown.py | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tildes/scss/_base.scss b/tildes/scss/_base.scss index 922f078..af03ec0 100644 --- a/tildes/scss/_base.scss +++ b/tildes/scss/_base.scss @@ -50,6 +50,11 @@ dl dd { font-size: 0.7rem; } +details:not([open]) { + cursor: pointer; + display: inline-block; +} + // Fixes a Chrome bug that seems to treat children of
as having // box-sizing: content-box. See Known issues: https://caniuse.com/#feat=details details * { diff --git a/tildes/scss/_placeholders.scss b/tildes/scss/_placeholders.scss index 4efba61..78f1313 100644 --- a/tildes/scss/_placeholders.scss +++ b/tildes/scss/_placeholders.scss @@ -11,6 +11,12 @@ } } + details { + margin-bottom: 0.4rem; + padding: 0.2rem 0.4rem; + border: 1px dotted; + } + hr { margin-left: 0; max-width: $paragraph-max-width; diff --git a/tildes/scss/modules/_topic.scss b/tildes/scss/modules/_topic.scss index 5201f47..d12a603 100644 --- a/tildes/scss/modules/_topic.scss +++ b/tildes/scss/modules/_topic.scss @@ -182,7 +182,7 @@ line-height: 0.8rem; } - summary::after { + > summary::after { font-style: italic; content: "Re-collapse topic text"; display: none; diff --git a/tildes/tildes/lib/markdown.py b/tildes/tildes/lib/markdown.py index b393e3d..e1dcda4 100644 --- a/tildes/tildes/lib/markdown.py +++ b/tildes/tildes/lib/markdown.py @@ -63,6 +63,7 @@ HTML_TAG_WHITELIST = ( "br", "code", "del", + "details", "em", "h1", "h2", @@ -80,6 +81,7 @@ HTML_TAG_WHITELIST = ( "small", "strong", "sub", + "summary", "sup", "span", "table", @@ -94,6 +96,7 @@ PROTOCOL_WHITELIST = ("http", "https", "mailto") HTML_ATTRIBUTE_WHITELIST_DEFAULT = { "a": ["href", "title"], + "details": ["open"], "ol": ["start"], "td": ["align"], "th": ["align"],