aboutsummaryrefslogtreecommitdiff
path: root/plugin/markdown
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2015-07-07 12:15:43 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2015-07-07 12:15:43 +0200
commitd44125d789a8d80beaf6426379c23270bee131d9 (patch)
tree57b108e9044dd7551c17a4f3d2bba4e7b4745712 /plugin/markdown
parent399d4f652d9ddd4d63040b2dc6bcdc19615abd1e (diff)
downloadfosdem-2018-presentation-d44125d789a8d80beaf6426379c23270bee131d9.tar
fosdem-2018-presentation-d44125d789a8d80beaf6426379c23270bee131d9.tar.gz
tweaks for #1200
Diffstat (limited to 'plugin/markdown')
-rwxr-xr-xplugin/markdown/markdown.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 14433e6..f4035e2 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -31,6 +31,8 @@
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
+ var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__';
+
/**
* Retrieves the markdown contents of a slide section
@@ -42,8 +44,10 @@
// strip leading whitespace so it isn't evaluated as code
var text = ( template || section ).textContent;
- // restore script end tag
- text = text.replace(/__SCRIPT_END__/g, '</script>');
+
+ // restore script end tags
+ text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' );
+
var leadingWs = text.match( /^\n?(\s*)/ )[1].length,
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
@@ -115,8 +119,11 @@
if( notesMatch.length === 2 ) {
content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>';
}
- //handle script end tag bug
- content = content.replace(/<\/script>/g, '__SCRIPT_END__');
+
+ // prevent script end tags in the content from interfering
+ // with parsing
+ content = content.replace( /<\/script>/g, SCRIPT_END_PLACEHOLDER );
+
return '<script type="text/template">' + content + '</script>';
}