@chayns-components/format 5.0.0-beta.650 → 5.0.0-beta.651
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.
- package/lib/cjs/utils/formatString/markdown/InternalHTMLRenderer.js +287 -0
- package/lib/cjs/utils/formatString/markdown/InternalHTMLRenderer.js.map +1 -0
- package/lib/cjs/utils/formatString/markdown/formatMarkdown.js +2 -1
- package/lib/cjs/utils/formatString/markdown/formatMarkdown.js.map +1 -1
- package/lib/esm/utils/formatString/markdown/InternalHTMLRenderer.js +278 -0
- package/lib/esm/utils/formatString/markdown/InternalHTMLRenderer.js.map +1 -0
- package/lib/esm/utils/formatString/markdown/formatMarkdown.js +2 -1
- package/lib/esm/utils/formatString/markdown/formatMarkdown.js.map +1 -1
- package/lib/types/utils/formatString/markdown/InternalHTMLRenderer.d.ts +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _commonmark = require("commonmark");
|
|
8
|
+
var _escape = require("../../escape");
|
|
9
|
+
// @ts-nocheck
|
|
10
|
+
// /* eslint-disable camelcase */
|
|
11
|
+
// noinspection JSUnusedGlobalSymbols,JSUnresolvedReference
|
|
12
|
+
|
|
13
|
+
const reUnsafeProtocol = /^javascript:|vbscript:|file:|data:/i;
|
|
14
|
+
const reSafeDataProtocol = /^data:image\/(?:png|gif|jpeg|webp)/i;
|
|
15
|
+
function potentiallyUnsafe(url) {
|
|
16
|
+
return reUnsafeProtocol.test(url) && !reSafeDataProtocol.test(url);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Helper function to produce an HTML tag.
|
|
20
|
+
function tag(name, attributes, selfclosing) {
|
|
21
|
+
if (this.disableTags > 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.buffer += `<${name}`;
|
|
25
|
+
if (attributes && attributes.length > 0) {
|
|
26
|
+
let i = 0;
|
|
27
|
+
let attribute;
|
|
28
|
+
// eslint-disable-next-line no-cond-assign
|
|
29
|
+
while ((attribute = attributes[i]) !== undefined) {
|
|
30
|
+
this.buffer += ` ${attribute[0]}="${attribute[1]}"`;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (selfclosing) {
|
|
35
|
+
this.buffer += ' /';
|
|
36
|
+
}
|
|
37
|
+
this.buffer += '>';
|
|
38
|
+
this.lastOut = '>';
|
|
39
|
+
}
|
|
40
|
+
function InternalHTMLRenderer(options) {
|
|
41
|
+
// eslint-disable-next-line no-param-reassign
|
|
42
|
+
options = options || {};
|
|
43
|
+
// by default, soft breaks are rendered as newlines in HTML
|
|
44
|
+
// eslint-disable-next-line no-param-reassign
|
|
45
|
+
options.softbreak = options.softbreak || '';
|
|
46
|
+
// set to "<br />" to make them hard breaks
|
|
47
|
+
// set to " " if you want to ignore line wrapping in source
|
|
48
|
+
this.esc = _escape.escapeHtmlInText;
|
|
49
|
+
// escape html with a custom function
|
|
50
|
+
// else use escapeXml
|
|
51
|
+
|
|
52
|
+
this.disableTags = 0;
|
|
53
|
+
this.lastOut = '\n';
|
|
54
|
+
this.options = options;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Node methods */
|
|
58
|
+
|
|
59
|
+
function text(node) {
|
|
60
|
+
this.out(node.literal);
|
|
61
|
+
}
|
|
62
|
+
function softbreak() {
|
|
63
|
+
this.lit('\n');
|
|
64
|
+
}
|
|
65
|
+
function linebreak() {
|
|
66
|
+
this.lit('\n');
|
|
67
|
+
}
|
|
68
|
+
function link(node, entering) {
|
|
69
|
+
const attributes = this.attrs(node);
|
|
70
|
+
if (entering) {
|
|
71
|
+
if (!(this.options.safe && potentiallyUnsafe(node.destination))) {
|
|
72
|
+
attributes.push(['href', this.esc(node.destination)]);
|
|
73
|
+
}
|
|
74
|
+
if (node.title) {
|
|
75
|
+
attributes.push(['title', this.esc(node.title)]);
|
|
76
|
+
}
|
|
77
|
+
this.tag('a', attributes);
|
|
78
|
+
} else {
|
|
79
|
+
this.tag('/a');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function image(node, entering) {
|
|
83
|
+
if (entering) {
|
|
84
|
+
if (this.disableTags === 0) {
|
|
85
|
+
if (this.options.safe && potentiallyUnsafe(node.destination)) {
|
|
86
|
+
this.lit('<img style="max-width: 100%" src=""');
|
|
87
|
+
} else {
|
|
88
|
+
this.lit(`<img src="${this.esc(node.destination)}"`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.disableTags += 1;
|
|
92
|
+
} else {
|
|
93
|
+
this.disableTags -= 1;
|
|
94
|
+
if (this.disableTags === 0) {
|
|
95
|
+
if (node.title) {
|
|
96
|
+
this.lit(` title="${this.esc(node.title)}`);
|
|
97
|
+
}
|
|
98
|
+
this.lit('/>');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function emph(node, entering) {
|
|
103
|
+
this.tag(entering ? 'em' : '/em');
|
|
104
|
+
}
|
|
105
|
+
function strong(node, entering) {
|
|
106
|
+
this.tag(entering ? 'strong' : '/strong');
|
|
107
|
+
}
|
|
108
|
+
function paragraph(node) {
|
|
109
|
+
const grandparent = node.parent.parent;
|
|
110
|
+
if (grandparent !== null && grandparent.type === 'list') {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.cr();
|
|
114
|
+
}
|
|
115
|
+
function heading(node, entering) {
|
|
116
|
+
const tagName = `h${node.level}`;
|
|
117
|
+
const attributes = this.attrs(node);
|
|
118
|
+
if (entering) {
|
|
119
|
+
var _node$next, _node$next2;
|
|
120
|
+
this.cr();
|
|
121
|
+
this.tag(tagName, attributes);
|
|
122
|
+
|
|
123
|
+
// Removes line break after heading.
|
|
124
|
+
// That line break would be one too many, since headings are block-level elements, and thus already cause a line break behind them.
|
|
125
|
+
if (((_node$next = node.next) === null || _node$next === void 0 ? void 0 : _node$next.type) === 'html_block' && ((_node$next2 = node.next) === null || _node$next2 === void 0 ? void 0 : _node$next2.literal) === _escape.MESSAGE_CONVERSION_LINE_BREAK) {
|
|
126
|
+
node.next.unlink();
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
this.tag(`/${tagName}`);
|
|
130
|
+
this.cr();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function code(node) {
|
|
134
|
+
this.tag('code class="inline-code"');
|
|
135
|
+
this.out(node.literal);
|
|
136
|
+
this.tag('/code');
|
|
137
|
+
}
|
|
138
|
+
function code_block(node) {
|
|
139
|
+
if (node._isFenced) {
|
|
140
|
+
var _node$next3, _node$next4;
|
|
141
|
+
this.tag('pre', [['language', node.info]]);
|
|
142
|
+
this.tag('code');
|
|
143
|
+
|
|
144
|
+
// Removes trailing and leading line break from the code block content.
|
|
145
|
+
const pattern = new RegExp(`^(${_escape.MESSAGE_CONVERSION_LINE_BREAK}|\\n)+|(${_escape.MESSAGE_CONVERSION_LINE_BREAK}|\\n)+$`, 'g');
|
|
146
|
+
const replaced = node.literal.replaceAll(pattern, '');
|
|
147
|
+
this.out(replaced);
|
|
148
|
+
this.tag('/code');
|
|
149
|
+
this.tag('/pre');
|
|
150
|
+
|
|
151
|
+
// Removes line break after code block.
|
|
152
|
+
// That line break would be one too many, since code blocks are block-level elements, and thus already cause a line break behind them.
|
|
153
|
+
if (((_node$next3 = node.next) === null || _node$next3 === void 0 ? void 0 : _node$next3.type) === 'html_block' && ((_node$next4 = node.next) === null || _node$next4 === void 0 ? void 0 : _node$next4.literal) === _escape.MESSAGE_CONVERSION_LINE_BREAK) {
|
|
154
|
+
// eslint-disable-next-line no-param-reassign
|
|
155
|
+
node.next.literal = '';
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
this.out(node.literal);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function thematic_break(node) {
|
|
162
|
+
var _node$next5, _node$next6;
|
|
163
|
+
// Removes line break after thematic break.
|
|
164
|
+
// That line break would be one too many, since thematic breaks are block-level elements, and thus already cause a line break behind them.
|
|
165
|
+
if (((_node$next5 = node.next) === null || _node$next5 === void 0 ? void 0 : _node$next5.type) === 'html_block' && ((_node$next6 = node.next) === null || _node$next6 === void 0 ? void 0 : _node$next6.literal) === _escape.MESSAGE_CONVERSION_LINE_BREAK) {
|
|
166
|
+
// eslint-disable-next-line no-param-reassign
|
|
167
|
+
node.next.literal = '';
|
|
168
|
+
}
|
|
169
|
+
const attributes = this.attrs(node);
|
|
170
|
+
this.cr();
|
|
171
|
+
this.tag('hr', attributes, true);
|
|
172
|
+
this.cr();
|
|
173
|
+
}
|
|
174
|
+
function block_quote(node, entering) {
|
|
175
|
+
const attributes = this.attrs(node);
|
|
176
|
+
if (entering) {
|
|
177
|
+
this.cr();
|
|
178
|
+
this.tag('blockquote', attributes);
|
|
179
|
+
this.cr();
|
|
180
|
+
} else {
|
|
181
|
+
this.cr();
|
|
182
|
+
this.tag('/blockquote');
|
|
183
|
+
this.cr();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function list(node, entering) {
|
|
187
|
+
const tagName = node.listType === 'bullet' ? 'ul' : 'ol';
|
|
188
|
+
const attributes = this.attrs(node);
|
|
189
|
+
if (entering) {
|
|
190
|
+
const start = node.listStart;
|
|
191
|
+
if (start !== null && start !== 1) {
|
|
192
|
+
attributes.push(['start', start.toString()]);
|
|
193
|
+
}
|
|
194
|
+
this.cr();
|
|
195
|
+
this.tag(tagName, attributes);
|
|
196
|
+
this.cr();
|
|
197
|
+
} else {
|
|
198
|
+
this.cr();
|
|
199
|
+
this.tag(`/${tagName}`);
|
|
200
|
+
this.cr();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function item(node, entering) {
|
|
204
|
+
const attributes = this.attrs(node);
|
|
205
|
+
if (entering) {
|
|
206
|
+
this.tag('li', attributes);
|
|
207
|
+
} else {
|
|
208
|
+
this.tag('/li');
|
|
209
|
+
this.cr();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function html_inline(node) {
|
|
213
|
+
if (this.options.safe) {
|
|
214
|
+
this.lit('<!-- raw HTML omitted -->');
|
|
215
|
+
} else {
|
|
216
|
+
this.lit(node.literal);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function html_block(node) {
|
|
220
|
+
this.cr();
|
|
221
|
+
if (this.options.safe) {
|
|
222
|
+
this.lit('<!-- raw HTML omitted -->');
|
|
223
|
+
} else {
|
|
224
|
+
this.lit(node.literal);
|
|
225
|
+
}
|
|
226
|
+
this.cr();
|
|
227
|
+
}
|
|
228
|
+
function custom_inline(node, entering) {
|
|
229
|
+
if (entering && node.onEnter) {
|
|
230
|
+
this.lit(node.onEnter);
|
|
231
|
+
} else if (!entering && node.onExit) {
|
|
232
|
+
this.lit(node.onExit);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function custom_block(node, entering) {
|
|
236
|
+
this.cr();
|
|
237
|
+
if (entering && node.onEnter) {
|
|
238
|
+
this.lit(node.onEnter);
|
|
239
|
+
} else if (!entering && node.onExit) {
|
|
240
|
+
this.lit(node.onExit);
|
|
241
|
+
}
|
|
242
|
+
this.cr();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* Helper methods */
|
|
246
|
+
|
|
247
|
+
function out(s) {
|
|
248
|
+
this.lit(this.esc(s));
|
|
249
|
+
}
|
|
250
|
+
function attrs(node) {
|
|
251
|
+
const att = [];
|
|
252
|
+
if (this.options.sourcepos) {
|
|
253
|
+
const pos = node.sourcepos;
|
|
254
|
+
if (pos) {
|
|
255
|
+
att.push(['data-sourcepos', `${String(pos[0][0])}:${String(pos[0][1])}-${String(pos[1][0])}:${String(pos[1][1])}`]);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return att;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// quick browser-compatible inheritance
|
|
262
|
+
InternalHTMLRenderer.prototype = Object.create(_commonmark.HtmlRenderer.prototype);
|
|
263
|
+
InternalHTMLRenderer.prototype.text = text;
|
|
264
|
+
InternalHTMLRenderer.prototype.html_inline = html_inline;
|
|
265
|
+
InternalHTMLRenderer.prototype.html_block = html_block;
|
|
266
|
+
InternalHTMLRenderer.prototype.softbreak = softbreak;
|
|
267
|
+
InternalHTMLRenderer.prototype.linebreak = linebreak;
|
|
268
|
+
InternalHTMLRenderer.prototype.link = link;
|
|
269
|
+
InternalHTMLRenderer.prototype.image = image;
|
|
270
|
+
InternalHTMLRenderer.prototype.emph = emph;
|
|
271
|
+
InternalHTMLRenderer.prototype.strong = strong;
|
|
272
|
+
InternalHTMLRenderer.prototype.paragraph = paragraph;
|
|
273
|
+
InternalHTMLRenderer.prototype.heading = heading;
|
|
274
|
+
InternalHTMLRenderer.prototype.code = code;
|
|
275
|
+
InternalHTMLRenderer.prototype.code_block = code_block;
|
|
276
|
+
InternalHTMLRenderer.prototype.thematic_break = thematic_break;
|
|
277
|
+
InternalHTMLRenderer.prototype.block_quote = block_quote;
|
|
278
|
+
InternalHTMLRenderer.prototype.list = list;
|
|
279
|
+
InternalHTMLRenderer.prototype.item = item;
|
|
280
|
+
InternalHTMLRenderer.prototype.custom_inline = custom_inline;
|
|
281
|
+
InternalHTMLRenderer.prototype.custom_block = custom_block;
|
|
282
|
+
InternalHTMLRenderer.prototype.esc = _escape.escapeHtmlInText;
|
|
283
|
+
InternalHTMLRenderer.prototype.out = out;
|
|
284
|
+
InternalHTMLRenderer.prototype.tag = tag;
|
|
285
|
+
InternalHTMLRenderer.prototype.attrs = attrs;
|
|
286
|
+
var _default = exports.default = InternalHTMLRenderer;
|
|
287
|
+
//# sourceMappingURL=InternalHTMLRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalHTMLRenderer.js","names":["_commonmark","require","_escape","reUnsafeProtocol","reSafeDataProtocol","potentiallyUnsafe","url","test","tag","name","attributes","selfclosing","disableTags","buffer","length","i","attribute","undefined","lastOut","InternalHTMLRenderer","options","softbreak","esc","escapeHtmlInText","text","node","out","literal","lit","linebreak","link","entering","attrs","safe","destination","push","title","image","emph","strong","paragraph","grandparent","parent","type","cr","heading","tagName","level","_node$next","_node$next2","next","MESSAGE_CONVERSION_LINE_BREAK","unlink","code","code_block","_isFenced","_node$next3","_node$next4","info","pattern","RegExp","replaced","replaceAll","thematic_break","_node$next5","_node$next6","block_quote","list","listType","start","listStart","toString","item","html_inline","html_block","custom_inline","onEnter","onExit","custom_block","s","att","sourcepos","pos","String","prototype","Object","create","HtmlRenderer","_default","exports","default"],"sources":["../../../../../src/utils/formatString/markdown/InternalHTMLRenderer.ts"],"sourcesContent":["// @ts-nocheck\n// /* eslint-disable camelcase */\n// noinspection JSUnusedGlobalSymbols,JSUnresolvedReference\n\nimport { HtmlRenderer } from 'commonmark';\nimport { escapeHtmlInText, MESSAGE_CONVERSION_LINE_BREAK } from '../../escape';\n\nconst reUnsafeProtocol = /^javascript:|vbscript:|file:|data:/i;\nconst reSafeDataProtocol = /^data:image\\/(?:png|gif|jpeg|webp)/i;\n\nfunction potentiallyUnsafe(url) {\n return reUnsafeProtocol.test(url) && !reSafeDataProtocol.test(url);\n}\n\n// Helper function to produce an HTML tag.\nfunction tag(name, attributes, selfclosing) {\n if (this.disableTags > 0) {\n return;\n }\n this.buffer += `<${name}`;\n if (attributes && attributes.length > 0) {\n let i = 0;\n let attribute;\n // eslint-disable-next-line no-cond-assign\n while ((attribute = attributes[i]) !== undefined) {\n this.buffer += ` ${attribute[0]}=\"${attribute[1]}\"`;\n i++;\n }\n }\n if (selfclosing) {\n this.buffer += ' /';\n }\n this.buffer += '>';\n this.lastOut = '>';\n}\n\nfunction InternalHTMLRenderer(options) {\n // eslint-disable-next-line no-param-reassign\n options = options || {};\n // by default, soft breaks are rendered as newlines in HTML\n // eslint-disable-next-line no-param-reassign\n options.softbreak = options.softbreak || '';\n // set to \"<br />\" to make them hard breaks\n // set to \" \" if you want to ignore line wrapping in source\n this.esc = escapeHtmlInText;\n // escape html with a custom function\n // else use escapeXml\n\n this.disableTags = 0;\n this.lastOut = '\\n';\n this.options = options;\n}\n\n/* Node methods */\n\nfunction text(node) {\n this.out(node.literal);\n}\n\nfunction softbreak() {\n this.lit('\\n');\n}\n\nfunction linebreak() {\n this.lit('\\n');\n}\n\nfunction link(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n if (!(this.options.safe && potentiallyUnsafe(node.destination))) {\n attributes.push(['href', this.esc(node.destination)]);\n }\n if (node.title) {\n attributes.push(['title', this.esc(node.title)]);\n }\n this.tag('a', attributes);\n } else {\n this.tag('/a');\n }\n}\n\nfunction image(node, entering) {\n if (entering) {\n if (this.disableTags === 0) {\n if (this.options.safe && potentiallyUnsafe(node.destination)) {\n this.lit('<img style=\"max-width: 100%\" src=\"\"');\n } else {\n this.lit(`<img src=\"${this.esc(node.destination)}\"`);\n }\n }\n this.disableTags += 1;\n } else {\n this.disableTags -= 1;\n if (this.disableTags === 0) {\n if (node.title) {\n this.lit(` title=\"${this.esc(node.title)}`);\n }\n this.lit('/>');\n }\n }\n}\n\nfunction emph(node, entering) {\n this.tag(entering ? 'em' : '/em');\n}\n\nfunction strong(node, entering) {\n this.tag(entering ? 'strong' : '/strong');\n}\n\nfunction paragraph(node) {\n const grandparent = node.parent.parent;\n\n if (grandparent !== null && grandparent.type === 'list') {\n return;\n }\n\n this.cr();\n}\n\nfunction heading(node, entering) {\n const tagName = `h${node.level}`;\n const attributes = this.attrs(node);\n if (entering) {\n this.cr();\n this.tag(tagName, attributes);\n\n // Removes line break after heading.\n // That line break would be one too many, since headings are block-level elements, and thus already cause a line break behind them.\n if (\n node.next?.type === 'html_block' &&\n node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK\n ) {\n node.next.unlink();\n }\n } else {\n this.tag(`/${tagName}`);\n this.cr();\n }\n}\n\nfunction code(node) {\n this.tag('code class=\"inline-code\"');\n this.out(node.literal);\n this.tag('/code');\n}\n\nfunction code_block(node) {\n if (node._isFenced) {\n this.tag('pre', [['language', node.info]]);\n this.tag('code');\n\n // Removes trailing and leading line break from the code block content.\n const pattern = new RegExp(\n `^(${MESSAGE_CONVERSION_LINE_BREAK}|\\\\n)+|(${MESSAGE_CONVERSION_LINE_BREAK}|\\\\n)+$`,\n 'g',\n );\n const replaced = node.literal.replaceAll(pattern, '');\n this.out(replaced);\n\n this.tag('/code');\n this.tag('/pre');\n\n // Removes line break after code block.\n // That line break would be one too many, since code blocks are block-level elements, and thus already cause a line break behind them.\n if (\n node.next?.type === 'html_block' &&\n node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK\n ) {\n // eslint-disable-next-line no-param-reassign\n node.next.literal = '';\n }\n } else {\n this.out(node.literal);\n }\n}\n\nfunction thematic_break(node) {\n // Removes line break after thematic break.\n // That line break would be one too many, since thematic breaks are block-level elements, and thus already cause a line break behind them.\n if (node.next?.type === 'html_block' && node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK) {\n // eslint-disable-next-line no-param-reassign\n node.next.literal = '';\n }\n\n const attributes = this.attrs(node);\n this.cr();\n this.tag('hr', attributes, true);\n this.cr();\n}\n\nfunction block_quote(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n this.cr();\n this.tag('blockquote', attributes);\n this.cr();\n } else {\n this.cr();\n this.tag('/blockquote');\n this.cr();\n }\n}\n\nfunction list(node, entering) {\n const tagName = node.listType === 'bullet' ? 'ul' : 'ol';\n const attributes = this.attrs(node);\n\n if (entering) {\n const start = node.listStart;\n if (start !== null && start !== 1) {\n attributes.push(['start', start.toString()]);\n }\n this.cr();\n this.tag(tagName, attributes);\n this.cr();\n } else {\n this.cr();\n this.tag(`/${tagName}`);\n this.cr();\n }\n}\n\nfunction item(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n this.tag('li', attributes);\n } else {\n this.tag('/li');\n this.cr();\n }\n}\n\nfunction html_inline(node) {\n if (this.options.safe) {\n this.lit('<!-- raw HTML omitted -->');\n } else {\n this.lit(node.literal);\n }\n}\n\nfunction html_block(node) {\n this.cr();\n if (this.options.safe) {\n this.lit('<!-- raw HTML omitted -->');\n } else {\n this.lit(node.literal);\n }\n this.cr();\n}\n\nfunction custom_inline(node, entering) {\n if (entering && node.onEnter) {\n this.lit(node.onEnter);\n } else if (!entering && node.onExit) {\n this.lit(node.onExit);\n }\n}\n\nfunction custom_block(node, entering) {\n this.cr();\n if (entering && node.onEnter) {\n this.lit(node.onEnter);\n } else if (!entering && node.onExit) {\n this.lit(node.onExit);\n }\n this.cr();\n}\n\n/* Helper methods */\n\nfunction out(s) {\n this.lit(this.esc(s));\n}\n\nfunction attrs(node) {\n const att = [];\n if (this.options.sourcepos) {\n const pos = node.sourcepos;\n if (pos) {\n att.push([\n 'data-sourcepos',\n `${String(pos[0][0])}:${String(pos[0][1])}-${String(pos[1][0])}:${String(\n pos[1][1],\n )}`,\n ]);\n }\n }\n return att;\n}\n\n// quick browser-compatible inheritance\nInternalHTMLRenderer.prototype = Object.create(HtmlRenderer.prototype);\n\nInternalHTMLRenderer.prototype.text = text;\nInternalHTMLRenderer.prototype.html_inline = html_inline;\nInternalHTMLRenderer.prototype.html_block = html_block;\nInternalHTMLRenderer.prototype.softbreak = softbreak;\nInternalHTMLRenderer.prototype.linebreak = linebreak;\nInternalHTMLRenderer.prototype.link = link;\nInternalHTMLRenderer.prototype.image = image;\nInternalHTMLRenderer.prototype.emph = emph;\nInternalHTMLRenderer.prototype.strong = strong;\nInternalHTMLRenderer.prototype.paragraph = paragraph;\nInternalHTMLRenderer.prototype.heading = heading;\nInternalHTMLRenderer.prototype.code = code;\nInternalHTMLRenderer.prototype.code_block = code_block;\nInternalHTMLRenderer.prototype.thematic_break = thematic_break;\nInternalHTMLRenderer.prototype.block_quote = block_quote;\nInternalHTMLRenderer.prototype.list = list;\nInternalHTMLRenderer.prototype.item = item;\nInternalHTMLRenderer.prototype.custom_inline = custom_inline;\nInternalHTMLRenderer.prototype.custom_block = custom_block;\n\nInternalHTMLRenderer.prototype.esc = escapeHtmlInText;\n\nInternalHTMLRenderer.prototype.out = out;\nInternalHTMLRenderer.prototype.tag = tag;\nInternalHTMLRenderer.prototype.attrs = attrs;\n\nexport default InternalHTMLRenderer;\n"],"mappings":";;;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAKA,MAAME,gBAAgB,GAAG,qCAAqC;AAC9D,MAAMC,kBAAkB,GAAG,qCAAqC;AAEhE,SAASC,iBAAiBA,CAACC,GAAG,EAAE;EAC5B,OAAOH,gBAAgB,CAACI,IAAI,CAACD,GAAG,CAAC,IAAI,CAACF,kBAAkB,CAACG,IAAI,CAACD,GAAG,CAAC;AACtE;;AAEA;AACA,SAASE,GAAGA,CAACC,IAAI,EAAEC,UAAU,EAAEC,WAAW,EAAE;EACxC,IAAI,IAAI,CAACC,WAAW,GAAG,CAAC,EAAE;IACtB;EACJ;EACA,IAAI,CAACC,MAAM,IAAI,IAAIJ,IAAI,EAAE;EACzB,IAAIC,UAAU,IAAIA,UAAU,CAACI,MAAM,GAAG,CAAC,EAAE;IACrC,IAAIC,CAAC,GAAG,CAAC;IACT,IAAIC,SAAS;IACb;IACA,OAAO,CAACA,SAAS,GAAGN,UAAU,CAACK,CAAC,CAAC,MAAME,SAAS,EAAE;MAC9C,IAAI,CAACJ,MAAM,IAAI,IAAIG,SAAS,CAAC,CAAC,CAAC,KAAKA,SAAS,CAAC,CAAC,CAAC,GAAG;MACnDD,CAAC,EAAE;IACP;EACJ;EACA,IAAIJ,WAAW,EAAE;IACb,IAAI,CAACE,MAAM,IAAI,IAAI;EACvB;EACA,IAAI,CAACA,MAAM,IAAI,GAAG;EAClB,IAAI,CAACK,OAAO,GAAG,GAAG;AACtB;AAEA,SAASC,oBAAoBA,CAACC,OAAO,EAAE;EACnC;EACAA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;EACvB;EACA;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GAAGA,IAAI;AAC1CX,oBAAoB,CAACiE,SAAS,CAAC/C,KAAK,GAAGA,KAAK;AAC5ClB,oBAAoB,CAACiE,SAAS,CAAC9C,IAAI,GAAGA,IAAI;AAC1CnB,oBAAoB,CAACiE,SAAS,CAAC7C,MAAM,GAAGA,MAAM;AAC9CpB,oBAAoB,CAACiE,SAAS,CAAC5C,SAAS,GAAGA,SAAS;AACpDrB,oBAAoB,CAACiE,SAAS,CAACvC,OAAO,GAAGA,OAAO;AAChD1B,oBAAoB,CAACiE,SAAS,CAAC/B,IAAI,GAAGA,IAAI;AAC1ClC,oBAAoB,CAACiE,SAAS,CAAC9B,UAAU,GAAGA,UAAU;AACtDnC,oBAAoB,CAACiE,SAAS,CAACrB,cAAc,GAAGA,cAAc;AAC9D5C,oBAAoB,CAACiE,SAAS,CAAClB,WAAW,GAAGA,WAAW;AACxD/C,oBAAoB,CAACiE,SAAS,CAACjB,IAAI,GAAGA,IAAI;AAC1ChD,oBAAoB,CAACiE,SAAS,CAACZ,IAAI,GAAGA,IAAI;AAC1CrD,oBAAoB,CAACiE,SAAS,CAACT,aAAa,GAAGA,aAAa;AAC5DxD,oBAAoB,CAACiE,SAAS,CAACN,YAAY,GAAGA,YAAY;AAE1D3D,oBAAoB,CAACiE,SAAS,CAAC9D,GAAG,GAAGC,wBAAgB;AAErDJ,oBAAoB,CAACiE,SAAS,CAAC1D,GAAG,GAAGA,GAAG;AACxCP,oBAAoB,CAACiE,SAAS,CAAC5E,GAAG,GAAGA,GAAG;AACxCW,oBAAoB,CAACiE,SAAS,CAACpD,KAAK,GAAGA,KAAK;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE9BvE,oBAAoB","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.parseMarkdown = void 0;
|
|
7
7
|
var _commonmark = require("commonmark");
|
|
8
8
|
var _escape = require("../../escape");
|
|
9
|
-
var _InternalHTMLRenderer = _interopRequireDefault(require("./InternalHTMLRenderer
|
|
9
|
+
var _InternalHTMLRenderer = _interopRequireDefault(require("./InternalHTMLRenderer"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
12
|
// @ts-ignore
|
|
@@ -23,6 +23,7 @@ const parseMarkdown = text => {
|
|
|
23
23
|
const commonmarkParser = new _commonmark.Parser();
|
|
24
24
|
// TODO Check if esc needs to be passed to InternalHTMLRenderer.
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
|
|
26
|
+
// @ts-ignore
|
|
26
27
|
const internalHTMLRenderer = new _InternalHTMLRenderer.default({
|
|
27
28
|
esc: _escape.escapeHtmlInText
|
|
28
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMarkdown.js","names":["_commonmark","require","_escape","_InternalHTMLRenderer","_interopRequireDefault","e","__esModule","default","parseMarkdown","text","newText","replaceAll","MESSAGE_CONVERSION_LINE_BREAK","commonmarkParser","Parser","internalHTMLRenderer","InternalHTMLRenderer","esc","escapeHtmlInText","parsedText","parse","render","MESSAGE_CONVERSION_LINE_BREAK_ESCAPED","exports"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { Parser } from 'commonmark';\nimport {\n escapeHtmlInText,\n MESSAGE_CONVERSION_LINE_BREAK,\n MESSAGE_CONVERSION_LINE_BREAK_ESCAPED,\n} from '../../escape';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport InternalHTMLRenderer from './InternalHTMLRenderer
|
|
1
|
+
{"version":3,"file":"formatMarkdown.js","names":["_commonmark","require","_escape","_InternalHTMLRenderer","_interopRequireDefault","e","__esModule","default","parseMarkdown","text","newText","replaceAll","MESSAGE_CONVERSION_LINE_BREAK","commonmarkParser","Parser","internalHTMLRenderer","InternalHTMLRenderer","esc","escapeHtmlInText","parsedText","parse","render","MESSAGE_CONVERSION_LINE_BREAK_ESCAPED","exports"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { Parser } from 'commonmark';\nimport {\n escapeHtmlInText,\n MESSAGE_CONVERSION_LINE_BREAK,\n MESSAGE_CONVERSION_LINE_BREAK_ESCAPED,\n} from '../../escape';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport InternalHTMLRenderer from './InternalHTMLRenderer';\n\nexport const parseMarkdown = (text: string) => {\n let newText = text;\n\n // Markdown has its own line break handling. For that reason, we need to replace line breaks with a custom element.\n // In this case I chose a custom <br> Tag.\n // Since commonmark doesn't parse markdown in lines with html, the custom <br> Tag needs to be in its own line.\n // Since there are issues, when the <br> Tag + \\n is followed by text, there needs to be a second line break.\n // Thus, we replace \\n with \\n<br>\\n\\n.\n newText = newText.replaceAll(/\\n/gm, `\\n${MESSAGE_CONVERSION_LINE_BREAK}\\n\\n`);\n\n const commonmarkParser = new Parser();\n // TODO Check if esc needs to be passed to InternalHTMLRenderer.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n // @ts-ignore\n const internalHTMLRenderer = new InternalHTMLRenderer({ esc: escapeHtmlInText });\n\n // Converts markdown to HTML.\n const parsedText = commonmarkParser.parse(newText);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n newText = internalHTMLRenderer.render(parsedText) as string;\n\n // The Linebreak handling of markdown is ignored, by removing \\n. Then the custom <br> Tags are converted back to \\n.\n newText = newText.replaceAll(/\\n/gm, '');\n newText = newText\n .replaceAll(MESSAGE_CONVERSION_LINE_BREAK, '\\n')\n .replaceAll(MESSAGE_CONVERSION_LINE_BREAK_ESCAPED, '\\n');\n\n return newText;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA0D,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAF1D;AACA;;AAGO,MAAMG,aAAa,GAAIC,IAAY,IAAK;EAC3C,IAAIC,OAAO,GAAGD,IAAI;;EAElB;EACA;EACA;EACA;EACA;EACAC,OAAO,GAAGA,OAAO,CAACC,UAAU,CAAC,MAAM,EAAE,KAAKC,qCAA6B,MAAM,CAAC;EAE9E,MAAMC,gBAAgB,GAAG,IAAIC,kBAAM,CAAC,CAAC;EACrC;EACA;EACA;EACA,MAAMC,oBAAoB,GAAG,IAAIC,6BAAoB,CAAC;IAAEC,GAAG,EAAEC;EAAiB,CAAC,CAAC;;EAEhF;EACA,MAAMC,UAAU,GAAGN,gBAAgB,CAACO,KAAK,CAACV,OAAO,CAAC;EAClD;EACAA,OAAO,GAAGK,oBAAoB,CAACM,MAAM,CAACF,UAAU,CAAW;;EAE3D;EACAT,OAAO,GAAGA,OAAO,CAACC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;EACxCD,OAAO,GAAGA,OAAO,CACZC,UAAU,CAACC,qCAA6B,EAAE,IAAI,CAAC,CAC/CD,UAAU,CAACW,6CAAqC,EAAE,IAAI,CAAC;EAE5D,OAAOZ,OAAO;AAClB,CAAC;AAACa,OAAA,CAAAf,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// /* eslint-disable camelcase */
|
|
3
|
+
// noinspection JSUnusedGlobalSymbols,JSUnresolvedReference
|
|
4
|
+
|
|
5
|
+
import { HtmlRenderer } from 'commonmark';
|
|
6
|
+
import { escapeHtmlInText, MESSAGE_CONVERSION_LINE_BREAK } from '../../escape';
|
|
7
|
+
const reUnsafeProtocol = /^javascript:|vbscript:|file:|data:/i;
|
|
8
|
+
const reSafeDataProtocol = /^data:image\/(?:png|gif|jpeg|webp)/i;
|
|
9
|
+
function potentiallyUnsafe(url) {
|
|
10
|
+
return reUnsafeProtocol.test(url) && !reSafeDataProtocol.test(url);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Helper function to produce an HTML tag.
|
|
14
|
+
function tag(name, attributes, selfclosing) {
|
|
15
|
+
if (this.disableTags > 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
this.buffer += `<${name}`;
|
|
19
|
+
if (attributes && attributes.length > 0) {
|
|
20
|
+
let i = 0;
|
|
21
|
+
let attribute;
|
|
22
|
+
// eslint-disable-next-line no-cond-assign
|
|
23
|
+
while ((attribute = attributes[i]) !== undefined) {
|
|
24
|
+
this.buffer += ` ${attribute[0]}="${attribute[1]}"`;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (selfclosing) {
|
|
29
|
+
this.buffer += ' /';
|
|
30
|
+
}
|
|
31
|
+
this.buffer += '>';
|
|
32
|
+
this.lastOut = '>';
|
|
33
|
+
}
|
|
34
|
+
function InternalHTMLRenderer(options) {
|
|
35
|
+
// eslint-disable-next-line no-param-reassign
|
|
36
|
+
options = options || {};
|
|
37
|
+
// by default, soft breaks are rendered as newlines in HTML
|
|
38
|
+
// eslint-disable-next-line no-param-reassign
|
|
39
|
+
options.softbreak = options.softbreak || '';
|
|
40
|
+
// set to "<br />" to make them hard breaks
|
|
41
|
+
// set to " " if you want to ignore line wrapping in source
|
|
42
|
+
this.esc = escapeHtmlInText;
|
|
43
|
+
// escape html with a custom function
|
|
44
|
+
// else use escapeXml
|
|
45
|
+
|
|
46
|
+
this.disableTags = 0;
|
|
47
|
+
this.lastOut = '\n';
|
|
48
|
+
this.options = options;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Node methods */
|
|
52
|
+
|
|
53
|
+
function text(node) {
|
|
54
|
+
this.out(node.literal);
|
|
55
|
+
}
|
|
56
|
+
function softbreak() {
|
|
57
|
+
this.lit('\n');
|
|
58
|
+
}
|
|
59
|
+
function linebreak() {
|
|
60
|
+
this.lit('\n');
|
|
61
|
+
}
|
|
62
|
+
function link(node, entering) {
|
|
63
|
+
const attributes = this.attrs(node);
|
|
64
|
+
if (entering) {
|
|
65
|
+
if (!(this.options.safe && potentiallyUnsafe(node.destination))) {
|
|
66
|
+
attributes.push(['href', this.esc(node.destination)]);
|
|
67
|
+
}
|
|
68
|
+
if (node.title) {
|
|
69
|
+
attributes.push(['title', this.esc(node.title)]);
|
|
70
|
+
}
|
|
71
|
+
this.tag('a', attributes);
|
|
72
|
+
} else {
|
|
73
|
+
this.tag('/a');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function image(node, entering) {
|
|
77
|
+
if (entering) {
|
|
78
|
+
if (this.disableTags === 0) {
|
|
79
|
+
if (this.options.safe && potentiallyUnsafe(node.destination)) {
|
|
80
|
+
this.lit('<img style="max-width: 100%" src=""');
|
|
81
|
+
} else {
|
|
82
|
+
this.lit(`<img src="${this.esc(node.destination)}"`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this.disableTags += 1;
|
|
86
|
+
} else {
|
|
87
|
+
this.disableTags -= 1;
|
|
88
|
+
if (this.disableTags === 0) {
|
|
89
|
+
if (node.title) {
|
|
90
|
+
this.lit(` title="${this.esc(node.title)}`);
|
|
91
|
+
}
|
|
92
|
+
this.lit('/>');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function emph(node, entering) {
|
|
97
|
+
this.tag(entering ? 'em' : '/em');
|
|
98
|
+
}
|
|
99
|
+
function strong(node, entering) {
|
|
100
|
+
this.tag(entering ? 'strong' : '/strong');
|
|
101
|
+
}
|
|
102
|
+
function paragraph(node) {
|
|
103
|
+
const grandparent = node.parent.parent;
|
|
104
|
+
if (grandparent !== null && grandparent.type === 'list') {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.cr();
|
|
108
|
+
}
|
|
109
|
+
function heading(node, entering) {
|
|
110
|
+
const tagName = `h${node.level}`;
|
|
111
|
+
const attributes = this.attrs(node);
|
|
112
|
+
if (entering) {
|
|
113
|
+
this.cr();
|
|
114
|
+
this.tag(tagName, attributes);
|
|
115
|
+
|
|
116
|
+
// Removes line break after heading.
|
|
117
|
+
// That line break would be one too many, since headings are block-level elements, and thus already cause a line break behind them.
|
|
118
|
+
if (node.next?.type === 'html_block' && node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK) {
|
|
119
|
+
node.next.unlink();
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
this.tag(`/${tagName}`);
|
|
123
|
+
this.cr();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function code(node) {
|
|
127
|
+
this.tag('code class="inline-code"');
|
|
128
|
+
this.out(node.literal);
|
|
129
|
+
this.tag('/code');
|
|
130
|
+
}
|
|
131
|
+
function code_block(node) {
|
|
132
|
+
if (node._isFenced) {
|
|
133
|
+
this.tag('pre', [['language', node.info]]);
|
|
134
|
+
this.tag('code');
|
|
135
|
+
|
|
136
|
+
// Removes trailing and leading line break from the code block content.
|
|
137
|
+
const pattern = new RegExp(`^(${MESSAGE_CONVERSION_LINE_BREAK}|\\n)+|(${MESSAGE_CONVERSION_LINE_BREAK}|\\n)+$`, 'g');
|
|
138
|
+
const replaced = node.literal.replaceAll(pattern, '');
|
|
139
|
+
this.out(replaced);
|
|
140
|
+
this.tag('/code');
|
|
141
|
+
this.tag('/pre');
|
|
142
|
+
|
|
143
|
+
// Removes line break after code block.
|
|
144
|
+
// That line break would be one too many, since code blocks are block-level elements, and thus already cause a line break behind them.
|
|
145
|
+
if (node.next?.type === 'html_block' && node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK) {
|
|
146
|
+
// eslint-disable-next-line no-param-reassign
|
|
147
|
+
node.next.literal = '';
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
this.out(node.literal);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function thematic_break(node) {
|
|
154
|
+
// Removes line break after thematic break.
|
|
155
|
+
// That line break would be one too many, since thematic breaks are block-level elements, and thus already cause a line break behind them.
|
|
156
|
+
if (node.next?.type === 'html_block' && node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK) {
|
|
157
|
+
// eslint-disable-next-line no-param-reassign
|
|
158
|
+
node.next.literal = '';
|
|
159
|
+
}
|
|
160
|
+
const attributes = this.attrs(node);
|
|
161
|
+
this.cr();
|
|
162
|
+
this.tag('hr', attributes, true);
|
|
163
|
+
this.cr();
|
|
164
|
+
}
|
|
165
|
+
function block_quote(node, entering) {
|
|
166
|
+
const attributes = this.attrs(node);
|
|
167
|
+
if (entering) {
|
|
168
|
+
this.cr();
|
|
169
|
+
this.tag('blockquote', attributes);
|
|
170
|
+
this.cr();
|
|
171
|
+
} else {
|
|
172
|
+
this.cr();
|
|
173
|
+
this.tag('/blockquote');
|
|
174
|
+
this.cr();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function list(node, entering) {
|
|
178
|
+
const tagName = node.listType === 'bullet' ? 'ul' : 'ol';
|
|
179
|
+
const attributes = this.attrs(node);
|
|
180
|
+
if (entering) {
|
|
181
|
+
const start = node.listStart;
|
|
182
|
+
if (start !== null && start !== 1) {
|
|
183
|
+
attributes.push(['start', start.toString()]);
|
|
184
|
+
}
|
|
185
|
+
this.cr();
|
|
186
|
+
this.tag(tagName, attributes);
|
|
187
|
+
this.cr();
|
|
188
|
+
} else {
|
|
189
|
+
this.cr();
|
|
190
|
+
this.tag(`/${tagName}`);
|
|
191
|
+
this.cr();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function item(node, entering) {
|
|
195
|
+
const attributes = this.attrs(node);
|
|
196
|
+
if (entering) {
|
|
197
|
+
this.tag('li', attributes);
|
|
198
|
+
} else {
|
|
199
|
+
this.tag('/li');
|
|
200
|
+
this.cr();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function html_inline(node) {
|
|
204
|
+
if (this.options.safe) {
|
|
205
|
+
this.lit('<!-- raw HTML omitted -->');
|
|
206
|
+
} else {
|
|
207
|
+
this.lit(node.literal);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function html_block(node) {
|
|
211
|
+
this.cr();
|
|
212
|
+
if (this.options.safe) {
|
|
213
|
+
this.lit('<!-- raw HTML omitted -->');
|
|
214
|
+
} else {
|
|
215
|
+
this.lit(node.literal);
|
|
216
|
+
}
|
|
217
|
+
this.cr();
|
|
218
|
+
}
|
|
219
|
+
function custom_inline(node, entering) {
|
|
220
|
+
if (entering && node.onEnter) {
|
|
221
|
+
this.lit(node.onEnter);
|
|
222
|
+
} else if (!entering && node.onExit) {
|
|
223
|
+
this.lit(node.onExit);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function custom_block(node, entering) {
|
|
227
|
+
this.cr();
|
|
228
|
+
if (entering && node.onEnter) {
|
|
229
|
+
this.lit(node.onEnter);
|
|
230
|
+
} else if (!entering && node.onExit) {
|
|
231
|
+
this.lit(node.onExit);
|
|
232
|
+
}
|
|
233
|
+
this.cr();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Helper methods */
|
|
237
|
+
|
|
238
|
+
function out(s) {
|
|
239
|
+
this.lit(this.esc(s));
|
|
240
|
+
}
|
|
241
|
+
function attrs(node) {
|
|
242
|
+
const att = [];
|
|
243
|
+
if (this.options.sourcepos) {
|
|
244
|
+
const pos = node.sourcepos;
|
|
245
|
+
if (pos) {
|
|
246
|
+
att.push(['data-sourcepos', `${String(pos[0][0])}:${String(pos[0][1])}-${String(pos[1][0])}:${String(pos[1][1])}`]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return att;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// quick browser-compatible inheritance
|
|
253
|
+
InternalHTMLRenderer.prototype = Object.create(HtmlRenderer.prototype);
|
|
254
|
+
InternalHTMLRenderer.prototype.text = text;
|
|
255
|
+
InternalHTMLRenderer.prototype.html_inline = html_inline;
|
|
256
|
+
InternalHTMLRenderer.prototype.html_block = html_block;
|
|
257
|
+
InternalHTMLRenderer.prototype.softbreak = softbreak;
|
|
258
|
+
InternalHTMLRenderer.prototype.linebreak = linebreak;
|
|
259
|
+
InternalHTMLRenderer.prototype.link = link;
|
|
260
|
+
InternalHTMLRenderer.prototype.image = image;
|
|
261
|
+
InternalHTMLRenderer.prototype.emph = emph;
|
|
262
|
+
InternalHTMLRenderer.prototype.strong = strong;
|
|
263
|
+
InternalHTMLRenderer.prototype.paragraph = paragraph;
|
|
264
|
+
InternalHTMLRenderer.prototype.heading = heading;
|
|
265
|
+
InternalHTMLRenderer.prototype.code = code;
|
|
266
|
+
InternalHTMLRenderer.prototype.code_block = code_block;
|
|
267
|
+
InternalHTMLRenderer.prototype.thematic_break = thematic_break;
|
|
268
|
+
InternalHTMLRenderer.prototype.block_quote = block_quote;
|
|
269
|
+
InternalHTMLRenderer.prototype.list = list;
|
|
270
|
+
InternalHTMLRenderer.prototype.item = item;
|
|
271
|
+
InternalHTMLRenderer.prototype.custom_inline = custom_inline;
|
|
272
|
+
InternalHTMLRenderer.prototype.custom_block = custom_block;
|
|
273
|
+
InternalHTMLRenderer.prototype.esc = escapeHtmlInText;
|
|
274
|
+
InternalHTMLRenderer.prototype.out = out;
|
|
275
|
+
InternalHTMLRenderer.prototype.tag = tag;
|
|
276
|
+
InternalHTMLRenderer.prototype.attrs = attrs;
|
|
277
|
+
export default InternalHTMLRenderer;
|
|
278
|
+
//# sourceMappingURL=InternalHTMLRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalHTMLRenderer.js","names":["HtmlRenderer","escapeHtmlInText","MESSAGE_CONVERSION_LINE_BREAK","reUnsafeProtocol","reSafeDataProtocol","potentiallyUnsafe","url","test","tag","name","attributes","selfclosing","disableTags","buffer","length","i","attribute","undefined","lastOut","InternalHTMLRenderer","options","softbreak","esc","text","node","out","literal","lit","linebreak","link","entering","attrs","safe","destination","push","title","image","emph","strong","paragraph","grandparent","parent","type","cr","heading","tagName","level","next","unlink","code","code_block","_isFenced","info","pattern","RegExp","replaced","replaceAll","thematic_break","block_quote","list","listType","start","listStart","toString","item","html_inline","html_block","custom_inline","onEnter","onExit","custom_block","s","att","sourcepos","pos","String","prototype","Object","create"],"sources":["../../../../../src/utils/formatString/markdown/InternalHTMLRenderer.ts"],"sourcesContent":["// @ts-nocheck\n// /* eslint-disable camelcase */\n// noinspection JSUnusedGlobalSymbols,JSUnresolvedReference\n\nimport { HtmlRenderer } from 'commonmark';\nimport { escapeHtmlInText, MESSAGE_CONVERSION_LINE_BREAK } from '../../escape';\n\nconst reUnsafeProtocol = /^javascript:|vbscript:|file:|data:/i;\nconst reSafeDataProtocol = /^data:image\\/(?:png|gif|jpeg|webp)/i;\n\nfunction potentiallyUnsafe(url) {\n return reUnsafeProtocol.test(url) && !reSafeDataProtocol.test(url);\n}\n\n// Helper function to produce an HTML tag.\nfunction tag(name, attributes, selfclosing) {\n if (this.disableTags > 0) {\n return;\n }\n this.buffer += `<${name}`;\n if (attributes && attributes.length > 0) {\n let i = 0;\n let attribute;\n // eslint-disable-next-line no-cond-assign\n while ((attribute = attributes[i]) !== undefined) {\n this.buffer += ` ${attribute[0]}=\"${attribute[1]}\"`;\n i++;\n }\n }\n if (selfclosing) {\n this.buffer += ' /';\n }\n this.buffer += '>';\n this.lastOut = '>';\n}\n\nfunction InternalHTMLRenderer(options) {\n // eslint-disable-next-line no-param-reassign\n options = options || {};\n // by default, soft breaks are rendered as newlines in HTML\n // eslint-disable-next-line no-param-reassign\n options.softbreak = options.softbreak || '';\n // set to \"<br />\" to make them hard breaks\n // set to \" \" if you want to ignore line wrapping in source\n this.esc = escapeHtmlInText;\n // escape html with a custom function\n // else use escapeXml\n\n this.disableTags = 0;\n this.lastOut = '\\n';\n this.options = options;\n}\n\n/* Node methods */\n\nfunction text(node) {\n this.out(node.literal);\n}\n\nfunction softbreak() {\n this.lit('\\n');\n}\n\nfunction linebreak() {\n this.lit('\\n');\n}\n\nfunction link(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n if (!(this.options.safe && potentiallyUnsafe(node.destination))) {\n attributes.push(['href', this.esc(node.destination)]);\n }\n if (node.title) {\n attributes.push(['title', this.esc(node.title)]);\n }\n this.tag('a', attributes);\n } else {\n this.tag('/a');\n }\n}\n\nfunction image(node, entering) {\n if (entering) {\n if (this.disableTags === 0) {\n if (this.options.safe && potentiallyUnsafe(node.destination)) {\n this.lit('<img style=\"max-width: 100%\" src=\"\"');\n } else {\n this.lit(`<img src=\"${this.esc(node.destination)}\"`);\n }\n }\n this.disableTags += 1;\n } else {\n this.disableTags -= 1;\n if (this.disableTags === 0) {\n if (node.title) {\n this.lit(` title=\"${this.esc(node.title)}`);\n }\n this.lit('/>');\n }\n }\n}\n\nfunction emph(node, entering) {\n this.tag(entering ? 'em' : '/em');\n}\n\nfunction strong(node, entering) {\n this.tag(entering ? 'strong' : '/strong');\n}\n\nfunction paragraph(node) {\n const grandparent = node.parent.parent;\n\n if (grandparent !== null && grandparent.type === 'list') {\n return;\n }\n\n this.cr();\n}\n\nfunction heading(node, entering) {\n const tagName = `h${node.level}`;\n const attributes = this.attrs(node);\n if (entering) {\n this.cr();\n this.tag(tagName, attributes);\n\n // Removes line break after heading.\n // That line break would be one too many, since headings are block-level elements, and thus already cause a line break behind them.\n if (\n node.next?.type === 'html_block' &&\n node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK\n ) {\n node.next.unlink();\n }\n } else {\n this.tag(`/${tagName}`);\n this.cr();\n }\n}\n\nfunction code(node) {\n this.tag('code class=\"inline-code\"');\n this.out(node.literal);\n this.tag('/code');\n}\n\nfunction code_block(node) {\n if (node._isFenced) {\n this.tag('pre', [['language', node.info]]);\n this.tag('code');\n\n // Removes trailing and leading line break from the code block content.\n const pattern = new RegExp(\n `^(${MESSAGE_CONVERSION_LINE_BREAK}|\\\\n)+|(${MESSAGE_CONVERSION_LINE_BREAK}|\\\\n)+$`,\n 'g',\n );\n const replaced = node.literal.replaceAll(pattern, '');\n this.out(replaced);\n\n this.tag('/code');\n this.tag('/pre');\n\n // Removes line break after code block.\n // That line break would be one too many, since code blocks are block-level elements, and thus already cause a line break behind them.\n if (\n node.next?.type === 'html_block' &&\n node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK\n ) {\n // eslint-disable-next-line no-param-reassign\n node.next.literal = '';\n }\n } else {\n this.out(node.literal);\n }\n}\n\nfunction thematic_break(node) {\n // Removes line break after thematic break.\n // That line break would be one too many, since thematic breaks are block-level elements, and thus already cause a line break behind them.\n if (node.next?.type === 'html_block' && node.next?.literal === MESSAGE_CONVERSION_LINE_BREAK) {\n // eslint-disable-next-line no-param-reassign\n node.next.literal = '';\n }\n\n const attributes = this.attrs(node);\n this.cr();\n this.tag('hr', attributes, true);\n this.cr();\n}\n\nfunction block_quote(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n this.cr();\n this.tag('blockquote', attributes);\n this.cr();\n } else {\n this.cr();\n this.tag('/blockquote');\n this.cr();\n }\n}\n\nfunction list(node, entering) {\n const tagName = node.listType === 'bullet' ? 'ul' : 'ol';\n const attributes = this.attrs(node);\n\n if (entering) {\n const start = node.listStart;\n if (start !== null && start !== 1) {\n attributes.push(['start', start.toString()]);\n }\n this.cr();\n this.tag(tagName, attributes);\n this.cr();\n } else {\n this.cr();\n this.tag(`/${tagName}`);\n this.cr();\n }\n}\n\nfunction item(node, entering) {\n const attributes = this.attrs(node);\n if (entering) {\n this.tag('li', attributes);\n } else {\n this.tag('/li');\n this.cr();\n }\n}\n\nfunction html_inline(node) {\n if (this.options.safe) {\n this.lit('<!-- raw HTML omitted -->');\n } else {\n this.lit(node.literal);\n }\n}\n\nfunction html_block(node) {\n this.cr();\n if (this.options.safe) {\n this.lit('<!-- raw HTML omitted -->');\n } else {\n this.lit(node.literal);\n }\n this.cr();\n}\n\nfunction custom_inline(node, entering) {\n if (entering && node.onEnter) {\n this.lit(node.onEnter);\n } else if (!entering && node.onExit) {\n this.lit(node.onExit);\n }\n}\n\nfunction custom_block(node, entering) {\n this.cr();\n if (entering && node.onEnter) {\n this.lit(node.onEnter);\n } else if (!entering && node.onExit) {\n this.lit(node.onExit);\n }\n this.cr();\n}\n\n/* Helper methods */\n\nfunction out(s) {\n this.lit(this.esc(s));\n}\n\nfunction attrs(node) {\n const att = [];\n if (this.options.sourcepos) {\n const pos = node.sourcepos;\n if (pos) {\n att.push([\n 'data-sourcepos',\n `${String(pos[0][0])}:${String(pos[0][1])}-${String(pos[1][0])}:${String(\n pos[1][1],\n )}`,\n ]);\n }\n }\n return att;\n}\n\n// quick browser-compatible inheritance\nInternalHTMLRenderer.prototype = Object.create(HtmlRenderer.prototype);\n\nInternalHTMLRenderer.prototype.text = text;\nInternalHTMLRenderer.prototype.html_inline = html_inline;\nInternalHTMLRenderer.prototype.html_block = html_block;\nInternalHTMLRenderer.prototype.softbreak = softbreak;\nInternalHTMLRenderer.prototype.linebreak = linebreak;\nInternalHTMLRenderer.prototype.link = link;\nInternalHTMLRenderer.prototype.image = image;\nInternalHTMLRenderer.prototype.emph = emph;\nInternalHTMLRenderer.prototype.strong = strong;\nInternalHTMLRenderer.prototype.paragraph = paragraph;\nInternalHTMLRenderer.prototype.heading = heading;\nInternalHTMLRenderer.prototype.code = code;\nInternalHTMLRenderer.prototype.code_block = code_block;\nInternalHTMLRenderer.prototype.thematic_break = thematic_break;\nInternalHTMLRenderer.prototype.block_quote = block_quote;\nInternalHTMLRenderer.prototype.list = list;\nInternalHTMLRenderer.prototype.item = item;\nInternalHTMLRenderer.prototype.custom_inline = custom_inline;\nInternalHTMLRenderer.prototype.custom_block = custom_block;\n\nInternalHTMLRenderer.prototype.esc = escapeHtmlInText;\n\nInternalHTMLRenderer.prototype.out = out;\nInternalHTMLRenderer.prototype.tag = tag;\nInternalHTMLRenderer.prototype.attrs = attrs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,CAAClB,WAAW,GAAGA,WAAW;AACxDvC,oBAAoB,CAACyD,SAAS,CAACjB,IAAI,GAAGA,IAAI;AAC1CxC,oBAAoB,CAACyD,SAAS,CAACZ,IAAI,GAAGA,IAAI;AAC1C7C,oBAAoB,CAACyD,SAAS,CAACT,aAAa,GAAGA,aAAa;AAC5DhD,oBAAoB,CAACyD,SAAS,CAACN,YAAY,GAAGA,YAAY;AAE1DnD,oBAAoB,CAACyD,SAAS,CAACtD,GAAG,GAAGrB,gBAAgB;AAErDkB,oBAAoB,CAACyD,SAAS,CAACnD,GAAG,GAAGA,GAAG;AACxCN,oBAAoB,CAACyD,SAAS,CAACpE,GAAG,GAAGA,GAAG;AACxCW,oBAAoB,CAACyD,SAAS,CAAC7C,KAAK,GAAGA,KAAK;AAE5C,eAAeZ,oBAAoB","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { Parser } from 'commonmark';
|
|
|
2
2
|
import { escapeHtmlInText, MESSAGE_CONVERSION_LINE_BREAK, MESSAGE_CONVERSION_LINE_BREAK_ESCAPED } from '../../escape';
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
import InternalHTMLRenderer from './InternalHTMLRenderer
|
|
5
|
+
import InternalHTMLRenderer from './InternalHTMLRenderer';
|
|
6
6
|
export const parseMarkdown = text => {
|
|
7
7
|
let newText = text;
|
|
8
8
|
|
|
@@ -15,6 +15,7 @@ export const parseMarkdown = text => {
|
|
|
15
15
|
const commonmarkParser = new Parser();
|
|
16
16
|
// TODO Check if esc needs to be passed to InternalHTMLRenderer.
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
|
|
18
|
+
// @ts-ignore
|
|
18
19
|
const internalHTMLRenderer = new InternalHTMLRenderer({
|
|
19
20
|
esc: escapeHtmlInText
|
|
20
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMarkdown.js","names":["Parser","escapeHtmlInText","MESSAGE_CONVERSION_LINE_BREAK","MESSAGE_CONVERSION_LINE_BREAK_ESCAPED","InternalHTMLRenderer","parseMarkdown","text","newText","replaceAll","commonmarkParser","internalHTMLRenderer","esc","parsedText","parse","render"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { Parser } from 'commonmark';\nimport {\n escapeHtmlInText,\n MESSAGE_CONVERSION_LINE_BREAK,\n MESSAGE_CONVERSION_LINE_BREAK_ESCAPED,\n} from '../../escape';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport InternalHTMLRenderer from './InternalHTMLRenderer
|
|
1
|
+
{"version":3,"file":"formatMarkdown.js","names":["Parser","escapeHtmlInText","MESSAGE_CONVERSION_LINE_BREAK","MESSAGE_CONVERSION_LINE_BREAK_ESCAPED","InternalHTMLRenderer","parseMarkdown","text","newText","replaceAll","commonmarkParser","internalHTMLRenderer","esc","parsedText","parse","render"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { Parser } from 'commonmark';\nimport {\n escapeHtmlInText,\n MESSAGE_CONVERSION_LINE_BREAK,\n MESSAGE_CONVERSION_LINE_BREAK_ESCAPED,\n} from '../../escape';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport InternalHTMLRenderer from './InternalHTMLRenderer';\n\nexport const parseMarkdown = (text: string) => {\n let newText = text;\n\n // Markdown has its own line break handling. For that reason, we need to replace line breaks with a custom element.\n // In this case I chose a custom <br> Tag.\n // Since commonmark doesn't parse markdown in lines with html, the custom <br> Tag needs to be in its own line.\n // Since there are issues, when the <br> Tag + \\n is followed by text, there needs to be a second line break.\n // Thus, we replace \\n with \\n<br>\\n\\n.\n newText = newText.replaceAll(/\\n/gm, `\\n${MESSAGE_CONVERSION_LINE_BREAK}\\n\\n`);\n\n const commonmarkParser = new Parser();\n // TODO Check if esc needs to be passed to InternalHTMLRenderer.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n // @ts-ignore\n const internalHTMLRenderer = new InternalHTMLRenderer({ esc: escapeHtmlInText });\n\n // Converts markdown to HTML.\n const parsedText = commonmarkParser.parse(newText);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n newText = internalHTMLRenderer.render(parsedText) as string;\n\n // The Linebreak handling of markdown is ignored, by removing \\n. Then the custom <br> Tags are converted back to \\n.\n newText = newText.replaceAll(/\\n/gm, '');\n newText = newText\n .replaceAll(MESSAGE_CONVERSION_LINE_BREAK, '\\n')\n .replaceAll(MESSAGE_CONVERSION_LINE_BREAK_ESCAPED, '\\n');\n\n return newText;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,YAAY;AACnC,SACIC,gBAAgB,EAChBC,6BAA6B,EAC7BC,qCAAqC,QAClC,cAAc;AACrB;AACA;AACA,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,OAAO,MAAMC,aAAa,GAAIC,IAAY,IAAK;EAC3C,IAAIC,OAAO,GAAGD,IAAI;;EAElB;EACA;EACA;EACA;EACA;EACAC,OAAO,GAAGA,OAAO,CAACC,UAAU,CAAC,MAAM,EAAE,KAAKN,6BAA6B,MAAM,CAAC;EAE9E,MAAMO,gBAAgB,GAAG,IAAIT,MAAM,CAAC,CAAC;EACrC;EACA;EACA;EACA,MAAMU,oBAAoB,GAAG,IAAIN,oBAAoB,CAAC;IAAEO,GAAG,EAAEV;EAAiB,CAAC,CAAC;;EAEhF;EACA,MAAMW,UAAU,GAAGH,gBAAgB,CAACI,KAAK,CAACN,OAAO,CAAC;EAClD;EACAA,OAAO,GAAGG,oBAAoB,CAACI,MAAM,CAACF,UAAU,CAAW;;EAE3D;EACAL,OAAO,GAAGA,OAAO,CAACC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;EACxCD,OAAO,GAAGA,OAAO,CACZC,UAAU,CAACN,6BAA6B,EAAE,IAAI,CAAC,CAC/CM,UAAU,CAACL,qCAAqC,EAAE,IAAI,CAAC;EAE5D,OAAOI,OAAO;AAClB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/format",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.651",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "4ed5eefd210a5a9caded6f2f9a08a24b3428251a"
|
|
73
73
|
}
|