Properly copy/paste allowed HTML
This commit is contained in:
parent
5bc467164c
commit
359c417619
|
@ -91,6 +91,28 @@
|
|||
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: {
|
||||
'pre.code.highlight'(el, text) {
|
||||
let lang = el.getAttribute('lang');
|
||||
|
|
|
@ -233,6 +233,37 @@ describe 'Copy as GFM', feature: true, js: true do
|
|||
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
|
||||
verify(
|
||||
<<-GFM.strip_heredoc,
|
||||
|
|
Loading…
Reference in New Issue