diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 10:31:41 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 10:31:41 -0800 |
commit | 74f88deac274a3138af13daa76e265cfb93fd509 (patch) | |
tree | a10a796ce1fc22dbf6c8ea8fc8db6d9a07da68f9 /js/lib | |
parent | 732bb492959c4d1008c7f8bf5b26d9c45c3f6a95 (diff) |
Reordered some definitions, so regex is defined before being used.
Diffstat (limited to 'js/lib')
-rw-r--r-- | js/lib/blocks.js | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js index afc5ea9..a7b75aa 100644 --- a/js/lib/blocks.js +++ b/js/lib/blocks.js @@ -5,8 +5,36 @@ var C_SPACE = 32; var C_OPEN_BRACKET = 91; var InlineParser = require('./inlines'); + var unescapeString = new InlineParser().unescapeString; +var BLOCKTAGNAME = '(?:article|header|aside|hgroup|iframe|blockquote|hr|body|li|map|button|object|canvas|ol|caption|output|col|p|colgroup|pre|dd|progress|div|section|dl|table|td|dt|tbody|embed|textarea|fieldset|tfoot|figcaption|th|figure|thead|footer|footer|tr|form|ul|h1|h2|h3|h4|h5|h6|video|script|style)'; + +var HTMLBLOCKOPEN = "<(?:" + BLOCKTAGNAME + "[\\s/>]" + "|" + + "/" + BLOCKTAGNAME + "[\\s>]" + "|" + "[?!])"; + +var reHtmlBlockOpen = new RegExp('^' + HTMLBLOCKOPEN, 'i'); + +var reHrule = /^(?:(?:\* *){3,}|(?:_ *){3,}|(?:- *){3,}) *$/; + +var reMaybeSpecial = /^[ #`~*+_=<>0-9-]/; + +var reNonSpace = /[^ \t\n]/; + +var reBulletListMarker = /^[*+-]( +|$)/; + +var reOrderedListMarker = /^(\d+)([.)])( +|$)/; + +var reATXHeaderMarker = /^#{1,6}(?: +|$)/; + +var reCodeFence = /^`{3,}(?!.*`)|^~{3,}(?!.*~)/; + +var reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/; + +var reSetextHeaderLine = /^(?:=+|-+) *$/; + +var reLineEnding = /\r\n|\n|\r/; + // Returns true if string contains only space characters. var isBlank = function(s) { "use strict"; @@ -44,35 +72,9 @@ var matchAt = function(re, s, offset) { } }; -var BLOCKTAGNAME = '(?:article|header|aside|hgroup|iframe|blockquote|hr|body|li|map|button|object|canvas|ol|caption|output|col|p|colgroup|pre|dd|progress|div|section|dl|table|td|dt|tbody|embed|textarea|fieldset|tfoot|figcaption|th|figure|thead|footer|footer|tr|form|ul|h1|h2|h3|h4|h5|h6|video|script|style)'; -var HTMLBLOCKOPEN = "<(?:" + BLOCKTAGNAME + "[\\s/>]" + "|" + - "/" + BLOCKTAGNAME + "[\\s>]" + "|" + "[?!])"; -var reHtmlBlockOpen = new RegExp('^' + HTMLBLOCKOPEN, 'i'); - -var reHrule = /^(?:(?:\* *){3,}|(?:_ *){3,}|(?:- *){3,}) *$/; - -var reMaybeSpecial = /^[ #`~*+_=<>0-9-]/; - -var reNonSpace = /[^ \t\n]/; - -var reBulletListMarker = /^[*+-]( +|$)/; - -var reOrderedListMarker = /^(\d+)([.)])( +|$)/; - -var reATXHeaderMarker = /^#{1,6}(?: +|$)/; - -var reCodeFence = /^`{3,}(?!.*`)|^~{3,}(?!.*~)/; - -var reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/; - -var reSetextHeaderLine = /^(?:=+|-+) *$/; - -var reFinalNewlines = /(?:\n *)+$/; - -var reLineEnding = /\r\n|\n|\r/; - // destructively trip final blank lines in an array of strings var stripFinalBlankLines = function(lns) { + "use strict"; var i = lns.length - 1; while (!reNonSpace.test(lns[i])) { lns.pop(); |