FIX: details plugin wasn't working properly

This commit is contained in:
Régis Hanol 2016-07-06 19:12:21 +02:00 committed by Robin Ward
parent 6dc4a3f2d6
commit a2b9b01d0f
2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,5 @@
const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'div', const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'details',
'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output',
'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video']; 'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video'];

View File

@ -12,7 +12,8 @@ function replaceDetails(text) {
// add new lines to make sure we *always* have a <p> element after </summary> and around </details> // add new lines to make sure we *always* have a <p> element after </summary> and around </details>
// otherwise we can't hide the content since we can't target text nodes via CSS // otherwise we can't hide the content since we can't target text nodes via CSS
return text.replace(/<\/summary>/ig, "</summary>\n\n").replace(/<\/details>/ig, "\n\n</details>\n\n"); return text.replace(/<\/summary>/ig, "</summary>\n\n")
.replace(/<\/details>/ig, "\n\n</details>\n\n");
} }
registerOption((siteSettings, opts) => { registerOption((siteSettings, opts) => {
@ -20,6 +21,12 @@ registerOption((siteSettings, opts) => {
}); });
export function setup(helper) { export function setup(helper) {
helper.whiteList('details.elided'); helper.whiteList([
'summary',
'summary[title]',
'details',
'details.elided'
]);
helper.addPreProcessor(text => replaceDetails(text)); helper.addPreProcessor(text => replaceDetails(text));
} }