From 80aadaf74e901b184d86b536c0c01e0fe98623d0 Mon Sep 17 00:00:00 2001 From: Gabriel Pillet Date: Thu, 31 Oct 2013 14:02:34 +0100 Subject: Removing global flag for replacing whitespaces --- plugin/markdown/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index d6c6c45..23a3ed4 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -49,7 +49,7 @@ text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' ); } else if( leadingWs > 1 ) { - text = text.replace( new RegExp('\\n? {' + leadingWs + '}','g'), '\n' ); + text = text.replace( new RegExp('\\n? {' + leadingWs + '}'), '\n' ); } return text; -- cgit v1.2.3 From 015468c3a2d1d4092f33920ac555a0e288e6213f Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 17 Feb 2014 21:15:02 +0100 Subject: renamed markdown attributes for clarity and consistency: data-vertical -> data-separator-vertical, data-notes -> data-separator-notes --- README.md | 6 +++--- plugin/markdown/example.html | 4 ++-- plugin/markdown/markdown.js | 10 +++++----- test/test-markdown-element-attributes.html | 8 ++++---- test/test-markdown-slide-attributes.html | 10 +++++----- test/test-markdown.html | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'plugin/markdown/markdown.js') diff --git a/README.md b/README.md index 8a37a0d..cbdb088 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ When used locally, this feature requires that reveal.js [runs from a local web s ```html
``` @@ -621,7 +621,7 @@ When used locally, this feature requires that reveal.js [runs from a local web s If you're using the external Markdown plugin, you can add notes with the help of a special delimiter: ```html -
+
# Title ## Sub-title diff --git a/plugin/markdown/example.html b/plugin/markdown/example.html index 909639f..364e866 100644 --- a/plugin/markdown/example.html +++ b/plugin/markdown/example.html @@ -19,7 +19,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
end bug inside code markdown by changing the tag before html is parsed and restoring it before markdown parsing--- plugin/markdown/markdown.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index 9afee06..738195f 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -42,7 +42,8 @@ // 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, ''); var leadingWs = text.match( /^\n?(\s*)/ )[1].length, leadingTabs = text.match( /^\n?(\t*)/ )[1].length; @@ -114,7 +115,8 @@ if( notesMatch.length === 2 ) { content = notesMatch[0] + ''; } - + //handle script end tag bug + content = content.replace(/<\/script>/g, '__SCRIPT_END__'); return ''; } -- cgit v1.2.3 From d44125d789a8d80beaf6426379c23270bee131d9 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 7 Jul 2015 12:15:43 +0200 Subject: tweaks for #1200 --- plugin/markdown/markdown.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugin/markdown/markdown.js') 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, ''); + + // restore script end tags + text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '' ); + 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] + ''; } - //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 ''; } -- cgit v1.2.3 From 625831b9930c50114ab96dd635813a36655e7614 Mon Sep 17 00:00:00 2001 From: Liu Zhanhong Date: Mon, 19 Oct 2015 19:50:43 +0800 Subject: format note content when creating slide In html content, marked allow `Inline-Level Grammar` but not `Block-Level Grammar`, so when I write following: ``` note: * a * b * c ``` it become: ```html

a b

  • c
``` unbelievable!--- plugin/markdown/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index f4035e2..031160c 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -117,7 +117,7 @@ var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) ); if( notesMatch.length === 2 ) { - content = notesMatch[0] + ''; + content = notesMatch[0] + ''; } // prevent script end tags in the content from interfering -- cgit v1.2.3 From 43f0d081550e5a4a3bc86e478ecc145990ad9a40 Mon Sep 17 00:00:00 2001 From: teawithfruit Date: Mon, 2 Nov 2015 10:37:16 +0100 Subject: fixed loading --- plugin/markdown/markdown.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index f4035e2..f40e2b6 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -4,7 +4,11 @@ * of external markdown documents. */ (function( root, factory ) { - if( typeof exports === 'object' ) { + if (typeof define === 'function' && define.amd) { + root.marked = require( './marked' ); + root.RevealMarkdown = factory( root.marked ); + root.RevealMarkdown.initialize(); + } else if( typeof exports === 'object' ) { module.exports = factory( require( './marked' ) ); } else { -- cgit v1.2.3 From 16ebf2a783724527faac2036bc2f971df8dea0a5 Mon Sep 17 00:00:00 2001 From: Riceball LEE Date: Wed, 11 Nov 2015 07:37:08 +0000 Subject: * [bug] the markdown plugin can not render highlight codes for marked.setOptions(highlight) --- plugin/markdown/markdown.js | 4 ++-- test/simple.md | 10 ++++++++++ test/test-markdown-external.html | 36 ++++++++++++++++++++++++++++++++++++ test/test-markdown-external.js | 19 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 test/simple.md create mode 100644 test/test-markdown-external.html create mode 100644 test/test-markdown-external.js (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index f4035e2..5544599 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -20,8 +20,8 @@ if( typeof hljs !== 'undefined' ) { marked.setOptions({ - highlight: function( lang, code ) { - return hljs.highlightAuto( lang, code ).value; + highlight: function( code, lang ) { + return hljs.highlightAuto( code, [lang] ).value; } }); } diff --git a/test/simple.md b/test/simple.md new file mode 100644 index 0000000..cd57d70 --- /dev/null +++ b/test/simple.md @@ -0,0 +1,10 @@ +## Slide 1.1 + +```js +var a = 1; +``` + +## Slide 1.2 + + +## Slide 2 diff --git a/test/test-markdown-external.html b/test/test-markdown-external.html new file mode 100644 index 0000000..859d0a1 --- /dev/null +++ b/test/test-markdown-external.html @@ -0,0 +1,36 @@ + + + + + + + reveal.js - Test Markdown + + + + + + + +
+
+ + + + + + + + + + + + + + diff --git a/test/test-markdown-external.js b/test/test-markdown-external.js new file mode 100644 index 0000000..a9ea034 --- /dev/null +++ b/test/test-markdown-external.js @@ -0,0 +1,19 @@ + + +Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'Markdown' ); + + test( 'Vertical separator', function() { + strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' ); + }); + test( 'language highlighter', function() { + strictEqual( document.querySelectorAll( '.hljs-keyword' ).length, 1, 'got rendered highlight tag.' ); + strictEqual( document.querySelector( '.hljs-keyword' ).innerHTML, 'var', 'the same keyword: var.' ); + }); + + +} ); + +Reveal.initialize(); + -- cgit v1.2.3 From c0ea2cd98010d16ea90123e26578e19656d6c2dc Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Fri, 8 Jan 2016 14:02:16 +0100 Subject: same code format --- plugin/markdown/markdown.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugin/markdown/markdown.js') diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index f40e2b6..ab8f2e9 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -10,8 +10,7 @@ root.RevealMarkdown.initialize(); } else if( typeof exports === 'object' ) { module.exports = factory( require( './marked' ) ); - } - else { + } else { // Browser globals (root is window) root.RevealMarkdown = factory( root.marked ); root.RevealMarkdown.initialize(); -- cgit v1.2.3