1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitIns = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | 'use strict';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | function scanDelims(state, start) {
|
8 | var pos = start, lastChar, nextChar, count,
|
9 | isLastWhiteSpace, isLastPunctChar,
|
10 | isNextWhiteSpace, isNextPunctChar,
|
11 | can_open = true,
|
12 | can_close = true,
|
13 | max = state.posMax,
|
14 | marker = state.src.charCodeAt(start),
|
15 | isWhiteSpace = state.md.utils.isWhiteSpace,
|
16 | isPunctChar = state.md.utils.isPunctChar,
|
17 | isMdAsciiPunct = state.md.utils.isMdAsciiPunct;
|
18 |
|
19 |
|
20 | lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20;
|
21 |
|
22 | while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; }
|
23 |
|
24 | if (pos >= max) {
|
25 | can_open = false;
|
26 | }
|
27 |
|
28 | count = pos - start;
|
29 |
|
30 |
|
31 | nextChar = pos < max ? state.src.charCodeAt(pos) : 0x20;
|
32 |
|
33 | isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
|
34 | isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
|
35 |
|
36 | isLastWhiteSpace = isWhiteSpace(lastChar);
|
37 | isNextWhiteSpace = isWhiteSpace(nextChar);
|
38 |
|
39 | if (isNextWhiteSpace) {
|
40 | can_open = false;
|
41 | } else if (isNextPunctChar) {
|
42 | if (!(isLastWhiteSpace || isLastPunctChar)) {
|
43 | can_open = false;
|
44 | }
|
45 | }
|
46 |
|
47 | if (isLastWhiteSpace) {
|
48 | can_close = false;
|
49 | } else if (isLastPunctChar) {
|
50 | if (!(isNextWhiteSpace || isNextPunctChar)) {
|
51 | can_close = false;
|
52 | }
|
53 | }
|
54 |
|
55 | return {
|
56 | can_open: can_open,
|
57 | can_close: can_close,
|
58 | delims: count
|
59 | };
|
60 | }
|
61 |
|
62 |
|
63 | function insert(state, silent) {
|
64 | var startCount,
|
65 | count,
|
66 | tagCount,
|
67 | found,
|
68 | stack,
|
69 | res,
|
70 | token,
|
71 | max = state.posMax,
|
72 | start = state.pos,
|
73 | marker = state.src.charCodeAt(start);
|
74 |
|
75 | if (marker !== 0x2B) { return false; }
|
76 | if (silent) { return false; }
|
77 |
|
78 | res = scanDelims(state, start);
|
79 | startCount = res.delims;
|
80 |
|
81 | if (!res.can_open) {
|
82 | state.pos += startCount;
|
83 |
|
84 | state.pending += state.src.slice(start, state.pos);
|
85 | return true;
|
86 | }
|
87 |
|
88 | stack = Math.floor(startCount / 2);
|
89 | if (stack <= 0) { return false; }
|
90 | state.pos = start + startCount;
|
91 |
|
92 | while (state.pos < max) {
|
93 | if (state.src.charCodeAt(state.pos) === marker) {
|
94 | res = scanDelims(state, state.pos);
|
95 | count = res.delims;
|
96 | tagCount = Math.floor(count / 2);
|
97 | if (res.can_close) {
|
98 | if (tagCount >= stack) {
|
99 | state.pos += count - 2;
|
100 | found = true;
|
101 | break;
|
102 | }
|
103 | stack -= tagCount;
|
104 | state.pos += count;
|
105 | continue;
|
106 | }
|
107 |
|
108 | if (res.can_open) { stack += tagCount; }
|
109 | state.pos += count;
|
110 | continue;
|
111 | }
|
112 |
|
113 | state.md.inline.skipToken(state);
|
114 | }
|
115 |
|
116 | if (!found) {
|
117 |
|
118 | state.pos = start;
|
119 | return false;
|
120 | }
|
121 |
|
122 |
|
123 | state.posMax = state.pos;
|
124 | state.pos = start + 2;
|
125 |
|
126 |
|
127 | token = state.push('ins_open', 'ins', 1);
|
128 | token.markup = String.fromCharCode(marker) + String.fromCharCode(marker);
|
129 |
|
130 | state.md.inline.tokenize(state);
|
131 |
|
132 | token = state.push('ins_close', 'ins', -1);
|
133 | token.markup = String.fromCharCode(marker) + String.fromCharCode(marker);
|
134 |
|
135 | state.pos = state.posMax + 2;
|
136 | state.posMax = max;
|
137 | return true;
|
138 | }
|
139 |
|
140 |
|
141 | module.exports = function ins_plugin(md) {
|
142 | md.inline.ruler.before('emphasis', 'ins', insert);
|
143 | };
|
144 |
|
145 | },{}]},{},[1])(1)
|
146 | }); |
\ | No newline at end of file |