khoj 1.17.1.dev223__py3-none-any.whl → 1.20.1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- khoj/app/settings.py +1 -1
- khoj/routers/web_client.py +29 -130
- {khoj-1.17.1.dev223.dist-info → khoj-1.20.1.dev1.dist-info}/METADATA +1 -1
- {khoj-1.17.1.dev223.dist-info → khoj-1.20.1.dev1.dist-info}/RECORD +7 -52
- khoj/interface/web/404.html +0 -56
- khoj/interface/web/agent.html +0 -312
- khoj/interface/web/agents.html +0 -276
- khoj/interface/web/assets/icons/cancel.svg +0 -3
- khoj/interface/web/assets/icons/collapse.svg +0 -17
- khoj/interface/web/assets/icons/computer.png +0 -0
- khoj/interface/web/assets/icons/confirm-icon.svg +0 -1
- khoj/interface/web/assets/icons/copy-button-success.svg +0 -6
- khoj/interface/web/assets/icons/copy-button.svg +0 -5
- khoj/interface/web/assets/icons/credit-card.png +0 -0
- khoj/interface/web/assets/icons/delete.svg +0 -26
- khoj/interface/web/assets/icons/docx.svg +0 -7
- khoj/interface/web/assets/icons/edit.svg +0 -4
- khoj/interface/web/assets/icons/key.svg +0 -4
- khoj/interface/web/assets/icons/markdown.svg +0 -1
- khoj/interface/web/assets/icons/new.svg +0 -23
- khoj/interface/web/assets/icons/notion.svg +0 -4
- khoj/interface/web/assets/icons/openai-logomark.svg +0 -1
- khoj/interface/web/assets/icons/org.svg +0 -1
- khoj/interface/web/assets/icons/pdf.svg +0 -23
- khoj/interface/web/assets/icons/pencil-edit.svg +0 -5
- khoj/interface/web/assets/icons/plaintext.svg +0 -1
- khoj/interface/web/assets/icons/question-mark-icon.svg +0 -1
- khoj/interface/web/assets/icons/send.svg +0 -1
- khoj/interface/web/assets/icons/share.svg +0 -8
- khoj/interface/web/assets/icons/speaker.svg +0 -4
- khoj/interface/web/assets/icons/stop-solid.svg +0 -37
- khoj/interface/web/assets/icons/thumbs-down-svgrepo-com.svg +0 -6
- khoj/interface/web/assets/icons/thumbs-up-svgrepo-com.svg +0 -6
- khoj/interface/web/assets/icons/user-silhouette.svg +0 -4
- khoj/interface/web/assets/icons/voice.svg +0 -8
- khoj/interface/web/assets/icons/web.svg +0 -2
- khoj/interface/web/assets/icons/whatsapp.svg +0 -17
- khoj/interface/web/assets/markdown-it.min.js +0 -8476
- khoj/interface/web/assets/natural-cron.min.js +0 -1
- khoj/interface/web/assets/org.min.js +0 -1823
- khoj/interface/web/assets/pico.min.css +0 -5
- khoj/interface/web/assets/purify.min.js +0 -3
- khoj/interface/web/chat.html +0 -3436
- khoj/interface/web/config_automation.html +0 -1103
- khoj/interface/web/content_source_computer_input.html +0 -139
- khoj/interface/web/content_source_notion_input.html +0 -94
- khoj/interface/web/public_conversation.html +0 -2006
- khoj/interface/web/search.html +0 -470
- khoj/interface/web/settings.html +0 -1011
- {khoj-1.17.1.dev223.dist-info → khoj-1.20.1.dev1.dist-info}/WHEEL +0 -0
- {khoj-1.17.1.dev223.dist-info → khoj-1.20.1.dev1.dist-info}/entry_points.txt +0 -0
- {khoj-1.17.1.dev223.dist-info → khoj-1.20.1.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,1823 +0,0 @@
|
|
|
1
|
-
// Generated by export.rb at Sat Feb 21 07:44:29 UTC 2015
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2014 Masafumi Oyamada
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
var Org = (function () {
|
|
25
|
-
var exports = {};
|
|
26
|
-
|
|
27
|
-
// ------------------------------------------------------------
|
|
28
|
-
// Syntax
|
|
29
|
-
// ------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
var Syntax = {
|
|
32
|
-
rules: {},
|
|
33
|
-
|
|
34
|
-
define: function (name, syntax) {
|
|
35
|
-
this.rules[name] = syntax;
|
|
36
|
-
var methodName = "is" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
|
37
|
-
this[methodName] = function (line) {
|
|
38
|
-
return this.rules[name].exec(line);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
Syntax.define("header", /^(\*+)\s+(.*)$/); // m[1] => level, m[2] => content
|
|
44
|
-
Syntax.define("preformatted", /^(\s*):(?: (.*)$|$)/); // m[1] => indentation, m[2] => content
|
|
45
|
-
Syntax.define("unorderedListElement", /^(\s*)(?:-|\+|\s+\*)\s+(.*)$/); // m[1] => indentation, m[2] => content
|
|
46
|
-
Syntax.define("orderedListElement", /^(\s*)(\d+)(?:\.|\))\s+(.*)$/); // m[1] => indentation, m[2] => number, m[3] => content
|
|
47
|
-
Syntax.define("tableSeparator", /^(\s*)\|((?:\+|-)*?)\|?$/); // m[1] => indentation, m[2] => content
|
|
48
|
-
Syntax.define("tableRow", /^(\s*)\|(.*?)\|?$/); // m[1] => indentation, m[2] => content
|
|
49
|
-
Syntax.define("blank", /^$/);
|
|
50
|
-
Syntax.define("horizontalRule", /^(\s*)-{5,}$/); //
|
|
51
|
-
Syntax.define("directive", /^(\s*)#\+(?:(begin|end)_)?(.*)$/i); // m[1] => indentation, m[2] => type, m[3] => content
|
|
52
|
-
Syntax.define("comment", /^(\s*)#(.*)$/);
|
|
53
|
-
Syntax.define("line", /^(\s*)(.*)$/);
|
|
54
|
-
|
|
55
|
-
const propertyDrawer = /:PROPERTIES:(.*):END:/g;
|
|
56
|
-
|
|
57
|
-
// ------------------------------------------------------------
|
|
58
|
-
// Token
|
|
59
|
-
// ------------------------------------------------------------
|
|
60
|
-
|
|
61
|
-
function Token() {
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Token.prototype = {
|
|
65
|
-
isListElement: function () {
|
|
66
|
-
return this.type === Lexer.tokens.orderedListElement ||
|
|
67
|
-
this.type === Lexer.tokens.unorderedListElement;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
isTableElement: function () {
|
|
71
|
-
return this.type === Lexer.tokens.tableSeparator ||
|
|
72
|
-
this.type === Lexer.tokens.tableRow;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ------------------------------------------------------------
|
|
77
|
-
// Lexer
|
|
78
|
-
// ------------------------------------------------------------
|
|
79
|
-
|
|
80
|
-
function Lexer(stream) {
|
|
81
|
-
this.stream = stream;
|
|
82
|
-
this.tokenStack = [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Lexer.prototype = {
|
|
86
|
-
tokenize: function (line) {
|
|
87
|
-
var token = new Token();
|
|
88
|
-
token.fromLineNumber = this.stream.lineNumber;
|
|
89
|
-
|
|
90
|
-
if (Syntax.isHeader(line)) {
|
|
91
|
-
token.type = Lexer.tokens.header;
|
|
92
|
-
token.indentation = 0;
|
|
93
|
-
token.content = RegExp.$2;
|
|
94
|
-
// specific
|
|
95
|
-
token.level = 2;
|
|
96
|
-
} else if (Syntax.isPreformatted(line)) {
|
|
97
|
-
token.type = Lexer.tokens.preformatted;
|
|
98
|
-
token.indentation = RegExp.$1.length;
|
|
99
|
-
token.content = RegExp.$2;
|
|
100
|
-
} else if (Syntax.isUnorderedListElement(line)) {
|
|
101
|
-
token.type = Lexer.tokens.unorderedListElement;
|
|
102
|
-
token.indentation = RegExp.$1.length;
|
|
103
|
-
token.content = RegExp.$2;
|
|
104
|
-
} else if (Syntax.isOrderedListElement(line)) {
|
|
105
|
-
token.type = Lexer.tokens.orderedListElement;
|
|
106
|
-
token.indentation = RegExp.$1.length;
|
|
107
|
-
token.content = RegExp.$3;
|
|
108
|
-
// specific
|
|
109
|
-
token.number = RegExp.$2;
|
|
110
|
-
} else if (Syntax.isTableSeparator(line)) {
|
|
111
|
-
token.type = Lexer.tokens.tableSeparator;
|
|
112
|
-
token.indentation = RegExp.$1.length;
|
|
113
|
-
token.content = RegExp.$2;
|
|
114
|
-
} else if (Syntax.isTableRow(line)) {
|
|
115
|
-
token.type = Lexer.tokens.tableRow;
|
|
116
|
-
token.indentation = RegExp.$1.length;
|
|
117
|
-
token.content = RegExp.$2;
|
|
118
|
-
} else if (Syntax.isBlank(line)) {
|
|
119
|
-
token.type = Lexer.tokens.blank;
|
|
120
|
-
token.indentation = 0;
|
|
121
|
-
token.content = null;
|
|
122
|
-
} else if (Syntax.isHorizontalRule(line)) {
|
|
123
|
-
token.type = Lexer.tokens.horizontalRule;
|
|
124
|
-
token.indentation = RegExp.$1.length;
|
|
125
|
-
token.content = null;
|
|
126
|
-
} else if (Syntax.isDirective(line)) {
|
|
127
|
-
token.type = Lexer.tokens.directive;
|
|
128
|
-
token.indentation = RegExp.$1.length;
|
|
129
|
-
token.content = RegExp.$3;
|
|
130
|
-
// decide directive type (begin, end or oneshot)
|
|
131
|
-
var directiveTypeString = RegExp.$2;
|
|
132
|
-
if (/^begin/i.test(directiveTypeString))
|
|
133
|
-
token.beginDirective = true;
|
|
134
|
-
else if (/^end/i.test(directiveTypeString))
|
|
135
|
-
token.endDirective = true;
|
|
136
|
-
else
|
|
137
|
-
token.oneshotDirective = true;
|
|
138
|
-
} else if (Syntax.isComment(line)) {
|
|
139
|
-
token.type = Lexer.tokens.comment;
|
|
140
|
-
token.indentation = RegExp.$1.length;
|
|
141
|
-
token.content = RegExp.$2;
|
|
142
|
-
} else if (Syntax.isLine(line)) {
|
|
143
|
-
token.type = Lexer.tokens.line;
|
|
144
|
-
token.indentation = RegExp.$1.length;
|
|
145
|
-
token.content = RegExp.$2;
|
|
146
|
-
} else {
|
|
147
|
-
throw new Error("SyntaxError: Unknown line: " + line);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return token;
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
pushToken: function (token) {
|
|
154
|
-
this.tokenStack.push(token);
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
pushDummyTokenByType: function (type) {
|
|
158
|
-
var token = new Token();
|
|
159
|
-
token.type = type;
|
|
160
|
-
this.tokenStack.push(token);
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
peekStackedToken: function () {
|
|
164
|
-
return this.tokenStack.length > 0 ?
|
|
165
|
-
this.tokenStack[this.tokenStack.length - 1] : null;
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
getStackedToken: function () {
|
|
169
|
-
return this.tokenStack.length > 0 ?
|
|
170
|
-
this.tokenStack.pop() : null;
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
peekNextToken: function () {
|
|
174
|
-
return this.peekStackedToken() ||
|
|
175
|
-
this.tokenize(this.stream.peekNextLine());
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
getNextToken: function () {
|
|
179
|
-
return this.getStackedToken() ||
|
|
180
|
-
this.tokenize(this.stream.getNextLine());
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
hasNext: function () {
|
|
184
|
-
return this.stream.hasNext();
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
getLineNumber: function () {
|
|
188
|
-
return this.stream.lineNumber;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
Lexer.tokens = {};
|
|
193
|
-
[
|
|
194
|
-
"header",
|
|
195
|
-
"orderedListElement",
|
|
196
|
-
"unorderedListElement",
|
|
197
|
-
"tableRow",
|
|
198
|
-
"tableSeparator",
|
|
199
|
-
"preformatted",
|
|
200
|
-
"line",
|
|
201
|
-
"horizontalRule",
|
|
202
|
-
"blank",
|
|
203
|
-
"directive",
|
|
204
|
-
"comment"
|
|
205
|
-
].forEach(function (tokenName, i) {
|
|
206
|
-
Lexer.tokens[tokenName] = i;
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// ------------------------------------------------------------
|
|
210
|
-
// Exports
|
|
211
|
-
// ------------------------------------------------------------
|
|
212
|
-
|
|
213
|
-
if (typeof exports !== "undefined")
|
|
214
|
-
exports.Lexer = Lexer;
|
|
215
|
-
|
|
216
|
-
function PrototypeNode(type, children) {
|
|
217
|
-
this.type = type;
|
|
218
|
-
this.children = [];
|
|
219
|
-
|
|
220
|
-
if (children) {
|
|
221
|
-
for (var i = 0, len = children.length; i < len; ++i) {
|
|
222
|
-
this.appendChild(children[i]);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
PrototypeNode.prototype = {
|
|
227
|
-
previousSibling: null,
|
|
228
|
-
parent: null,
|
|
229
|
-
get firstChild() {
|
|
230
|
-
return this.children.length < 1 ?
|
|
231
|
-
null : this.children[0];
|
|
232
|
-
},
|
|
233
|
-
get lastChild() {
|
|
234
|
-
return this.children.length < 1 ?
|
|
235
|
-
null : this.children[this.children.length - 1];
|
|
236
|
-
},
|
|
237
|
-
appendChild: function (newChild) {
|
|
238
|
-
var previousSibling = this.children.length < 1 ?
|
|
239
|
-
null : this.lastChild;
|
|
240
|
-
this.children.push(newChild);
|
|
241
|
-
newChild.previousSibling = previousSibling;
|
|
242
|
-
newChild.parent = this;
|
|
243
|
-
},
|
|
244
|
-
toString: function () {
|
|
245
|
-
var string = "<" + this.type + ">";
|
|
246
|
-
|
|
247
|
-
if (typeof this.value !== "undefined") {
|
|
248
|
-
string += " " + this.value;
|
|
249
|
-
} else if (this.children) {
|
|
250
|
-
string += "\n" + this.children.map(function (child, idx) {
|
|
251
|
-
return "#" + idx + " " + child.toString();
|
|
252
|
-
}).join("\n").split("\n").map(function (line) {
|
|
253
|
-
return " " + line;
|
|
254
|
-
}).join("\n");
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return string;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
var Node = {
|
|
262
|
-
types: {},
|
|
263
|
-
|
|
264
|
-
define: function (name, postProcess) {
|
|
265
|
-
this.types[name] = name;
|
|
266
|
-
|
|
267
|
-
var methodName = "create" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
|
268
|
-
var postProcessGiven = typeof postProcess === "function";
|
|
269
|
-
|
|
270
|
-
this[methodName] = function (children, options) {
|
|
271
|
-
var node = new PrototypeNode(name, children);
|
|
272
|
-
|
|
273
|
-
if (postProcessGiven)
|
|
274
|
-
postProcess(node, options || {});
|
|
275
|
-
|
|
276
|
-
return node;
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
Node.define("text", function (node, options) {
|
|
282
|
-
node.value = options.value;
|
|
283
|
-
});
|
|
284
|
-
Node.define("header", function (node, options) {
|
|
285
|
-
node.level = options.level;
|
|
286
|
-
});
|
|
287
|
-
Node.define("orderedList");
|
|
288
|
-
Node.define("unorderedList");
|
|
289
|
-
Node.define("definitionList");
|
|
290
|
-
Node.define("listElement");
|
|
291
|
-
Node.define("paragraph");
|
|
292
|
-
Node.define("preformatted");
|
|
293
|
-
Node.define("table");
|
|
294
|
-
Node.define("tableRow");
|
|
295
|
-
Node.define("tableCell");
|
|
296
|
-
Node.define("horizontalRule");
|
|
297
|
-
Node.define("directive");
|
|
298
|
-
|
|
299
|
-
// Inline
|
|
300
|
-
Node.define("inlineContainer");
|
|
301
|
-
|
|
302
|
-
Node.define("bold");
|
|
303
|
-
Node.define("italic");
|
|
304
|
-
Node.define("underline");
|
|
305
|
-
Node.define("code");
|
|
306
|
-
Node.define("verbatim");
|
|
307
|
-
Node.define("dashed");
|
|
308
|
-
Node.define("link", function (node, options) {
|
|
309
|
-
node.src = options.src;
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
if (typeof exports !== "undefined")
|
|
313
|
-
exports.Node = Node;
|
|
314
|
-
|
|
315
|
-
function Stream(sequence) {
|
|
316
|
-
this.sequences = sequence.split(/\r?\n/);
|
|
317
|
-
this.totalLines = this.sequences.length;
|
|
318
|
-
this.lineNumber = 0;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
Stream.prototype.peekNextLine = function () {
|
|
322
|
-
return this.hasNext() ? this.sequences[this.lineNumber] : null;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
Stream.prototype.getNextLine = function () {
|
|
326
|
-
return this.hasNext() ? this.sequences[this.lineNumber++] : null;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
Stream.prototype.hasNext = function () {
|
|
330
|
-
return this.lineNumber < this.totalLines;
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
if (typeof exports !== "undefined") {
|
|
334
|
-
exports.Stream = Stream;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// var Stream = require("./stream.js").Stream;
|
|
338
|
-
// var Lexer = require("./lexer.js").Lexer;
|
|
339
|
-
// var Node = require("./node.js").Node;
|
|
340
|
-
|
|
341
|
-
function Parser() {
|
|
342
|
-
this.inlineParser = new InlineParser();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
Parser.parseStream = function (stream, options) {
|
|
346
|
-
var parser = new Parser();
|
|
347
|
-
parser.initStatus(stream, options);
|
|
348
|
-
parser.parseNodes();
|
|
349
|
-
return parser.nodes;
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
Parser.prototype = {
|
|
353
|
-
initStatus: function (stream, options) {
|
|
354
|
-
if (typeof stream === "string")
|
|
355
|
-
stream = new Stream(stream);
|
|
356
|
-
this.lexer = new Lexer(stream);
|
|
357
|
-
this.nodes = [];
|
|
358
|
-
this.options = {
|
|
359
|
-
toc: true,
|
|
360
|
-
num: true,
|
|
361
|
-
"^": "{}",
|
|
362
|
-
multilineCell: false
|
|
363
|
-
};
|
|
364
|
-
// Override option values
|
|
365
|
-
if (options && typeof options === "object") {
|
|
366
|
-
for (var key in options) {
|
|
367
|
-
this.options[key] = options[key];
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
this.document = {
|
|
371
|
-
options: this.options,
|
|
372
|
-
directiveValues: {},
|
|
373
|
-
convert: function (ConverterClass, exportOptions) {
|
|
374
|
-
var converter = new ConverterClass(this, exportOptions);
|
|
375
|
-
return converter.result;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
|
|
380
|
-
parse: function (stream, options) {
|
|
381
|
-
this.initStatus(stream, options);
|
|
382
|
-
this.parseDocument();
|
|
383
|
-
this.document.nodes = this.nodes;
|
|
384
|
-
return this.document;
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
createErrorReport: function (message) {
|
|
388
|
-
return new Error(message + " at line " + this.lexer.getLineNumber());
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
skipBlank: function () {
|
|
392
|
-
var blankToken = null;
|
|
393
|
-
while (this.lexer.peekNextToken().type === Lexer.tokens.blank)
|
|
394
|
-
blankToken = this.lexer.getNextToken();
|
|
395
|
-
return blankToken;
|
|
396
|
-
},
|
|
397
|
-
|
|
398
|
-
setNodeOriginFromToken: function (node, token) {
|
|
399
|
-
node.fromLineNumber = token.fromLineNumber;
|
|
400
|
-
return node;
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
appendNode: function (newNode) {
|
|
404
|
-
var previousSibling = this.nodes.length > 0 ? this.nodes[this.nodes.length - 1] : null;
|
|
405
|
-
this.nodes.push(newNode);
|
|
406
|
-
newNode.previousSibling = previousSibling;
|
|
407
|
-
},
|
|
408
|
-
|
|
409
|
-
// ------------------------------------------------------------
|
|
410
|
-
// <Document> ::= <Element>*
|
|
411
|
-
// ------------------------------------------------------------
|
|
412
|
-
|
|
413
|
-
parseDocument: function () {
|
|
414
|
-
this.parseTitle();
|
|
415
|
-
this.parseNodes();
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
parseNodes: function () {
|
|
419
|
-
while (this.lexer.hasNext()) {
|
|
420
|
-
var element = this.parseElement();
|
|
421
|
-
if (element) this.appendNode(element);
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
|
|
425
|
-
parseTitle: function () {
|
|
426
|
-
this.skipBlank();
|
|
427
|
-
|
|
428
|
-
if (this.lexer.hasNext() &&
|
|
429
|
-
this.lexer.peekNextToken().type === Lexer.tokens.line)
|
|
430
|
-
this.document.title = this.createTextNode(this.lexer.getNextToken().content);
|
|
431
|
-
else
|
|
432
|
-
this.document.title = null;
|
|
433
|
-
|
|
434
|
-
this.lexer.pushDummyTokenByType(Lexer.tokens.blank);
|
|
435
|
-
},
|
|
436
|
-
|
|
437
|
-
// ------------------------------------------------------------
|
|
438
|
-
// <Element> ::= (<Header> | <List>
|
|
439
|
-
// | <Preformatted> | <Paragraph>
|
|
440
|
-
// | <Table>)*
|
|
441
|
-
// ------------------------------------------------------------
|
|
442
|
-
|
|
443
|
-
parseElement: function () {
|
|
444
|
-
var element = null;
|
|
445
|
-
|
|
446
|
-
switch (this.lexer.peekNextToken().type) {
|
|
447
|
-
case Lexer.tokens.header:
|
|
448
|
-
element = this.parseHeader();
|
|
449
|
-
break;
|
|
450
|
-
case Lexer.tokens.preformatted:
|
|
451
|
-
element = this.parsePreformatted();
|
|
452
|
-
break;
|
|
453
|
-
case Lexer.tokens.orderedListElement:
|
|
454
|
-
case Lexer.tokens.unorderedListElement:
|
|
455
|
-
element = this.parseList();
|
|
456
|
-
break;
|
|
457
|
-
case Lexer.tokens.line:
|
|
458
|
-
element = this.parseText();
|
|
459
|
-
break;
|
|
460
|
-
case Lexer.tokens.tableRow:
|
|
461
|
-
case Lexer.tokens.tableSeparator:
|
|
462
|
-
element = this.parseTable();
|
|
463
|
-
break;
|
|
464
|
-
case Lexer.tokens.blank:
|
|
465
|
-
this.skipBlank();
|
|
466
|
-
if (this.lexer.hasNext()) {
|
|
467
|
-
if (this.lexer.peekNextToken().type === Lexer.tokens.line)
|
|
468
|
-
element = this.parseParagraph();
|
|
469
|
-
else
|
|
470
|
-
element = this.parseElement();
|
|
471
|
-
}
|
|
472
|
-
break;
|
|
473
|
-
case Lexer.tokens.horizontalRule:
|
|
474
|
-
this.lexer.getNextToken();
|
|
475
|
-
element = Node.createHorizontalRule();
|
|
476
|
-
break;
|
|
477
|
-
case Lexer.tokens.directive:
|
|
478
|
-
element = this.parseDirective();
|
|
479
|
-
break;
|
|
480
|
-
case Lexer.tokens.comment:
|
|
481
|
-
// Skip
|
|
482
|
-
this.lexer.getNextToken();
|
|
483
|
-
break;
|
|
484
|
-
default:
|
|
485
|
-
throw this.createErrorReport("Unhandled token: " + this.lexer.peekNextToken().type);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
return element;
|
|
489
|
-
},
|
|
490
|
-
|
|
491
|
-
parseElementBesidesDirectiveEnd: function () {
|
|
492
|
-
try {
|
|
493
|
-
// Temporary, override the definition of `parseElement`
|
|
494
|
-
this.parseElement = this.parseElementBesidesDirectiveEndBody;
|
|
495
|
-
return this.parseElement();
|
|
496
|
-
} finally {
|
|
497
|
-
this.parseElement = this.originalParseElement;
|
|
498
|
-
}
|
|
499
|
-
},
|
|
500
|
-
|
|
501
|
-
parseElementBesidesDirectiveEndBody: function () {
|
|
502
|
-
if (this.lexer.peekNextToken().type === Lexer.tokens.directive &&
|
|
503
|
-
this.lexer.peekNextToken().endDirective) {
|
|
504
|
-
return null;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
return this.originalParseElement();
|
|
508
|
-
},
|
|
509
|
-
|
|
510
|
-
// ------------------------------------------------------------
|
|
511
|
-
// <Header>
|
|
512
|
-
//
|
|
513
|
-
// : preformatted
|
|
514
|
-
// : block
|
|
515
|
-
// ------------------------------------------------------------
|
|
516
|
-
|
|
517
|
-
parseHeader: function () {
|
|
518
|
-
var headerToken = this.lexer.getNextToken();
|
|
519
|
-
var header = Node.createHeader([
|
|
520
|
-
this.createTextNode(headerToken.content) // TODO: Parse inline markups
|
|
521
|
-
], { level: headerToken.level });
|
|
522
|
-
this.setNodeOriginFromToken(header, headerToken);
|
|
523
|
-
|
|
524
|
-
return header;
|
|
525
|
-
},
|
|
526
|
-
|
|
527
|
-
// ------------------------------------------------------------
|
|
528
|
-
// <Preformatted>
|
|
529
|
-
//
|
|
530
|
-
// : preformatted
|
|
531
|
-
// : block
|
|
532
|
-
// ------------------------------------------------------------
|
|
533
|
-
|
|
534
|
-
parsePreformatted: function () {
|
|
535
|
-
var preformattedFirstToken = this.lexer.peekNextToken();
|
|
536
|
-
var preformatted = Node.createPreformatted([]);
|
|
537
|
-
this.setNodeOriginFromToken(preformatted, preformattedFirstToken);
|
|
538
|
-
|
|
539
|
-
var textContents = [];
|
|
540
|
-
|
|
541
|
-
while (this.lexer.hasNext()) {
|
|
542
|
-
var token = this.lexer.peekNextToken();
|
|
543
|
-
if (token.type !== Lexer.tokens.preformatted ||
|
|
544
|
-
token.indentation < preformattedFirstToken.indentation)
|
|
545
|
-
break;
|
|
546
|
-
this.lexer.getNextToken();
|
|
547
|
-
textContents.push(token.content);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
preformatted.appendChild(this.createTextNode(textContents.join("\n"), true /* no emphasis */));
|
|
551
|
-
|
|
552
|
-
return preformatted;
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
// ------------------------------------------------------------
|
|
556
|
-
// <List>
|
|
557
|
-
//
|
|
558
|
-
// - foo
|
|
559
|
-
// 1. bar
|
|
560
|
-
// 2. baz
|
|
561
|
-
// ------------------------------------------------------------
|
|
562
|
-
|
|
563
|
-
// XXX: not consider codes (e.g., =Foo::Bar=)
|
|
564
|
-
definitionPattern: /^(.*?) :: *(.*)$/,
|
|
565
|
-
|
|
566
|
-
parseList: function () {
|
|
567
|
-
var rootToken = this.lexer.peekNextToken();
|
|
568
|
-
var list;
|
|
569
|
-
var isDefinitionList = false;
|
|
570
|
-
|
|
571
|
-
if (this.definitionPattern.test(rootToken.content)) {
|
|
572
|
-
list = Node.createDefinitionList([]);
|
|
573
|
-
isDefinitionList = true;
|
|
574
|
-
} else {
|
|
575
|
-
list = rootToken.type === Lexer.tokens.unorderedListElement ?
|
|
576
|
-
Node.createUnorderedList([]) : Node.createOrderedList([]);
|
|
577
|
-
}
|
|
578
|
-
this.setNodeOriginFromToken(list, rootToken);
|
|
579
|
-
|
|
580
|
-
while (this.lexer.hasNext()) {
|
|
581
|
-
var nextToken = this.lexer.peekNextToken();
|
|
582
|
-
if (!nextToken.isListElement() || nextToken.indentation !== rootToken.indentation)
|
|
583
|
-
break;
|
|
584
|
-
list.appendChild(this.parseListElement(rootToken.indentation, isDefinitionList));
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
return list;
|
|
588
|
-
},
|
|
589
|
-
|
|
590
|
-
unknownDefinitionTerm: "???",
|
|
591
|
-
|
|
592
|
-
parseListElement: function (rootIndentation, isDefinitionList) {
|
|
593
|
-
var listElementToken = this.lexer.getNextToken();
|
|
594
|
-
var listElement = Node.createListElement([]);
|
|
595
|
-
this.setNodeOriginFromToken(listElement, listElementToken);
|
|
596
|
-
|
|
597
|
-
listElement.isDefinitionList = isDefinitionList;
|
|
598
|
-
|
|
599
|
-
if (isDefinitionList) {
|
|
600
|
-
var match = this.definitionPattern.exec(listElementToken.content);
|
|
601
|
-
listElement.term = [
|
|
602
|
-
this.createTextNode(match && match[1] ? match[1] : this.unknownDefinitionTerm)
|
|
603
|
-
];
|
|
604
|
-
listElement.appendChild(this.createTextNode(match ? match[2] : listElementToken.content));
|
|
605
|
-
} else {
|
|
606
|
-
listElement.appendChild(this.createTextNode(listElementToken.content));
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
while (this.lexer.hasNext()) {
|
|
610
|
-
var blankToken = this.skipBlank();
|
|
611
|
-
if (!this.lexer.hasNext())
|
|
612
|
-
break;
|
|
613
|
-
|
|
614
|
-
var notBlankNextToken = this.lexer.peekNextToken();
|
|
615
|
-
if (blankToken && !notBlankNextToken.isListElement())
|
|
616
|
-
this.lexer.pushToken(blankToken); // Recover blank token only when next line is not listElement.
|
|
617
|
-
// End of the list if hit less indented line or end of directive
|
|
618
|
-
if (notBlankNextToken.indentation <= rootIndentation ||
|
|
619
|
-
(notBlankNextToken.type === Lexer.tokens.directive && notBlankNextToken.endDirective))
|
|
620
|
-
break;
|
|
621
|
-
|
|
622
|
-
var element = this.parseElement(); // recursive
|
|
623
|
-
if (element)
|
|
624
|
-
listElement.appendChild(element);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
return listElement;
|
|
628
|
-
},
|
|
629
|
-
|
|
630
|
-
// ------------------------------------------------------------
|
|
631
|
-
// <Table> ::= <TableRow>+
|
|
632
|
-
// ------------------------------------------------------------
|
|
633
|
-
|
|
634
|
-
parseTable: function () {
|
|
635
|
-
var nextToken = this.lexer.peekNextToken();
|
|
636
|
-
var table = Node.createTable([]);
|
|
637
|
-
this.setNodeOriginFromToken(table, nextToken);
|
|
638
|
-
var sawSeparator = false;
|
|
639
|
-
|
|
640
|
-
var allowMultilineCell = nextToken.type === Lexer.tokens.tableSeparator && this.options.multilineCell;
|
|
641
|
-
|
|
642
|
-
while (this.lexer.hasNext() &&
|
|
643
|
-
(nextToken = this.lexer.peekNextToken()).isTableElement()) {
|
|
644
|
-
if (nextToken.type === Lexer.tokens.tableRow) {
|
|
645
|
-
var tableRow = this.parseTableRow(allowMultilineCell);
|
|
646
|
-
table.appendChild(tableRow);
|
|
647
|
-
} else {
|
|
648
|
-
// Lexer.tokens.tableSeparator
|
|
649
|
-
sawSeparator = true;
|
|
650
|
-
this.lexer.getNextToken();
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
if (sawSeparator && table.children.length) {
|
|
655
|
-
table.children[0].children.forEach(function (cell) {
|
|
656
|
-
cell.isHeader = true;
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
return table;
|
|
661
|
-
},
|
|
662
|
-
|
|
663
|
-
// ------------------------------------------------------------
|
|
664
|
-
// <TableRow> ::= <TableCell>+
|
|
665
|
-
// ------------------------------------------------------------
|
|
666
|
-
|
|
667
|
-
parseTableRow: function (allowMultilineCell) {
|
|
668
|
-
var tableRowTokens = [];
|
|
669
|
-
|
|
670
|
-
while (this.lexer.peekNextToken().type === Lexer.tokens.tableRow) {
|
|
671
|
-
tableRowTokens.push(this.lexer.getNextToken());
|
|
672
|
-
if (!allowMultilineCell) {
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
if (!tableRowTokens.length) {
|
|
678
|
-
throw this.createErrorReport("Expected table row");
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
var firstTableRowToken = tableRowTokens.shift();
|
|
682
|
-
var tableCellTexts = firstTableRowToken.content.split("|");
|
|
683
|
-
|
|
684
|
-
tableRowTokens.forEach(function (rowToken) {
|
|
685
|
-
rowToken.content.split("|").forEach(function (cellText, cellIdx) {
|
|
686
|
-
tableCellTexts[cellIdx] = (tableCellTexts[cellIdx] || "") + "\n" + cellText;
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// TODO: Prepare two pathes: (1)
|
|
691
|
-
var tableCells = tableCellTexts.map(
|
|
692
|
-
// TODO: consider '|' escape?
|
|
693
|
-
function (text) {
|
|
694
|
-
return Node.createTableCell(Parser.parseStream(text));
|
|
695
|
-
}, this);
|
|
696
|
-
|
|
697
|
-
return this.setNodeOriginFromToken(Node.createTableRow(tableCells), firstTableRowToken);
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
// ------------------------------------------------------------
|
|
701
|
-
// <Directive> ::= "#+.*"
|
|
702
|
-
// ------------------------------------------------------------
|
|
703
|
-
|
|
704
|
-
parseDirective: function () {
|
|
705
|
-
var directiveToken = this.lexer.getNextToken();
|
|
706
|
-
var directiveNode = this.createDirectiveNodeFromToken(directiveToken);
|
|
707
|
-
|
|
708
|
-
if (directiveToken.endDirective)
|
|
709
|
-
throw this.createErrorReport("Unmatched 'end' directive for " + directiveNode.directiveName);
|
|
710
|
-
|
|
711
|
-
if (directiveToken.oneshotDirective) {
|
|
712
|
-
this.interpretDirective(directiveNode);
|
|
713
|
-
return directiveNode;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
if (!directiveToken.beginDirective)
|
|
717
|
-
throw this.createErrorReport("Invalid directive " + directiveNode.directiveName);
|
|
718
|
-
|
|
719
|
-
// Parse begin ~ end
|
|
720
|
-
directiveNode.children = [];
|
|
721
|
-
if (this.isVerbatimDirective(directiveNode))
|
|
722
|
-
return this.parseDirectiveBlockVerbatim(directiveNode);
|
|
723
|
-
else
|
|
724
|
-
return this.parseDirectiveBlock(directiveNode);
|
|
725
|
-
},
|
|
726
|
-
|
|
727
|
-
createDirectiveNodeFromToken: function (directiveToken) {
|
|
728
|
-
var matched = /^[ ]*([^ ]*)[ ]*(.*)[ ]*$/.exec(directiveToken.content);
|
|
729
|
-
|
|
730
|
-
var directiveNode = Node.createDirective(null);
|
|
731
|
-
this.setNodeOriginFromToken(directiveNode, directiveToken);
|
|
732
|
-
directiveNode.directiveName = matched[1].toLowerCase();
|
|
733
|
-
directiveNode.directiveArguments = this.parseDirectiveArguments(matched[2]);
|
|
734
|
-
directiveNode.directiveOptions = this.parseDirectiveOptions(matched[2]);
|
|
735
|
-
directiveNode.directiveRawValue = matched[2];
|
|
736
|
-
|
|
737
|
-
return directiveNode;
|
|
738
|
-
},
|
|
739
|
-
|
|
740
|
-
isVerbatimDirective: function (directiveNode) {
|
|
741
|
-
var directiveName = directiveNode.directiveName;
|
|
742
|
-
return directiveName === "src" || directiveName === "example" || directiveName === "html";
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
parseDirectiveBlock: function (directiveNode, verbatim) {
|
|
746
|
-
this.lexer.pushDummyTokenByType(Lexer.tokens.blank);
|
|
747
|
-
|
|
748
|
-
while (this.lexer.hasNext()) {
|
|
749
|
-
var nextToken = this.lexer.peekNextToken();
|
|
750
|
-
if (nextToken.type === Lexer.tokens.directive &&
|
|
751
|
-
nextToken.endDirective &&
|
|
752
|
-
this.createDirectiveNodeFromToken(nextToken).directiveName === directiveNode.directiveName) {
|
|
753
|
-
// Close directive
|
|
754
|
-
this.lexer.getNextToken();
|
|
755
|
-
return directiveNode;
|
|
756
|
-
}
|
|
757
|
-
var element = this.parseElementBesidesDirectiveEnd();
|
|
758
|
-
if (element)
|
|
759
|
-
directiveNode.appendChild(element);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
throw this.createErrorReport("Unclosed directive " + directiveNode.directiveName);
|
|
763
|
-
},
|
|
764
|
-
|
|
765
|
-
parseDirectiveBlockVerbatim: function (directiveNode) {
|
|
766
|
-
var textContent = [];
|
|
767
|
-
|
|
768
|
-
while (this.lexer.hasNext()) {
|
|
769
|
-
var nextToken = this.lexer.peekNextToken();
|
|
770
|
-
if (nextToken.type === Lexer.tokens.directive &&
|
|
771
|
-
nextToken.endDirective &&
|
|
772
|
-
this.createDirectiveNodeFromToken(nextToken).directiveName === directiveNode.directiveName) {
|
|
773
|
-
this.lexer.getNextToken();
|
|
774
|
-
directiveNode.appendChild(this.createTextNode(textContent.join("\n"), true));
|
|
775
|
-
return directiveNode;
|
|
776
|
-
}
|
|
777
|
-
textContent.push(this.lexer.stream.getNextLine());
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
throw this.createErrorReport("Unclosed directive " + directiveNode.directiveName);
|
|
781
|
-
},
|
|
782
|
-
|
|
783
|
-
parseDirectiveArguments: function (parameters) {
|
|
784
|
-
return parameters.split(/[ ]+/).filter(function (param) {
|
|
785
|
-
return param.length && param[0] !== "-";
|
|
786
|
-
});
|
|
787
|
-
},
|
|
788
|
-
|
|
789
|
-
parseDirectiveOptions: function (parameters) {
|
|
790
|
-
return parameters.split(/[ ]+/).filter(function (param) {
|
|
791
|
-
return param.length && param[0] === "-";
|
|
792
|
-
});
|
|
793
|
-
},
|
|
794
|
-
|
|
795
|
-
interpretDirective: function (directiveNode) {
|
|
796
|
-
// http://orgmode.org/manual/Export-options.html
|
|
797
|
-
switch (directiveNode.directiveName) {
|
|
798
|
-
case "options:":
|
|
799
|
-
this.interpretOptionDirective(directiveNode);
|
|
800
|
-
break;
|
|
801
|
-
case "title:":
|
|
802
|
-
this.document.title = directiveNode.directiveRawValue;
|
|
803
|
-
break;
|
|
804
|
-
case "author:":
|
|
805
|
-
this.document.author = directiveNode.directiveRawValue;
|
|
806
|
-
break;
|
|
807
|
-
case "email:":
|
|
808
|
-
this.document.email = directiveNode.directiveRawValue;
|
|
809
|
-
break;
|
|
810
|
-
default:
|
|
811
|
-
this.document.directiveValues[directiveNode.directiveName] = directiveNode.directiveRawValue;
|
|
812
|
-
break;
|
|
813
|
-
}
|
|
814
|
-
},
|
|
815
|
-
|
|
816
|
-
interpretOptionDirective: function (optionDirectiveNode) {
|
|
817
|
-
optionDirectiveNode.directiveArguments.forEach(function (pairString) {
|
|
818
|
-
var pair = pairString.split(":");
|
|
819
|
-
this.options[pair[0]] = this.convertLispyValue(pair[1]);
|
|
820
|
-
}, this);
|
|
821
|
-
},
|
|
822
|
-
|
|
823
|
-
convertLispyValue: function (lispyValue) {
|
|
824
|
-
switch (lispyValue) {
|
|
825
|
-
case "t":
|
|
826
|
-
return true;
|
|
827
|
-
case "nil":
|
|
828
|
-
return false;
|
|
829
|
-
default:
|
|
830
|
-
if (/^[0-9]+$/.test(lispyValue))
|
|
831
|
-
return parseInt(lispyValue);
|
|
832
|
-
return lispyValue;
|
|
833
|
-
}
|
|
834
|
-
},
|
|
835
|
-
|
|
836
|
-
// ------------------------------------------------------------
|
|
837
|
-
// <Paragraph> ::= <Blank> <Line>*
|
|
838
|
-
// ------------------------------------------------------------
|
|
839
|
-
|
|
840
|
-
parseParagraph: function () {
|
|
841
|
-
var paragraphFisrtToken = this.lexer.peekNextToken();
|
|
842
|
-
var paragraph = Node.createParagraph([]);
|
|
843
|
-
this.setNodeOriginFromToken(paragraph, paragraphFisrtToken);
|
|
844
|
-
|
|
845
|
-
var textContents = [];
|
|
846
|
-
|
|
847
|
-
while (this.lexer.hasNext()) {
|
|
848
|
-
var nextToken = this.lexer.peekNextToken();
|
|
849
|
-
if (nextToken.type !== Lexer.tokens.line
|
|
850
|
-
|| nextToken.indentation < paragraphFisrtToken.indentation)
|
|
851
|
-
break;
|
|
852
|
-
this.lexer.getNextToken();
|
|
853
|
-
textContents.push(nextToken.content);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
paragraph.appendChild(this.createTextNode(textContents.join("\n")));
|
|
857
|
-
|
|
858
|
-
return paragraph;
|
|
859
|
-
},
|
|
860
|
-
|
|
861
|
-
parseText: function (noEmphasis) {
|
|
862
|
-
var lineToken = this.lexer.getNextToken();
|
|
863
|
-
return this.createTextNode(lineToken.content, noEmphasis);
|
|
864
|
-
},
|
|
865
|
-
|
|
866
|
-
// ------------------------------------------------------------
|
|
867
|
-
// <Text> (DOM Like)
|
|
868
|
-
// ------------------------------------------------------------
|
|
869
|
-
|
|
870
|
-
createTextNode: function (text, noEmphasis) {
|
|
871
|
-
return noEmphasis ? Node.createText(null, { value: text })
|
|
872
|
-
: this.inlineParser.parseEmphasis(text);
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
Parser.prototype.originalParseElement = Parser.prototype.parseElement;
|
|
876
|
-
|
|
877
|
-
// ------------------------------------------------------------
|
|
878
|
-
// Parser for Inline Elements
|
|
879
|
-
//
|
|
880
|
-
// @refs org-emphasis-regexp-components
|
|
881
|
-
// ------------------------------------------------------------
|
|
882
|
-
|
|
883
|
-
function InlineParser() {
|
|
884
|
-
this.preEmphasis = " \t\\('\"";
|
|
885
|
-
this.postEmphasis = "- \t.,:!?;'\"\\)";
|
|
886
|
-
this.borderForbidden = " \t\r\n,\"'";
|
|
887
|
-
this.bodyRegexp = "[\\s\\S]*?";
|
|
888
|
-
this.markers = "*/_=~+";
|
|
889
|
-
|
|
890
|
-
this.emphasisPattern = this.buildEmphasisPattern();
|
|
891
|
-
this.linkPattern = /\[\[([^\]]*)\](?:\[([^\]]*)\])?\]/g; // \1 => link, \2 => text
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
InlineParser.prototype = {
|
|
895
|
-
parseEmphasis: function (text) {
|
|
896
|
-
var emphasisPattern = this.emphasisPattern;
|
|
897
|
-
emphasisPattern.lastIndex = 0;
|
|
898
|
-
|
|
899
|
-
var result = [],
|
|
900
|
-
match,
|
|
901
|
-
previousLast = 0,
|
|
902
|
-
savedLastIndex;
|
|
903
|
-
|
|
904
|
-
while ((match = emphasisPattern.exec(text))) {
|
|
905
|
-
var whole = match[0];
|
|
906
|
-
var pre = match[1];
|
|
907
|
-
var marker = match[2];
|
|
908
|
-
var body = match[3];
|
|
909
|
-
var post = match[4];
|
|
910
|
-
|
|
911
|
-
{
|
|
912
|
-
// parse links
|
|
913
|
-
var matchBegin = emphasisPattern.lastIndex - whole.length;
|
|
914
|
-
var beforeContent = text.substring(previousLast, matchBegin + pre.length);
|
|
915
|
-
savedLastIndex = emphasisPattern.lastIndex;
|
|
916
|
-
result.push(this.parseLink(beforeContent));
|
|
917
|
-
emphasisPattern.lastIndex = savedLastIndex;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
var bodyNode = [Node.createText(null, { value: body })];
|
|
921
|
-
var bodyContainer = this.emphasizeElementByMarker(bodyNode, marker);
|
|
922
|
-
result.push(bodyContainer);
|
|
923
|
-
|
|
924
|
-
previousLast = emphasisPattern.lastIndex - post.length;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
if (emphasisPattern.lastIndex === 0 ||
|
|
928
|
-
emphasisPattern.lastIndex !== text.length - 1)
|
|
929
|
-
result.push(this.parseLink(text.substring(previousLast)));
|
|
930
|
-
|
|
931
|
-
if (result.length === 1) {
|
|
932
|
-
// Avoid duplicated inline container wrapping
|
|
933
|
-
return result[0];
|
|
934
|
-
} else {
|
|
935
|
-
return Node.createInlineContainer(result);
|
|
936
|
-
}
|
|
937
|
-
},
|
|
938
|
-
|
|
939
|
-
depth: 0,
|
|
940
|
-
parseLink: function (text) {
|
|
941
|
-
var linkPattern = this.linkPattern;
|
|
942
|
-
linkPattern.lastIndex = 0;
|
|
943
|
-
|
|
944
|
-
var match,
|
|
945
|
-
result = [],
|
|
946
|
-
previousLast = 0,
|
|
947
|
-
savedLastIndex;
|
|
948
|
-
|
|
949
|
-
while ((match = linkPattern.exec(text))) {
|
|
950
|
-
var whole = match[0];
|
|
951
|
-
var src = match[1];
|
|
952
|
-
var title = match[2];
|
|
953
|
-
|
|
954
|
-
// parse before content
|
|
955
|
-
var matchBegin = linkPattern.lastIndex - whole.length;
|
|
956
|
-
var beforeContent = text.substring(previousLast, matchBegin);
|
|
957
|
-
result.push(Node.createText(null, { value: beforeContent }));
|
|
958
|
-
|
|
959
|
-
// parse link
|
|
960
|
-
var link = Node.createLink([]);
|
|
961
|
-
link.src = src;
|
|
962
|
-
if (title) {
|
|
963
|
-
savedLastIndex = linkPattern.lastIndex;
|
|
964
|
-
link.appendChild(this.parseEmphasis(title));
|
|
965
|
-
linkPattern.lastIndex = savedLastIndex;
|
|
966
|
-
} else {
|
|
967
|
-
link.appendChild(Node.createText(null, { value: src }));
|
|
968
|
-
}
|
|
969
|
-
result.push(link);
|
|
970
|
-
|
|
971
|
-
previousLast = linkPattern.lastIndex;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
if (linkPattern.lastIndex === 0 ||
|
|
975
|
-
linkPattern.lastIndex !== text.length - 1)
|
|
976
|
-
result.push(Node.createText(null, { value: text.substring(previousLast) }));
|
|
977
|
-
|
|
978
|
-
return Node.createInlineContainer(result);
|
|
979
|
-
},
|
|
980
|
-
|
|
981
|
-
emphasizeElementByMarker: function (element, marker) {
|
|
982
|
-
switch (marker) {
|
|
983
|
-
case "*":
|
|
984
|
-
return Node.createBold(element);
|
|
985
|
-
case "/":
|
|
986
|
-
return Node.createItalic(element);
|
|
987
|
-
case "_":
|
|
988
|
-
return Node.createUnderline(element);
|
|
989
|
-
case "=":
|
|
990
|
-
case "~":
|
|
991
|
-
return Node.createCode(element);
|
|
992
|
-
case "+":
|
|
993
|
-
return Node.createDashed(element);
|
|
994
|
-
}
|
|
995
|
-
},
|
|
996
|
-
|
|
997
|
-
buildEmphasisPattern: function () {
|
|
998
|
-
return new RegExp(
|
|
999
|
-
"([" + this.preEmphasis + "]|^|\r?\n)" + // \1 => pre
|
|
1000
|
-
"([" + this.markers + "])" + // \2 => marker
|
|
1001
|
-
"([^" + this.borderForbidden + "]|" + // \3 => body
|
|
1002
|
-
"[^" + this.borderForbidden + "]" +
|
|
1003
|
-
this.bodyRegexp +
|
|
1004
|
-
"[^" + this.borderForbidden + "])" +
|
|
1005
|
-
"\\2" +
|
|
1006
|
-
"([" + this.postEmphasis +"]|$|\r?\n)", // \4 => post
|
|
1007
|
-
// flags
|
|
1008
|
-
"g"
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
if (typeof exports !== "undefined") {
|
|
1014
|
-
exports.Parser = Parser;
|
|
1015
|
-
exports.InlineParser = InlineParser;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
// var Node = require("../node.js").Node;
|
|
1019
|
-
|
|
1020
|
-
function Converter() {
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
Converter.prototype = {
|
|
1024
|
-
exportOptions: {
|
|
1025
|
-
headerOffset: 1,
|
|
1026
|
-
exportFromLineNumber: false,
|
|
1027
|
-
suppressSubScriptHandling: false,
|
|
1028
|
-
suppressAutoLink: false,
|
|
1029
|
-
// HTML
|
|
1030
|
-
translateSymbolArrow: false,
|
|
1031
|
-
suppressCheckboxHandling: false,
|
|
1032
|
-
// { "directive:": function (node, childText, auxData) {} }
|
|
1033
|
-
customDirectiveHandler: null,
|
|
1034
|
-
// e.g., "org-js-"
|
|
1035
|
-
htmlClassPrefix: null,
|
|
1036
|
-
htmlIdPrefix: null
|
|
1037
|
-
},
|
|
1038
|
-
|
|
1039
|
-
untitled: "Untitled",
|
|
1040
|
-
result: null,
|
|
1041
|
-
|
|
1042
|
-
// TODO: Manage TODO lists
|
|
1043
|
-
|
|
1044
|
-
initialize: function (orgDocument, exportOptions) {
|
|
1045
|
-
this.orgDocument = orgDocument;
|
|
1046
|
-
this.documentOptions = orgDocument.options || {};
|
|
1047
|
-
this.exportOptions = exportOptions || {};
|
|
1048
|
-
|
|
1049
|
-
this.headers = [];
|
|
1050
|
-
this.headerOffset =
|
|
1051
|
-
typeof this.exportOptions.headerOffset === "number" ? this.exportOptions.headerOffset : 1;
|
|
1052
|
-
this.sectionNumbers = [0];
|
|
1053
|
-
},
|
|
1054
|
-
|
|
1055
|
-
createTocItem: function (headerNode, parentTocs) {
|
|
1056
|
-
var childTocs = [];
|
|
1057
|
-
childTocs.parent = parentTocs;
|
|
1058
|
-
var tocItem = { headerNode: headerNode, childTocs: childTocs };
|
|
1059
|
-
return tocItem;
|
|
1060
|
-
},
|
|
1061
|
-
|
|
1062
|
-
computeToc: function (exportTocLevel) {
|
|
1063
|
-
if (typeof exportTocLevel !== "number")
|
|
1064
|
-
exportTocLevel = Infinity;
|
|
1065
|
-
|
|
1066
|
-
var toc = [];
|
|
1067
|
-
toc.parent = null;
|
|
1068
|
-
|
|
1069
|
-
var previousLevel = 1;
|
|
1070
|
-
var currentTocs = toc; // first
|
|
1071
|
-
|
|
1072
|
-
for (var i = 0; i < this.headers.length; ++i) {
|
|
1073
|
-
var headerNode = this.headers[i];
|
|
1074
|
-
|
|
1075
|
-
if (headerNode.level > exportTocLevel)
|
|
1076
|
-
continue;
|
|
1077
|
-
|
|
1078
|
-
var levelDiff = headerNode.level - previousLevel;
|
|
1079
|
-
if (levelDiff > 0) {
|
|
1080
|
-
for (var j = 0; j < levelDiff; ++j) {
|
|
1081
|
-
if (currentTocs.length === 0) {
|
|
1082
|
-
// Create a dummy tocItem
|
|
1083
|
-
var dummyHeader = Node.createHeader([], {
|
|
1084
|
-
level: previousLevel + j
|
|
1085
|
-
});
|
|
1086
|
-
dummyHeader.sectionNumberText = "";
|
|
1087
|
-
currentTocs.push(this.createTocItem(dummyHeader, currentTocs));
|
|
1088
|
-
}
|
|
1089
|
-
currentTocs = currentTocs[currentTocs.length - 1].childTocs;
|
|
1090
|
-
}
|
|
1091
|
-
} else if (levelDiff < 0) {
|
|
1092
|
-
levelDiff = -levelDiff;
|
|
1093
|
-
for (var k = 0; k < levelDiff; ++k) {
|
|
1094
|
-
currentTocs = currentTocs.parent;
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
currentTocs.push(this.createTocItem(headerNode, currentTocs));
|
|
1099
|
-
|
|
1100
|
-
previousLevel = headerNode.level;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
return toc;
|
|
1104
|
-
},
|
|
1105
|
-
|
|
1106
|
-
convertNode: function (node, recordHeader, insideCodeElement) {
|
|
1107
|
-
if (!insideCodeElement) {
|
|
1108
|
-
if (node.type === Node.types.directive) {
|
|
1109
|
-
if (node.directiveName === "example" ||
|
|
1110
|
-
node.directiveName === "src") {
|
|
1111
|
-
insideCodeElement = true;
|
|
1112
|
-
}
|
|
1113
|
-
} else if (node.type === Node.types.preformatted) {
|
|
1114
|
-
insideCodeElement = true;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
if (typeof node === "string") {
|
|
1119
|
-
node = Node.createText(null, { value: node });
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
var childText = node.children ? this.convertNodesInternal(node.children, recordHeader, insideCodeElement) : "";
|
|
1123
|
-
var text;
|
|
1124
|
-
|
|
1125
|
-
var auxData = this.computeAuxDataForNode(node);
|
|
1126
|
-
|
|
1127
|
-
switch (node.type) {
|
|
1128
|
-
case Node.types.header:
|
|
1129
|
-
// Compute section number
|
|
1130
|
-
var sectionNumberText = null;
|
|
1131
|
-
if (recordHeader) {
|
|
1132
|
-
var thisHeaderLevel = node.level;
|
|
1133
|
-
var previousHeaderLevel = this.sectionNumbers.length;
|
|
1134
|
-
if (thisHeaderLevel > previousHeaderLevel) {
|
|
1135
|
-
// Fill missing section number
|
|
1136
|
-
var levelDiff = thisHeaderLevel - previousHeaderLevel;
|
|
1137
|
-
for (var j = 0; j < levelDiff; ++j) {
|
|
1138
|
-
this.sectionNumbers[thisHeaderLevel - 1 - j] = 0; // Extend
|
|
1139
|
-
}
|
|
1140
|
-
} else if (thisHeaderLevel < previousHeaderLevel) {
|
|
1141
|
-
this.sectionNumbers.length = thisHeaderLevel; // Collapse
|
|
1142
|
-
}
|
|
1143
|
-
this.sectionNumbers[thisHeaderLevel - 1]++;
|
|
1144
|
-
sectionNumberText = this.sectionNumbers.join(".");
|
|
1145
|
-
node.sectionNumberText = sectionNumberText; // Can be used in ToC
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
text = this.convertHeader(node, childText, auxData, sectionNumberText);
|
|
1149
|
-
|
|
1150
|
-
if (recordHeader)
|
|
1151
|
-
this.headers.push(node);
|
|
1152
|
-
break;
|
|
1153
|
-
case Node.types.orderedList:
|
|
1154
|
-
text = this.convertOrderedList(node, childText, auxData);
|
|
1155
|
-
break;
|
|
1156
|
-
case Node.types.unorderedList:
|
|
1157
|
-
text = this.convertUnorderedList(node, childText, auxData);
|
|
1158
|
-
break;
|
|
1159
|
-
case Node.types.definitionList:
|
|
1160
|
-
text = this.convertDefinitionList(node, childText, auxData);
|
|
1161
|
-
break;
|
|
1162
|
-
case Node.types.listElement:
|
|
1163
|
-
if (node.isDefinitionList) {
|
|
1164
|
-
var termText = this.convertNodesInternal(node.term, recordHeader, insideCodeElement);
|
|
1165
|
-
text = this.convertDefinitionItem(node, childText, auxData,
|
|
1166
|
-
termText, childText);
|
|
1167
|
-
} else {
|
|
1168
|
-
text = this.convertListItem(node, childText, auxData);
|
|
1169
|
-
}
|
|
1170
|
-
break;
|
|
1171
|
-
case Node.types.paragraph:
|
|
1172
|
-
text = this.convertParagraph(node, childText, auxData);
|
|
1173
|
-
break;
|
|
1174
|
-
case Node.types.preformatted:
|
|
1175
|
-
text = this.convertPreformatted(node, childText, auxData);
|
|
1176
|
-
break;
|
|
1177
|
-
case Node.types.table:
|
|
1178
|
-
text = this.convertTable(node, childText, auxData);
|
|
1179
|
-
break;
|
|
1180
|
-
case Node.types.tableRow:
|
|
1181
|
-
text = this.convertTableRow(node, childText, auxData);
|
|
1182
|
-
break;
|
|
1183
|
-
case Node.types.tableCell:
|
|
1184
|
-
if (node.isHeader)
|
|
1185
|
-
text = this.convertTableHeader(node, childText, auxData);
|
|
1186
|
-
else
|
|
1187
|
-
text = this.convertTableCell(node, childText, auxData);
|
|
1188
|
-
break;
|
|
1189
|
-
case Node.types.horizontalRule:
|
|
1190
|
-
text = this.convertHorizontalRule(node, childText, auxData);
|
|
1191
|
-
break;
|
|
1192
|
-
// ============================================================ //
|
|
1193
|
-
// Inline
|
|
1194
|
-
// ============================================================ //
|
|
1195
|
-
case Node.types.inlineContainer:
|
|
1196
|
-
text = this.convertInlineContainer(node, childText, auxData);
|
|
1197
|
-
break;
|
|
1198
|
-
case Node.types.bold:
|
|
1199
|
-
text = this.convertBold(node, childText, auxData);
|
|
1200
|
-
break;
|
|
1201
|
-
case Node.types.italic:
|
|
1202
|
-
text = this.convertItalic(node, childText, auxData);
|
|
1203
|
-
break;
|
|
1204
|
-
case Node.types.underline:
|
|
1205
|
-
text = this.convertUnderline(node, childText, auxData);
|
|
1206
|
-
break;
|
|
1207
|
-
case Node.types.code:
|
|
1208
|
-
text = this.convertCode(node, childText, auxData);
|
|
1209
|
-
break;
|
|
1210
|
-
case Node.types.dashed:
|
|
1211
|
-
text = this.convertDashed(node, childText, auxData);
|
|
1212
|
-
break;
|
|
1213
|
-
case Node.types.link:
|
|
1214
|
-
text = this.convertLink(node, childText, auxData);
|
|
1215
|
-
break;
|
|
1216
|
-
case Node.types.directive:
|
|
1217
|
-
switch (node.directiveName) {
|
|
1218
|
-
case "quote":
|
|
1219
|
-
text = this.convertQuote(node, childText, auxData);
|
|
1220
|
-
break;
|
|
1221
|
-
case "example":
|
|
1222
|
-
text = this.convertExample(node, childText, auxData);
|
|
1223
|
-
break;
|
|
1224
|
-
case "src":
|
|
1225
|
-
text = this.convertSrc(node, childText, auxData);
|
|
1226
|
-
break;
|
|
1227
|
-
case "html":
|
|
1228
|
-
case "html:":
|
|
1229
|
-
text = this.convertHTML(node, childText, auxData);
|
|
1230
|
-
break;
|
|
1231
|
-
default:
|
|
1232
|
-
if (this.exportOptions.customDirectiveHandler &&
|
|
1233
|
-
this.exportOptions.customDirectiveHandler[node.directiveName]) {
|
|
1234
|
-
text = this.exportOptions.customDirectiveHandler[node.directiveName](
|
|
1235
|
-
node, childText, auxData
|
|
1236
|
-
);
|
|
1237
|
-
} else {
|
|
1238
|
-
text = childText;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
break;
|
|
1242
|
-
case Node.types.text:
|
|
1243
|
-
text = this.convertText(node.value, insideCodeElement);
|
|
1244
|
-
break;
|
|
1245
|
-
default:
|
|
1246
|
-
throw Error("Unknown node type: " + node.type);
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
if (typeof this.postProcess === "function") {
|
|
1250
|
-
text = this.postProcess(node, text, insideCodeElement);
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
return text;
|
|
1254
|
-
},
|
|
1255
|
-
|
|
1256
|
-
convertText: function (text, insideCodeElement) {
|
|
1257
|
-
var escapedText = this.escapeSpecialChars(text, insideCodeElement);
|
|
1258
|
-
|
|
1259
|
-
if (!this.exportOptions.suppressSubScriptHandling && !insideCodeElement) {
|
|
1260
|
-
escapedText = this.makeSubscripts(escapedText, insideCodeElement);
|
|
1261
|
-
}
|
|
1262
|
-
if (!this.exportOptions.suppressAutoLink) {
|
|
1263
|
-
escapedText = this.linkURL(escapedText);
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
return escapedText;
|
|
1267
|
-
},
|
|
1268
|
-
|
|
1269
|
-
// By default, ignore html
|
|
1270
|
-
convertHTML: function (node, childText, auxData) {
|
|
1271
|
-
return childText;
|
|
1272
|
-
},
|
|
1273
|
-
|
|
1274
|
-
convertNodesInternal: function (nodes, recordHeader, insideCodeElement) {
|
|
1275
|
-
var nodesTexts = [];
|
|
1276
|
-
for (var i = 0; i < nodes.length; ++i) {
|
|
1277
|
-
var node = nodes[i];
|
|
1278
|
-
var nodeText = this.convertNode(node, recordHeader, insideCodeElement);
|
|
1279
|
-
nodesTexts.push(nodeText);
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
// Return entries without their property drawers
|
|
1283
|
-
return this.combineNodesTexts(nodesTexts).replace(propertyDrawer, '');
|
|
1284
|
-
},
|
|
1285
|
-
|
|
1286
|
-
convertHeaderBlock: function (headerBlock, recordHeader) {
|
|
1287
|
-
throw Error("convertHeaderBlock is not implemented");
|
|
1288
|
-
},
|
|
1289
|
-
|
|
1290
|
-
convertHeaderTree: function (headerTree, recordHeader) {
|
|
1291
|
-
return this.convertHeaderBlock(headerTree, recordHeader);
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
convertNodesToHeaderTree: function (nodes, nextBlockBegin, blockHeader) {
|
|
1295
|
-
var childBlocks = [];
|
|
1296
|
-
var childNodes = [];
|
|
1297
|
-
|
|
1298
|
-
if (typeof nextBlockBegin === "undefined") {
|
|
1299
|
-
nextBlockBegin = 0;
|
|
1300
|
-
}
|
|
1301
|
-
if (typeof blockHeader === "undefined") {
|
|
1302
|
-
blockHeader = null;
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
for (var i = nextBlockBegin; i < nodes.length;) {
|
|
1306
|
-
var node = nodes[i];
|
|
1307
|
-
|
|
1308
|
-
var isHeader = node.type === Node.types.header;
|
|
1309
|
-
|
|
1310
|
-
if (!isHeader) {
|
|
1311
|
-
childNodes.push(node);
|
|
1312
|
-
i = i + 1;
|
|
1313
|
-
continue;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
// Header
|
|
1317
|
-
if (blockHeader && node.level <= blockHeader.level) {
|
|
1318
|
-
// Finish Block
|
|
1319
|
-
break;
|
|
1320
|
-
} else {
|
|
1321
|
-
// blockHeader.level < node.level
|
|
1322
|
-
// Begin child block
|
|
1323
|
-
var childBlock = this.convertNodesToHeaderTree(nodes, i + 1, node);
|
|
1324
|
-
childBlocks.push(childBlock);
|
|
1325
|
-
i = childBlock.nextIndex;
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
// Finish block
|
|
1330
|
-
return {
|
|
1331
|
-
header: blockHeader,
|
|
1332
|
-
childNodes: childNodes,
|
|
1333
|
-
nextIndex: i,
|
|
1334
|
-
childBlocks: childBlocks
|
|
1335
|
-
};
|
|
1336
|
-
},
|
|
1337
|
-
|
|
1338
|
-
convertNodes: function (nodes, recordHeader, insideCodeElement) {
|
|
1339
|
-
return this.convertNodesInternal(nodes, recordHeader, insideCodeElement);
|
|
1340
|
-
},
|
|
1341
|
-
|
|
1342
|
-
combineNodesTexts: function (nodesTexts) {
|
|
1343
|
-
return nodesTexts.join("");
|
|
1344
|
-
},
|
|
1345
|
-
|
|
1346
|
-
getNodeTextContent: function (node) {
|
|
1347
|
-
if (node.type === Node.types.text)
|
|
1348
|
-
return this.escapeSpecialChars(node.value);
|
|
1349
|
-
else
|
|
1350
|
-
return node.children ? node.children.map(this.getNodeTextContent, this).join("") : "";
|
|
1351
|
-
},
|
|
1352
|
-
|
|
1353
|
-
// @Override
|
|
1354
|
-
escapeSpecialChars: function (text) {
|
|
1355
|
-
throw Error("Implement escapeSpecialChars");
|
|
1356
|
-
},
|
|
1357
|
-
|
|
1358
|
-
// http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
|
1359
|
-
urlPattern: /\b(?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])/ig,
|
|
1360
|
-
|
|
1361
|
-
// @Override
|
|
1362
|
-
linkURL: function (text) {
|
|
1363
|
-
var self = this;
|
|
1364
|
-
return text.replace(this.urlPattern, function (matched) {
|
|
1365
|
-
if (matched.indexOf("://") < 0)
|
|
1366
|
-
matched = "http://" + matched;
|
|
1367
|
-
return self.makeLink(matched);
|
|
1368
|
-
});
|
|
1369
|
-
},
|
|
1370
|
-
|
|
1371
|
-
makeLink: function (url) {
|
|
1372
|
-
throw Error("Implement makeLink");
|
|
1373
|
-
},
|
|
1374
|
-
|
|
1375
|
-
makeSubscripts: function (text) {
|
|
1376
|
-
if (this.documentOptions["^"] === "{}")
|
|
1377
|
-
return text.replace(/\b([^_ \t]*)_{([^}]*)}/g,
|
|
1378
|
-
this.makeSubscript);
|
|
1379
|
-
else if (this.documentOptions["^"])
|
|
1380
|
-
return text.replace(/\b([^_ \t]*)_([^_]*)\b/g,
|
|
1381
|
-
this.makeSubscript);
|
|
1382
|
-
else
|
|
1383
|
-
return text;
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1386
|
-
makeSubscript: function (match, body, subscript) {
|
|
1387
|
-
throw Error("Implement makeSubscript");
|
|
1388
|
-
},
|
|
1389
|
-
|
|
1390
|
-
stripParametersFromURL: function (url) {
|
|
1391
|
-
return url.replace(/\?.*$/, "");
|
|
1392
|
-
},
|
|
1393
|
-
|
|
1394
|
-
imageExtensionPattern: new RegExp("(" + [
|
|
1395
|
-
"bmp", "png", "jpeg", "jpg", "gif", "tiff",
|
|
1396
|
-
"tif", "xbm", "xpm", "pbm", "pgm", "ppm", "svg"
|
|
1397
|
-
].join("|") + ")$", "i")
|
|
1398
|
-
};
|
|
1399
|
-
|
|
1400
|
-
if (typeof exports !== "undefined")
|
|
1401
|
-
exports.Converter = Converter;
|
|
1402
|
-
|
|
1403
|
-
// var Converter = require("./converter.js").Converter;
|
|
1404
|
-
// var Node = require("../node.js").Node;
|
|
1405
|
-
|
|
1406
|
-
function ConverterHTML(orgDocument, exportOptions) {
|
|
1407
|
-
this.initialize(orgDocument, exportOptions);
|
|
1408
|
-
this.result = this.convert();
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
ConverterHTML.prototype = {
|
|
1412
|
-
__proto__: Converter.prototype,
|
|
1413
|
-
|
|
1414
|
-
convert: function () {
|
|
1415
|
-
var contentHTML = this.convertNodes(this.orgDocument.nodes, false /* record headers */);
|
|
1416
|
-
|
|
1417
|
-
return {
|
|
1418
|
-
contentHTML: contentHTML,
|
|
1419
|
-
toString: function () {
|
|
1420
|
-
return contentHTML;
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
},
|
|
1424
|
-
|
|
1425
|
-
tocToHTML: function (toc) {
|
|
1426
|
-
function tocToHTMLFunction(tocList) {
|
|
1427
|
-
var html = "";
|
|
1428
|
-
for (var i = 0; i < tocList.length; ++i) {
|
|
1429
|
-
var tocItem = tocList[i];
|
|
1430
|
-
var sectionNumberText = tocItem.headerNode.sectionNumberText;
|
|
1431
|
-
var sectionNumber = this.documentOptions.num ?
|
|
1432
|
-
this.inlineTag("span", sectionNumberText, {
|
|
1433
|
-
"class": "section-number"
|
|
1434
|
-
}) : "";
|
|
1435
|
-
var header = this.getNodeTextContent(tocItem.headerNode);
|
|
1436
|
-
var headerLink = this.inlineTag("a", sectionNumber + header, {
|
|
1437
|
-
href: "#header-" + sectionNumberText.replace(/\./g, "-")
|
|
1438
|
-
});
|
|
1439
|
-
var subList = tocItem.childTocs.length ? tocToHTMLFunction.call(this, tocItem.childTocs) : "";
|
|
1440
|
-
html += this.tag("li", headerLink + subList);
|
|
1441
|
-
}
|
|
1442
|
-
return this.tag("ul", html);
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
return tocToHTMLFunction.call(this, toc);
|
|
1446
|
-
},
|
|
1447
|
-
|
|
1448
|
-
computeAuxDataForNode: function (node) {
|
|
1449
|
-
while (node.parent &&
|
|
1450
|
-
node.parent.type === Node.types.inlineContainer) {
|
|
1451
|
-
node = node.parent;
|
|
1452
|
-
}
|
|
1453
|
-
var attributesNode = node.previousSibling;
|
|
1454
|
-
var attributesText = "";
|
|
1455
|
-
while (attributesNode &&
|
|
1456
|
-
attributesNode.type === Node.types.directive &&
|
|
1457
|
-
attributesNode.directiveName === "attr_html:") {
|
|
1458
|
-
attributesText += attributesNode.directiveRawValue + " ";
|
|
1459
|
-
attributesNode = attributesNode.previousSibling;
|
|
1460
|
-
}
|
|
1461
|
-
return attributesText;
|
|
1462
|
-
},
|
|
1463
|
-
|
|
1464
|
-
// Method to construct org-js generated class
|
|
1465
|
-
orgClassName: function (className) {
|
|
1466
|
-
return this.exportOptions.htmlClassPrefix ?
|
|
1467
|
-
this.exportOptions.htmlClassPrefix + className
|
|
1468
|
-
: className;
|
|
1469
|
-
},
|
|
1470
|
-
|
|
1471
|
-
// Method to construct org-js generated id
|
|
1472
|
-
orgId: function (id) {
|
|
1473
|
-
return this.exportOptions.htmlIdPrefix ?
|
|
1474
|
-
this.exportOptions.htmlIdPrefix + id
|
|
1475
|
-
: id;
|
|
1476
|
-
},
|
|
1477
|
-
|
|
1478
|
-
// ----------------------------------------------------
|
|
1479
|
-
// Node conversion
|
|
1480
|
-
// ----------------------------------------------------
|
|
1481
|
-
|
|
1482
|
-
convertHeader: function (node, childText, auxData, sectionNumberText) {
|
|
1483
|
-
var headerAttributes = {};
|
|
1484
|
-
|
|
1485
|
-
// Parse task status
|
|
1486
|
-
taskStatusRegex = /^\s*([A-Z]+) /
|
|
1487
|
-
taskStatusMatch = childText.match(taskStatusRegex);
|
|
1488
|
-
taskStatus = taskStatusMatch && taskStatusMatch[1];
|
|
1489
|
-
childText = childText.replace(taskStatusRegex, "");
|
|
1490
|
-
|
|
1491
|
-
if (taskStatus) {
|
|
1492
|
-
childText = this.inlineTag("span", taskStatus, {
|
|
1493
|
-
"class": "task-status " + taskStatus
|
|
1494
|
-
}) + childText;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
// Parse task tags
|
|
1498
|
-
taskTagsRegex = /:([\w:]+):/g
|
|
1499
|
-
taskTagsMatch = childText.match(taskTagsRegex);
|
|
1500
|
-
taskTags = taskTagsMatch && taskTagsMatch[0].split(":").slice(1,-1);
|
|
1501
|
-
childText = childText.replace(taskTagsRegex, "");
|
|
1502
|
-
|
|
1503
|
-
if (taskTags) {
|
|
1504
|
-
taskTags.forEach(tag => {
|
|
1505
|
-
childText += this.inlineTag("span", tag, { "class": "task-tag" })
|
|
1506
|
-
});
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
if (sectionNumberText) {
|
|
1510
|
-
childText = this.inlineTag("span", sectionNumberText, {
|
|
1511
|
-
"class": "section-number"
|
|
1512
|
-
}) + childText;
|
|
1513
|
-
headerAttributes["id"] = "header-" + sectionNumberText.replace(/\./g, "-");
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
if (taskStatus)
|
|
1517
|
-
headerAttributes["class"] = "task-status " + taskStatus;
|
|
1518
|
-
|
|
1519
|
-
return this.tag("h" + (this.headerOffset + node.level),
|
|
1520
|
-
childText, headerAttributes, auxData);
|
|
1521
|
-
},
|
|
1522
|
-
|
|
1523
|
-
convertOrderedList: function (node, childText, auxData) {
|
|
1524
|
-
return this.tag("ol", childText, null, auxData);
|
|
1525
|
-
},
|
|
1526
|
-
|
|
1527
|
-
convertUnorderedList: function (node, childText, auxData) {
|
|
1528
|
-
return this.tag("ul", childText, null, auxData);
|
|
1529
|
-
},
|
|
1530
|
-
|
|
1531
|
-
convertDefinitionList: function (node, childText, auxData) {
|
|
1532
|
-
return this.tag("dl", childText, null, auxData);
|
|
1533
|
-
},
|
|
1534
|
-
|
|
1535
|
-
convertDefinitionItem: function (node, childText, auxData,
|
|
1536
|
-
term, definition) {
|
|
1537
|
-
return this.tag("dt", term) + this.tag("dd", definition);
|
|
1538
|
-
},
|
|
1539
|
-
|
|
1540
|
-
convertListItem: function (node, childText, auxData) {
|
|
1541
|
-
if (this.exportOptions.suppressCheckboxHandling) {
|
|
1542
|
-
return this.tag("li", childText, null, auxData);
|
|
1543
|
-
} else {
|
|
1544
|
-
var listItemAttributes = {};
|
|
1545
|
-
var listItemText = childText;
|
|
1546
|
-
// Embed checkbox
|
|
1547
|
-
if (/^\s*\[(X| |-)\]([\s\S]*)/.exec(listItemText)) {
|
|
1548
|
-
listItemText = RegExp.$2 ;
|
|
1549
|
-
var checkboxIndicator = RegExp.$1;
|
|
1550
|
-
|
|
1551
|
-
var checkboxAttributes = { type: "checkbox" };
|
|
1552
|
-
switch (checkboxIndicator) {
|
|
1553
|
-
case "X":
|
|
1554
|
-
checkboxAttributes["checked"] = "true";
|
|
1555
|
-
listItemAttributes["data-checkbox-status"] = "done";
|
|
1556
|
-
break;
|
|
1557
|
-
case "-":
|
|
1558
|
-
listItemAttributes["data-checkbox-status"] = "intermediate";
|
|
1559
|
-
break;
|
|
1560
|
-
default:
|
|
1561
|
-
listItemAttributes["data-checkbox-status"] = "undone";
|
|
1562
|
-
break;
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
listItemText = this.inlineTag("input", null, checkboxAttributes) + listItemText;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
return this.tag("li", listItemText, listItemAttributes, auxData);
|
|
1569
|
-
}
|
|
1570
|
-
},
|
|
1571
|
-
|
|
1572
|
-
convertParagraph: function (node, childText, auxData) {
|
|
1573
|
-
return this.tag("p", childText, null, auxData);
|
|
1574
|
-
},
|
|
1575
|
-
|
|
1576
|
-
convertPreformatted: function (node, childText, auxData) {
|
|
1577
|
-
return this.tag("pre", childText, null, auxData);
|
|
1578
|
-
},
|
|
1579
|
-
|
|
1580
|
-
convertTable: function (node, childText, auxData) {
|
|
1581
|
-
return this.tag("table", this.tag("tbody", childText), null, auxData);
|
|
1582
|
-
},
|
|
1583
|
-
|
|
1584
|
-
convertTableRow: function (node, childText, auxData) {
|
|
1585
|
-
return this.tag("tr", childText);
|
|
1586
|
-
},
|
|
1587
|
-
|
|
1588
|
-
convertTableHeader: function (node, childText, auxData) {
|
|
1589
|
-
return this.tag("th", childText);
|
|
1590
|
-
},
|
|
1591
|
-
|
|
1592
|
-
convertTableCell: function (node, childText, auxData) {
|
|
1593
|
-
return this.tag("td", childText);
|
|
1594
|
-
},
|
|
1595
|
-
|
|
1596
|
-
convertHorizontalRule: function (node, childText, auxData) {
|
|
1597
|
-
return this.tag("hr", null, null, auxData);
|
|
1598
|
-
},
|
|
1599
|
-
|
|
1600
|
-
convertInlineContainer: function (node, childText, auxData) {
|
|
1601
|
-
return childText;
|
|
1602
|
-
},
|
|
1603
|
-
|
|
1604
|
-
convertBold: function (node, childText, auxData) {
|
|
1605
|
-
return this.inlineTag("b", childText);
|
|
1606
|
-
},
|
|
1607
|
-
|
|
1608
|
-
convertItalic: function (node, childText, auxData) {
|
|
1609
|
-
return this.inlineTag("i", childText);
|
|
1610
|
-
},
|
|
1611
|
-
|
|
1612
|
-
convertUnderline: function (node, childText, auxData) {
|
|
1613
|
-
return this.inlineTag("span", childText, {
|
|
1614
|
-
style: "text-decoration:underline;"
|
|
1615
|
-
});
|
|
1616
|
-
},
|
|
1617
|
-
|
|
1618
|
-
convertCode: function (node, childText, auxData) {
|
|
1619
|
-
return this.inlineTag("code", childText);
|
|
1620
|
-
},
|
|
1621
|
-
|
|
1622
|
-
convertDashed: function (node, childText, auxData) {
|
|
1623
|
-
return this.inlineTag("del", childText);
|
|
1624
|
-
},
|
|
1625
|
-
|
|
1626
|
-
convertLink: function (node, childText, auxData) {
|
|
1627
|
-
var srcParameterStripped = this.stripParametersFromURL(node.src);
|
|
1628
|
-
if (this.imageExtensionPattern.exec(srcParameterStripped)) {
|
|
1629
|
-
var imgText = this.getNodeTextContent(node);
|
|
1630
|
-
return this.inlineTag("img", null, {
|
|
1631
|
-
src: node.src,
|
|
1632
|
-
alt: imgText,
|
|
1633
|
-
title: imgText
|
|
1634
|
-
}, auxData);
|
|
1635
|
-
} else {
|
|
1636
|
-
return this.inlineTag("a", childText, { href: node.src });
|
|
1637
|
-
}
|
|
1638
|
-
},
|
|
1639
|
-
|
|
1640
|
-
convertQuote: function (node, childText, auxData) {
|
|
1641
|
-
return this.tag("blockquote", childText, null, auxData);
|
|
1642
|
-
},
|
|
1643
|
-
|
|
1644
|
-
convertExample: function (node, childText, auxData) {
|
|
1645
|
-
return this.tag("pre", childText, null, auxData);
|
|
1646
|
-
},
|
|
1647
|
-
|
|
1648
|
-
convertSrc: function (node, childText, auxData) {
|
|
1649
|
-
var codeLanguage = node.directiveArguments.length
|
|
1650
|
-
? node.directiveArguments[0]
|
|
1651
|
-
: "unknown";
|
|
1652
|
-
childText = this.tag("code", childText, {
|
|
1653
|
-
"class": "language-" + codeLanguage
|
|
1654
|
-
}, auxData);
|
|
1655
|
-
return this.tag("pre", childText, {
|
|
1656
|
-
"class": "prettyprint"
|
|
1657
|
-
});
|
|
1658
|
-
},
|
|
1659
|
-
|
|
1660
|
-
// @override
|
|
1661
|
-
convertHTML: function (node, childText, auxData) {
|
|
1662
|
-
if (node.directiveName === "html:") {
|
|
1663
|
-
return node.directiveRawValue;
|
|
1664
|
-
} else if (node.directiveName === "html") {
|
|
1665
|
-
return node.children.map(function (textNode) {
|
|
1666
|
-
return textNode.value;
|
|
1667
|
-
}).join("\n");
|
|
1668
|
-
} else {
|
|
1669
|
-
return childText;
|
|
1670
|
-
}
|
|
1671
|
-
},
|
|
1672
|
-
|
|
1673
|
-
// @implement
|
|
1674
|
-
convertHeaderBlock: function (headerBlock, level, index) {
|
|
1675
|
-
level = level || 0;
|
|
1676
|
-
index = index || 0;
|
|
1677
|
-
|
|
1678
|
-
var contents = [];
|
|
1679
|
-
|
|
1680
|
-
var headerNode = headerBlock.header;
|
|
1681
|
-
if (headerNode) {
|
|
1682
|
-
contents.push(this.convertNode(headerNode));
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
var blockContent = this.convertNodes(headerBlock.childNodes);
|
|
1686
|
-
contents.push(blockContent);
|
|
1687
|
-
|
|
1688
|
-
var childBlockContent = headerBlock.childBlocks
|
|
1689
|
-
.map(function (block, idx) {
|
|
1690
|
-
return this.convertHeaderBlock(block, level + 1, idx);
|
|
1691
|
-
}, this)
|
|
1692
|
-
.join("\n");
|
|
1693
|
-
contents.push(childBlockContent);
|
|
1694
|
-
|
|
1695
|
-
var contentsText = contents.join("\n");
|
|
1696
|
-
|
|
1697
|
-
if (headerNode) {
|
|
1698
|
-
return this.tag("section", "\n" + contents.join("\n"), {
|
|
1699
|
-
"class": "block block-level-" + level
|
|
1700
|
-
});
|
|
1701
|
-
} else {
|
|
1702
|
-
return contentsText;
|
|
1703
|
-
}
|
|
1704
|
-
},
|
|
1705
|
-
|
|
1706
|
-
// ----------------------------------------------------
|
|
1707
|
-
// Supplemental methods
|
|
1708
|
-
// ----------------------------------------------------
|
|
1709
|
-
|
|
1710
|
-
replaceMap: {
|
|
1711
|
-
// [replacing pattern, predicate]
|
|
1712
|
-
"&": ["&", null],
|
|
1713
|
-
"<": ["<", null],
|
|
1714
|
-
">": [">", null],
|
|
1715
|
-
'"': [""", null],
|
|
1716
|
-
"'": ["'", null],
|
|
1717
|
-
"->": ["➔", function (text, insideCodeElement) {
|
|
1718
|
-
return this.exportOptions.translateSymbolArrow && !insideCodeElement;
|
|
1719
|
-
}]
|
|
1720
|
-
},
|
|
1721
|
-
|
|
1722
|
-
replaceRegexp: null,
|
|
1723
|
-
|
|
1724
|
-
// @implement @override
|
|
1725
|
-
escapeSpecialChars: function (text, insideCodeElement) {
|
|
1726
|
-
if (!this.replaceRegexp) {
|
|
1727
|
-
this.replaceRegexp = new RegExp(Object.keys(this.replaceMap).join("|"), "g");
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
var replaceMap = this.replaceMap;
|
|
1731
|
-
var self = this;
|
|
1732
|
-
return text.replace(this.replaceRegexp, function (matched) {
|
|
1733
|
-
if (!replaceMap[matched]) {
|
|
1734
|
-
throw Error("escapeSpecialChars: Invalid match");
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
var predicate = replaceMap[matched][1];
|
|
1738
|
-
if (typeof predicate === "function" &&
|
|
1739
|
-
!predicate.call(self, text, insideCodeElement)) {
|
|
1740
|
-
// Not fullfill the predicate
|
|
1741
|
-
return matched;
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
return replaceMap[matched][0];
|
|
1745
|
-
});
|
|
1746
|
-
},
|
|
1747
|
-
|
|
1748
|
-
// @implement
|
|
1749
|
-
postProcess: function (node, currentText, insideCodeElement) {
|
|
1750
|
-
if (this.exportOptions.exportFromLineNumber &&
|
|
1751
|
-
typeof node.fromLineNumber === "number") {
|
|
1752
|
-
// Wrap with line number information
|
|
1753
|
-
currentText = this.inlineTag("div", currentText, {
|
|
1754
|
-
"data-line-number": node.fromLineNumber
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
return currentText;
|
|
1758
|
-
},
|
|
1759
|
-
|
|
1760
|
-
// @implement
|
|
1761
|
-
makeLink: function (url) {
|
|
1762
|
-
return "<a href=\"" + url + "\">" + decodeURIComponent(url) + "</a>";
|
|
1763
|
-
},
|
|
1764
|
-
|
|
1765
|
-
// @implement
|
|
1766
|
-
makeSubscript: function (match, body, subscript) {
|
|
1767
|
-
return "<span class=\"org-subscript-parent\">" +
|
|
1768
|
-
body +
|
|
1769
|
-
"</span><span class=\"org-subscript-child\">" +
|
|
1770
|
-
subscript +
|
|
1771
|
-
"</span>";
|
|
1772
|
-
},
|
|
1773
|
-
|
|
1774
|
-
// ----------------------------------------------------
|
|
1775
|
-
// Specific methods
|
|
1776
|
-
// ----------------------------------------------------
|
|
1777
|
-
|
|
1778
|
-
attributesObjectToString: function (attributesObject) {
|
|
1779
|
-
var attributesString = "";
|
|
1780
|
-
for (var attributeName in attributesObject) {
|
|
1781
|
-
if (attributesObject.hasOwnProperty(attributeName)) {
|
|
1782
|
-
var attributeValue = attributesObject[attributeName];
|
|
1783
|
-
// To avoid id/class name conflicts with other frameworks,
|
|
1784
|
-
// users can add arbitrary prefix to org-js generated
|
|
1785
|
-
// ids/classes via exportOptions.
|
|
1786
|
-
if (attributeName === "class") {
|
|
1787
|
-
attributeValue = this.orgClassName(attributeValue);
|
|
1788
|
-
} else if (attributeName === "id") {
|
|
1789
|
-
attributeValue = this.orgId(attributeValue);
|
|
1790
|
-
}
|
|
1791
|
-
attributesString += " " + attributeName + "=\"" + attributeValue + "\"";
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
return attributesString;
|
|
1795
|
-
},
|
|
1796
|
-
|
|
1797
|
-
inlineTag: function (name, innerText, attributesObject, auxAttributesText) {
|
|
1798
|
-
attributesObject = attributesObject || {};
|
|
1799
|
-
|
|
1800
|
-
var htmlString = "<" + name;
|
|
1801
|
-
// TODO: check duplicated attributes
|
|
1802
|
-
if (auxAttributesText)
|
|
1803
|
-
htmlString += " " + auxAttributesText;
|
|
1804
|
-
htmlString += this.attributesObjectToString(attributesObject);
|
|
1805
|
-
|
|
1806
|
-
if (innerText === null)
|
|
1807
|
-
return htmlString + "/>";
|
|
1808
|
-
|
|
1809
|
-
htmlString += ">" + innerText + "</" + name + ">";
|
|
1810
|
-
|
|
1811
|
-
return htmlString;
|
|
1812
|
-
},
|
|
1813
|
-
|
|
1814
|
-
tag: function (name, innerText, attributesObject, auxAttributesText) {
|
|
1815
|
-
return this.inlineTag(name, innerText, attributesObject, auxAttributesText) + "\n";
|
|
1816
|
-
}
|
|
1817
|
-
};
|
|
1818
|
-
|
|
1819
|
-
if (typeof exports !== "undefined")
|
|
1820
|
-
exports.ConverterHTML = ConverterHTML;
|
|
1821
|
-
|
|
1822
|
-
return exports;
|
|
1823
|
-
})();
|