diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2015-03-12 19:43:41 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 15:00:39 +0100 |
commit | e2a72ac7ba55f5d0a26e4cbe57d6be3a0e85b751 (patch) | |
tree | 142e9f1c0386cfb5461696cc7cfce8fdd35e5b1a /packages/gitbook-markdown/lib/annotate.js | |
parent | 2196afddd60f6a9e050cad7baf4bf6d6935f6769 (diff) | |
download | gitbook-e2a72ac7ba55f5d0a26e4cbe57d6be3a0e85b751.zip gitbook-e2a72ac7ba55f5d0a26e4cbe57d6be3a0e85b751.tar.gz gitbook-e2a72ac7ba55f5d0a26e4cbe57d6be3a0e85b751.tar.bz2 |
Add inline annotation and improve code layout
Diffstat (limited to 'packages/gitbook-markdown/lib/annotate.js')
-rw-r--r-- | packages/gitbook-markdown/lib/annotate.js | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/packages/gitbook-markdown/lib/annotate.js b/packages/gitbook-markdown/lib/annotate.js deleted file mode 100644 index 34e5d90..0000000 --- a/packages/gitbook-markdown/lib/annotate.js +++ /dev/null @@ -1,44 +0,0 @@ -var engine = require('./annotate_engine'); - -// Pulled from "kramed.Lexer.rules.tables" -var rules = { newline: /^\n+/, - code: /^( {4}[^\n]+\n*)+/, - fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/, - hr: /^( *[-*_]){3,} *(?:\n+|$)/, - heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, - nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, - lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, - blockquote: /^( *>[^\n]+(\n(?! *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$))[^\n]+)*\n*)+/, - list: /^( *)((?:[*+-]|\d+\.)) [\s\S]+?(?:\n+(?=\1?(?:[-*_] *){3,}(?:\n+|$))|\n+(?= *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$))|\n{2,}(?! )(?!\1(?:[*+-]|\d+\.) )\n*|\s*$)/, - html: /^ *(?:<!--[\s\S]*?--> *(?:\n|\s*$)|<((?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\b)\w+(?!:\/|[^\w\s@]*@)\b)[\s\S]+?<\/\1> *(?:\n{2,}|\s*$)|<(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\b)\w+(?!:\/|[^\w\s@]*@)\b(?:"[^"]*"|'[^']*'|[^'">])*?> *(?:\n{2,}|\s*$))/, - def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, - footnote: /^\[\^([^\]]+)\]: ([^\n]+)/, - table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/, - paragraph: /^((?:[^\n]+\n?(?! *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\2 *(?:\n+|$)|( *)((?:[*+-]|\d+\.)) [\s\S]+?(?:\n+(?=\3?(?:[-*_] *){3,}(?:\n+|$))|\n+(?= *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$))|\n{2,}(?! )(?!\1(?:[*+-]|\d+\.) )\n*|\s*$)|( *[-*_]){3,} *(?:\n+|$)| *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)|([^\n]+)\n *(=|-){2,} *(?:\n+|$)|( *>[^\n]+(\n(?! *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$))[^\n]+)*\n*)+|<(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\b)\w+(?!:\/|[^\w\s@]*@)\b| *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)| *(\${2,}) *([\s\S]+?)\s*\1 *(?:\n+|$)))+)\n*/, - text: /^[^\n]+/, - math: /^ *(\${2,}) *([\s\S]+?)\s*\1 *(?:\n+|$)/, - // These are lower level, ignore them - //bullet: /(?:[*+-]|\d+\.)/, - //item: /^( *)((?:[*+-]|\d+\.)) [^\n]*(?:\n(?!\1(?:[*+-]|\d+\.) )[^\n]*)*/gm, - //_tag: '(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b' -}; - -// List of all the regexes we want to run -var ruleTypes = [ -'newline', 'code', 'fences', 'footnote', 'math', 'heading', -'nptable', 'lheading', 'hr', 'blockquote', 'list', -'html', 'def', 'table', 'paragraph', 'text', -]; - -// Mapping if rule type is different from token type -var ruleMap = { - 'nptable': 'table', - 'lheading': 'heading', - 'newline': 'space', -} - -function annotate(src) { - return engine(src, rules, ruleTypes, ruleMap); -} - -module.exports = annotate; |