aboutsummaryrefslogtreecommitdiff
path: root/point/libs/markdownjs
diff options
context:
space:
mode:
Diffstat (limited to 'point/libs/markdownjs')
-rw-r--r--point/libs/markdownjs/markdown.min.js538
1 files changed, 538 insertions, 0 deletions
diff --git a/point/libs/markdownjs/markdown.min.js b/point/libs/markdownjs/markdown.min.js
new file mode 100644
index 0000000..9bf8d3f
--- /dev/null
+++ b/point/libs/markdownjs/markdown.min.js
@@ -0,0 +1,538 @@
1!function (a) {
2 function b() {
3 return"Markdown.mk_block( " + uneval(this.toString()) + ", " + uneval(this.trailing) + ", " + uneval(this.lineNumber) + " )"
4 }
5
6 function c() {
7 var a = require("util");
8 return"Markdown.mk_block( " + a.inspect(this.toString()) + ", " + a.inspect(this.trailing) + ", " + a.inspect(this.lineNumber) + " )"
9 }
10
11 function d(a) {
12 for (var b = 0, c = -1; -1 !== (c = a.indexOf("\n", c + 1));)b++;
13 return b
14 }
15
16 function e(a) {
17 return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;")
18 }
19
20 function f(a) {
21 if ("string" == typeof a)return e(a);
22 var b = a.shift(), c = {}, d = [];
23 for (!a.length || "object" != typeof a[0] || a[0]instanceof Array || (c = a.shift()); a.length;)d.push(f(a.shift()));
24 var g = "";
25 for (var h in c)g += " " + h + '="' + e(c[h]) + '"';
26 return"img" === b || "br" === b || "hr" === b ? "<" + b + g + "/>" : "<" + b + g + ">" + d.join("") + "</" + b + ">"
27 }
28
29 function g(a, b, c) {
30 var d;
31 c = c || {};
32 var e = a.slice(0);
33 "function" == typeof c.preprocessTreeNode && (e = c.preprocessTreeNode(e, b));
34 var f = o(e);
35 if (f) {
36 e[1] = {};
37 for (d in f)e[1][d] = f[d];
38 f = e[1]
39 }
40 if ("string" == typeof e)return e;
41 switch (e[0]) {
42 case"header":
43 e[0] = "h" + e[1].level, delete e[1].level;
44 break;
45 case"bulletlist":
46 e[0] = "ul";
47 break;
48 case"numberlist":
49 e[0] = "ol";
50 break;
51 case"listitem":
52 e[0] = "li";
53 break;
54 case"para":
55 e[0] = "p";
56 break;
57 case"markdown":
58 e[0] = "html", f && delete f.references;
59 break;
60 case"code_block":
61 e[0] = "pre", d = f ? 2 : 1;
62 var h = ["code"];
63 h.push.apply(h, e.splice(d, e.length - d)), e[d] = h;
64 break;
65 case"inlinecode":
66 e[0] = "code";
67 break;
68 case"img":
69 e[1].src = e[1].href, delete e[1].href;
70 break;
71 case"linebreak":
72 e[0] = "br";
73 break;
74 case"link":
75 e[0] = "a";
76 break;
77 case"link_ref":
78 e[0] = "a";
79 var i = b[f.ref];
80 if (!i)return f.original;
81 delete f.ref, f.href = i.href, i.title && (f.title = i.title), delete f.original;
82 break;
83 case"img_ref":
84 e[0] = "img";
85 var i = b[f.ref];
86 if (!i)return f.original;
87 delete f.ref, f.src = i.href, i.title && (f.title = i.title), delete f.original
88 }
89 if (d = 1, f) {
90 for (var j in e[1]) {
91 d = 2;
92 break
93 }
94 1 === d && e.splice(d, 1)
95 }
96 for (; d < e.length; ++d)e[d] = g(e[d], b, c);
97 return e
98 }
99
100 function h(a) {
101 for (var b = o(a) ? 2 : 1; b < a.length;)"string" == typeof a[b] ? b + 1 < a.length && "string" == typeof a[b + 1] ? a[b] += a.splice(b + 1, 1)[0] : ++b : (h(a[b]), ++b)
102 }
103
104 function i(a, b) {
105 function c(a) {
106 this.len_after = a, this.name = "close_" + b
107 }
108
109 var d = a + "_state", e = "strong" === a ? "em_state" : "strong_state";
110 return function (f) {
111 if (this[d][0] === b)return this[d].shift(), [f.length, new c(f.length - b.length)];
112 var g = this[e].slice(), h = this[d].slice();
113 this[d].unshift(b);
114 var i = this.processInline(f.substr(b.length)), j = i[i.length - 1];
115 if (this[d].shift(), j instanceof c) {
116 i.pop();
117 var k = f.length - j.len_after;
118 return[k, [a].concat(i)]
119 }
120 return this[e] = g, this[d] = h, [b.length, b]
121 }
122 }
123
124 function j(a) {
125 for (var b = a.split(""), c = [""], d = !1; b.length;) {
126 var e = b.shift();
127 switch (e) {
128 case" ":
129 d ? c[c.length - 1] += e : c.push("");
130 break;
131 case"'":
132 case'"':
133 d = !d;
134 break;
135 case"\\":
136 e = b.shift();
137 default:
138 c[c.length - 1] += e
139 }
140 }
141 return c
142 }
143
144 var k = {};
145 k.mk_block = function (a, d, e) {
146 1 === arguments.length && (d = "\n\n");
147 var f = new String(a);
148 return f.trailing = d, f.inspect = c, f.toSource = b, void 0 !== e && (f.lineNumber = e), f
149 };
150 var l = k.isArray = Array.isArray || function (a) {
151 return"[object Array]" === Object.prototype.toString.call(a)
152 };
153 k.forEach = Array.prototype.forEach ? function (a, b, c) {
154 return a.forEach(b, c)
155 } : function (a, b, c) {
156 for (var d = 0; d < a.length; d++)b.call(c || a, a[d], d, a)
157 }, k.isEmpty = function (a) {
158 for (var b in a)if (hasOwnProperty.call(a, b))return!1;
159 return!0
160 }, k.extract_attr = function (a) {
161 return l(a) && a.length > 1 && "object" == typeof a[1] && !l(a[1]) ? a[1] : void 0
162 };
163 var m = function (a) {
164 switch (typeof a) {
165 case"undefined":
166 this.dialect = m.dialects.Gruber;
167 break;
168 case"object":
169 this.dialect = a;
170 break;
171 default:
172 if (!(a in m.dialects))throw new Error("Unknown Markdown dialect '" + String(a) + "'");
173 this.dialect = m.dialects[a]
174 }
175 this.em_state = [], this.strong_state = [], this.debug_indent = ""
176 };
177 m.dialects = {};
178 var n = m.mk_block = k.mk_block, l = k.isArray;
179 m.parse = function (a, b) {
180 var c = new m(b);
181 return c.toTree(a)
182 }, m.prototype.split_blocks = function (a) {
183 a = a.replace(/(\r\n|\n|\r)/g, "\n");
184 var b, c = /([\s\S]+?)($|\n#|\n(?:\s*\n|$)+)/g, e = [], f = 1;
185 for (null !== (b = /^(\s*\n)/.exec(a)) && (f += d(b[0]), c.lastIndex = b[0].length); null !== (b = c.exec(a));)"\n#" === b[2] && (b[2] = "\n", c.lastIndex--), e.push(n(b[1], b[2], f)), f += d(b[0]);
186 return e
187 }, m.prototype.processBlock = function (a, b) {
188 var c = this.dialect.block, d = c.__order__;
189 if ("__call__"in c)return c.__call__.call(this, a, b);
190 for (var e = 0; e < d.length; e++) {
191 var f = c[d[e]].call(this, a, b);
192 if (f)return(!l(f) || f.length > 0 && !l(f[0])) && this.debug(d[e], "didn't return a proper array"), f
193 }
194 return[]
195 }, m.prototype.processInline = function (a) {
196 return this.dialect.inline.__call__.call(this, String(a))
197 }, m.prototype.toTree = function (a, b) {
198 var c = a instanceof Array ? a : this.split_blocks(a), d = this.tree;
199 try {
200 for (this.tree = b || this.tree || ["markdown"]; c.length;) {
201 var e = this.processBlock(c.shift(), c);
202 e.length && this.tree.push.apply(this.tree, e)
203 }
204 return this.tree
205 } finally {
206 b && (this.tree = d)
207 }
208 }, m.prototype.debug = function () {
209 var a = Array.prototype.slice.call(arguments);
210 a.unshift(this.debug_indent), "undefined" != typeof print && print.apply(print, a), "undefined" != typeof console && "undefined" != typeof console.log && console.log.apply(null, a)
211 }, m.prototype.loop_re_over_block = function (a, b, c) {
212 for (var d, e = b.valueOf(); e.length && null !== (d = a.exec(e));)e = e.substr(d[0].length), c.call(this, d);
213 return e
214 }, m.buildBlockOrder = function (a) {
215 var b = [];
216 for (var c in a)"__order__" !== c && "__call__" !== c && b.push(c);
217 a.__order__ = b