diff options
Diffstat (limited to 'packages/gitbook-markdown/lib')
-rw-r--r-- | packages/gitbook-markdown/lib/annotate_blocks.js | 2 | ||||
-rw-r--r-- | packages/gitbook-markdown/lib/annotate_inline.js | 2 | ||||
-rw-r--r-- | packages/gitbook-markdown/lib/page.js | 28 |
3 files changed, 14 insertions, 18 deletions
diff --git a/packages/gitbook-markdown/lib/annotate_blocks.js b/packages/gitbook-markdown/lib/annotate_blocks.js index 88653ad..cb8ada8 100644 --- a/packages/gitbook-markdown/lib/annotate_blocks.js +++ b/packages/gitbook-markdown/lib/annotate_blocks.js @@ -27,7 +27,7 @@ var rules = { newline: /^\n+/, // List of all the regexes we want to run var ruleTypes = [ -'newline', 'rawStart', 'rawEnd', 'code', 'fences', 'footnote', 'math', 'heading', +'rawStart', 'rawEnd', 'newline', 'code', 'fences', 'footnote', 'math', 'heading', 'nptable', 'lheading', 'hr', 'blockquote', 'list', 'html', 'def', 'table', 'paragraph', 'text', ]; diff --git a/packages/gitbook-markdown/lib/annotate_inline.js b/packages/gitbook-markdown/lib/annotate_inline.js index 649cec1..376b092 100644 --- a/packages/gitbook-markdown/lib/annotate_inline.js +++ b/packages/gitbook-markdown/lib/annotate_inline.js @@ -18,7 +18,7 @@ var rules = { text: /^[\s\S]+?(?=[\\<!\[_*`$~]|https?:\/\/| {2,}\n|$)/, math: /^\$\$\s*([\s\S]*?[^\$])\s*\$\$(?!\$)/, rawStart: /^{%([\s]*)raw([\s]*)%}/, - rawEnd: /^{%([\s]*)endraw([\s]*)%}/ + rawEnd: /[\s\S]*{%([\s]*)endraw([\s]*)%}/ // /^{%([\s]*)endraw([\s]*)%}/ //_inside: /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/, //_href: /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/ }; diff --git a/packages/gitbook-markdown/lib/page.js b/packages/gitbook-markdown/lib/page.js index 9b0f37f..1cd55a8 100644 --- a/packages/gitbook-markdown/lib/page.js +++ b/packages/gitbook-markdown/lib/page.js @@ -15,8 +15,6 @@ function combine(nodes) { return _.pluck(nodes, 'raw').join(''); } - - function preparePage(src) { var lexed = annotate.blocks(src); var levelRaw = 0; @@ -26,31 +24,29 @@ function preparePage(src) { el.raw = escape(el.raw); } else if (el.type == 'rawStart') { levelRaw = levelRaw + 1; - } else if (el.type == 'rawStart') { - levelRaw = levelRaw - 1; + } else if (el.type == 'rawEnd') { + levelRaw = 0; } return el; }; var escaped = lexed - // Escape code blocks - .map(escapeCodeElement) - - // Escape inline code blocks .map(function(el) { // Only escape paragraphs and headings - if(!(el.type == 'paragraph' || el.type == 'heading')) { - return el; - } + if(el.type == 'paragraph' || el.type == 'heading') { + var line = annotate.inline(el.raw); - // Escape inline code blocks - var newInline = annotate.inline(el.raw).map(escapeCodeElement); + // Escape inline code blocks + line = line.map(escapeCodeElement); - // Change raw source code - el.raw = combine(newInline); + // Change raw source code + el.raw = combine(line); - return el; + return el; + } else { + return escapeCodeElement(el); + } }); return combine(escaped); |