Commit 359c4176 authored by Douwe Maan's avatar Douwe Maan

Properly copy/paste allowed HTML

parent 5bc46716
...@@ -91,6 +91,28 @@ ...@@ -91,6 +91,28 @@
return text.trim(); return text.trim();
}, },
}, },
SanitizationFilter: {
'br'(el, text) {
return '<br>';
},
'dl'(el, text) {
let lines = text.trim().split('\n');
// Add two spaces to the front of subsequent list items lines,
// or leave the line entirely blank.
lines = lines.map((s) => {
s = s.trim();
if (s.length === 0) return '';
return ` ${s}`;
});
return `<dl>\n${lines.join('\n')}\n</dl>`;
},
'sub, dt, dd, kbd, q, samp, var, ruby, rt, rp, abbr'(el, text) {
const tag = el.nodeName.toLowerCase();
return `<${tag}>${text}</${tag}>`;
},
},
SyntaxHighlightFilter: { SyntaxHighlightFilter: {
'pre.code.highlight'(el, text) { 'pre.code.highlight'(el, text) {
let lang = el.getAttribute('lang'); let lang = el.getAttribute('lang');
......
...@@ -233,6 +233,37 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -233,6 +233,37 @@ describe 'Copy as GFM', feature: true, js: true do
end end
end end
it 'supports SanitizationFilter' do
verify(
<<-GFM.strip_heredoc
BR: <br>
<sub>sub</sub>
<dl>
<dt>dt</dt>
<dd>dd</dd>
</dl>
<kbd>kbd</kbd>
<q>q</q>
<samp>samp</samp>
<var>var</var>
<ruby>ruby</ruby>
<rt>rt</rt>
<rp>rp</rp>
<abbr>abbr</abbr>
GFM
)
end
it 'supports SyntaxHighlightFilter' do it 'supports SyntaxHighlightFilter' do
verify( verify(
<<-GFM.strip_heredoc, <<-GFM.strip_heredoc,
......
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