aboutsummaryrefslogtreecommitdiff
path: root/node_modules/markdown-it/lib/rules_inline/balance_pairs.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/markdown-it/lib/rules_inline/balance_pairs.js
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/markdown-it/lib/rules_inline/balance_pairs.js')
-rw-r--r--node_modules/markdown-it/lib/rules_inline/balance_pairs.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/markdown-it/lib/rules_inline/balance_pairs.js b/node_modules/markdown-it/lib/rules_inline/balance_pairs.js
new file mode 100644
index 00000000..f2a52072
--- /dev/null
+++ b/node_modules/markdown-it/lib/rules_inline/balance_pairs.js
@@ -0,0 +1,44 @@
+// For each opening emphasis-like marker find a matching closing one
+//
+'use strict';
+
+
+module.exports = function link_pairs(state) {
+ var i, j, lastDelim, currDelim,
+ delimiters = state.delimiters,
+ max = state.delimiters.length;
+
+ for (i = 0; i < max; i++) {
+ lastDelim = delimiters[i];
+
+ if (!lastDelim.close) { continue; }
+
+ j = i - lastDelim.jump - 1;
+
+ while (j >= 0) {
+ currDelim = delimiters[j];
+
+ if (currDelim.open &&
+ currDelim.marker === lastDelim.marker &&
+ currDelim.end < 0 &&
+ currDelim.level === lastDelim.level) {
+
+ // typeofs are for backward compatibility with plugins
+ var odd_match = (currDelim.close || lastDelim.open) &&
+ typeof currDelim.length !== 'undefined' &&
+ typeof lastDelim.length !== 'undefined' &&
+ (currDelim.length + lastDelim.length) % 3 === 0;
+
+ if (!odd_match) {
+ lastDelim.jump = i - j;
+ lastDelim.open = false;
+ currDelim.end = i;
+ currDelim.jump = 0;
+ break;
+ }
+ }
+
+ j -= currDelim.jump + 1;
+ }
+ }
+};