diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-15 09:34:01 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-15 10:07:26 -0800 |
commit | 013294b384ab6dec0320f4c2ce6aa7a810b1630a (patch) | |
tree | 4dca5ec96d70faff8ef2be3a1f3852ad424f6e94 /js/lib/inlines.js | |
parent | c637f8d6d57aa197d57579dc8f87023be635e8ad (diff) |
Added normalize-reference.js.
This does a proper unicode case fold instead of just using
toUpperCase. It is also faster, partly because we can do
one pass for space and case normalization.
Modified from the NPM package fold-case; proper credit given
in source and COPYING.
Diffstat (limited to 'js/lib/inlines.js')
-rw-r--r-- | js/lib/inlines.js | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/js/lib/inlines.js b/js/lib/inlines.js index 46e4644..8bd70c2 100644 --- a/js/lib/inlines.js +++ b/js/lib/inlines.js @@ -2,6 +2,8 @@ var Node = require('./node'); var common = require('./common'); +var normalizeReference = require('./normalize-reference'); + var normalizeURI = common.normalizeURI; var unescapeString = common.unescapeString; var fromCodePoint = require('./from-code-point.js'); @@ -92,14 +94,6 @@ var reLinkLabel = /^\[(?:[^\\\[\]]|\\[\[\]]){0,1000}\]/; // Matches a string of non-special characters. var reMain = /^[^\n`\[\]\\!<&*_]+/m; -// Normalize reference label: collapse internal whitespace -// to single space, remove leading/trailing whitespace, case fold. -var normalizeReference = function(s) { - return s.trim() - .replace(/\s+/, ' ') - .toUpperCase(); -}; - var text = function(s) { var node = new Node('Text'); node.literal = s; |