@tabnas/markdown 0.4.1 → 0.5.0

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/dist/html.js ADDED
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ /* Copyright (c) 2021-2026 Richard Rodger, MIT License */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderHTML = renderHTML;
5
+ const common_ts_1 = require("./common.js");
6
+ const options_ts_1 = require("./options.js");
7
+ /**
8
+ * Render `doc` (a tree that has been through both parse phases) as HTML.
9
+ *
10
+ * Only `options.breaks` affects the output: it turns soft line breaks into
11
+ * hard ones. `gfm` is a parse-time concern — by the time a `del` node exists
12
+ * the renderer just prints it.
13
+ */
14
+ function renderHTML(doc, options) {
15
+ const opts = (0, options_ts_1.resolveOptions)(options);
16
+ // §6.9 soft line breaks: rendered as a newline, or as a hard break when the
17
+ // caller asks for `breaks`.
18
+ const softbreak = opts.breaks ? '<br />\n' : '\n';
19
+ let buf = '';
20
+ // Tracks whether the buffer is positioned at the start of a line, which is
21
+ // the only thing `cr()` needs to know. An empty buffer counts as at-line-
22
+ // start, so a leading `cr()` (every top-level block opens with one) writes
23
+ // nothing.
24
+ let atLineStart = true;
25
+ function lit(s) {
26
+ // An empty write must not claim the line is dirty, or the next `cr()`
27
+ // would insert a spurious newline.
28
+ if ('' === s)
29
+ return;
30
+ buf += s;
31
+ atLineStart = '\n' === s.charAt(s.length - 1);
32
+ }
33
+ function cr() {
34
+ if (!atLineStart)
35
+ lit('\n');
36
+ }
37
+ function tag(name, attrs, selfClosing) {
38
+ let s = '<' + name;
39
+ if (undefined !== attrs) {
40
+ for (const attr of attrs) {
41
+ s += ' ' + attr[0] + '="' + attr[1] + '"';
42
+ }
43
+ }
44
+ if (true === selfClosing)
45
+ s += ' /';
46
+ lit(s + '>');
47
+ }
48
+ const walker = doc.walker();
49
+ let event = walker.next();
50
+ while (null !== event) {
51
+ const node = event.node;
52
+ const entering = event.entering;
53
+ switch (node.type) {
54
+ case 'document':
55
+ break;
56
+ case 'paragraph': {
57
+ // §5.3: "if a list is tight, we remove the <p> tags from the item
58
+ // contents". The paragraph's grandparent is the list — a paragraph
59
+ // whose grandparent is a list is necessarily an item's direct child.
60
+ const grandparent = null === node.parent ? null : node.parent.parent;
61
+ if (null !== grandparent &&
62
+ 'list' === grandparent.type &&
63
+ null !== grandparent.listData &&
64
+ grandparent.listData.tight) {
65
+ break;
66
+ }
67
+ if (entering) {
68
+ cr();
69
+ tag('p');
70
+ }
71
+ else {
72
+ tag('/p');
73
+ cr();
74
+ }
75
+ break;
76
+ }
77
+ case 'heading': {
78
+ const name = 'h' + node.level;
79
+ if (entering) {
80
+ cr();
81
+ tag(name);
82
+ }
83
+ else {
84
+ tag('/' + name);
85
+ cr();
86
+ }
87
+ break;
88
+ }
89
+ case 'thematic_break':
90
+ cr();
91
+ tag('hr', undefined, true);
92
+ cr();
93
+ break;
94
+ case 'block_quote':
95
+ cr();
96
+ tag(entering ? 'blockquote' : '/blockquote');
97
+ cr();
98
+ break;
99
+ case 'list': {
100
+ const data = node.listData;
101
+ const ordered = null !== data && 'ordered' === data.type;
102
+ const name = ordered ? 'ol' : 'ul';
103
+ if (entering) {
104
+ const attrs = [];
105
+ // §5.3: the start number is only rendered when it is not 1 — and
106
+ // `start="0"` is meaningful, so this is an inequality, not a
107
+ // truthiness test.
108
+ if (ordered && null !== data && 1 !== data.start) {
109
+ attrs.push(['start', String(data.start)]);
110
+ }
111
+ cr();
112
+ tag(name, attrs);
113
+ }
114
+ else {
115
+ cr();
116
+ tag('/' + name);
117
+ }
118
+ cr();
119
+ break;
120
+ }
121
+ case 'item':
122
+ // No `cr()` after `<li>`: a tight item renders `<li>text</li>`, and a
123
+ // loose one gets its newline from the leading `cr()` of the first
124
+ // child block.
125
+ if (entering) {
126
+ tag('li');
127
+ }
128
+ else {
129
+ tag('/li');
130
+ cr();
131
+ }
132
+ break;
133
+ case 'code_block': {
134
+ const attrs = [];
135
+ // §4.5: "the first word of the info string is typically used to
136
+ // specify the language". The info string arrives from the block phase
137
+ // already backslash-unescaped and entity-decoded; only the escaping
138
+ // for attribute context is left to do here.
139
+ const info = null === node.info ? '' : node.info;
140
+ const firstWord = '' === info ? '' : info.split(/\s+/)[0];
141
+ if ('' !== firstWord) {
142
+ attrs.push(['class', 'language-' + (0, common_ts_1.escapeXml)(firstWord)]);
143
+ }
144
+ cr();
145
+ tag('pre');
146
+ tag('code', attrs);
147
+ // The block phase guarantees the literal already ends with a newline
148
+ // (or is empty, for an empty fenced block, which renders as
149
+ // `<pre><code></code></pre>`).
150
+ lit((0, common_ts_1.escapeXml)(null === node.literal ? '' : node.literal));
151
+ tag('/code');
152
+ tag('/pre');
153
+ cr();
154
+ break;
155
+ }
156
+ case 'html_block':
157
+ // §4.6: raw HTML passes through verbatim, unescaped.
158
+ cr();
159
+ lit(null === node.literal ? '' : node.literal);
160
+ cr();
161
+ break;
162
+ case 'text':
163
+ lit((0, common_ts_1.escapeXml)(null === node.literal ? '' : node.literal));
164
+ break;
165
+ case 'softbreak':
166
+ lit(softbreak);
167
+ break;
168
+ case 'linebreak':
169
+ tag('br', undefined, true);
170
+ cr();
171
+ break;
172
+ case 'code':
173
+ tag('code');
174
+ lit((0, common_ts_1.escapeXml)(null === node.literal ? '' : node.literal));
175
+ tag('/code');
176
+ break;
177
+ case 'html_inline':
178
+ lit(null === node.literal ? '' : node.literal);
179
+ break;
180
+ case 'emph':
181
+ tag(entering ? 'em' : '/em');
182
+ break;
183
+ case 'strong':
184
+ tag(entering ? 'strong' : '/strong');
185
+ break;
186
+ case 'del':
187
+ tag(entering ? 'del' : '/del');
188
+ break;
189
+ case 'link':
190
+ if (entering) {
191
+ const attrs = [['href', (0, common_ts_1.escapeXml)((0, common_ts_1.normalizeURI)(destinationOf(node)))]];
192
+ // An empty title is dropped: `[link](/url "")` renders as a bare
193
+ // `<a href="/url">`.
194
+ if (null !== node.title && '' !== node.title) {
195
+ attrs.push(['title', (0, common_ts_1.escapeXml)(node.title)]);
196
+ }
197
+ tag('a', attrs);
198
+ }
199
+ else {
200
+ tag('/a');
201
+ }
202
+ break;
203
+ case 'image': {
204
+ if (entering) {
205
+ const attrs = [
206
+ ['src', (0, common_ts_1.escapeXml)((0, common_ts_1.normalizeURI)(destinationOf(node)))],
207
+ ['alt', (0, common_ts_1.escapeXml)(altText(node))],
208
+ ];
209
+ if (null !== node.title && '' !== node.title) {
210
+ attrs.push(['title', (0, common_ts_1.escapeXml)(node.title)]);
211
+ }
212
+ tag('img', attrs, true);
213
+ // The children have been consumed into `alt`; jump the walk
214
+ // straight to this image's exit event so they are not also
215
+ // rendered as markup.
216
+ walker.resumeAt(node, false);
217
+ }
218
+ break;
219
+ }
220
+ }
221
+ event = walker.next();
222
+ }
223
+ return buf;
224
+ }
225
+ function destinationOf(node) {
226
+ return null === node.destination ? '' : node.destination;
227
+ }
228
+ /**
229
+ * §6.4 images: "the image description gets represented as the `alt`
230
+ * attribute" — as plain text. Descend the subtree keeping the text and
231
+ * code-span literals and dropping the markup wrappers, so
232
+ * `![foo *bar*](/url)` yields `alt="foo bar"` and a nested link contributes
233
+ * only its text.
234
+ *
235
+ * Raw inline HTML and line breaks inside a description are not exercised by
236
+ * the spec suite and the two reference implementations disagree: cmark
237
+ * escapes the raw HTML into the attribute and turns breaks into spaces,
238
+ * commonmark.js emits the HTML verbatim (producing a malformed attribute)
239
+ * and turns breaks into newlines. We keep the literal — escaped, since the
240
+ * result is attribute-context text — and follow commonmark.js on breaks.
241
+ */
242
+ function altText(image) {
243
+ let alt = '';
244
+ const walker = image.walker();
245
+ walker.next(); // discard the image's own entering event
246
+ let event = walker.next();
247
+ while (null !== event && event.node !== image) {
248
+ const node = event.node;
249
+ if (event.entering) {
250
+ switch (node.type) {
251
+ case 'text':
252
+ case 'code':
253
+ case 'html_inline':
254
+ alt += null === node.literal ? '' : node.literal;
255
+ break;
256
+ case 'softbreak':
257
+ case 'linebreak':
258
+ alt += '\n';
259
+ break;
260
+ default:
261
+ // Containers (emph, strong, link, a nested image) contribute
262
+ // nothing themselves; the walk still descends into their children.
263
+ break;
264
+ }
265
+ }
266
+ event = walker.next();
267
+ }
268
+ return alt;
269
+ }
270
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":";AAAA,yDAAyD;;AAsCzD,gCAwOC;AAtPD,2CAAqD;AACrD,6CAA6C;AAM7C;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,OAAgC;IACtE,MAAM,IAAI,GAAG,IAAA,2BAAc,EAAC,OAAO,CAAC,CAAA;IAEpC,4EAA4E;IAC5E,4BAA4B;IAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAA;IAEjD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,2EAA2E;IAC3E,0EAA0E;IAC1E,2EAA2E;IAC3E,WAAW;IACX,IAAI,WAAW,GAAG,IAAI,CAAA;IAEtB,SAAS,GAAG,CAAC,CAAS;QACpB,sEAAsE;QACtE,mCAAmC;QACnC,IAAI,EAAE,KAAK,CAAC;YAAE,OAAM;QACpB,GAAG,IAAI,CAAC,CAAA;QACR,WAAW,GAAG,IAAI,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED,SAAS,EAAE;QACT,IAAI,CAAC,WAAW;YAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAED,SAAS,GAAG,CAAC,IAAY,EAAE,KAAc,EAAE,WAAqB;QAC9D,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,CAAA;QAClB,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,CAAC,IAAI,G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AAC,OAAO,CAAA;oBAChD,MAAK;gBACP,KAAK,WAAW,CAAC;gBACjB,KAAK,WAAW;oBACd,GAAG,IAAI,IAAI,CAAA;oBACX,MAAK;gBACP;oBACE,6DAA6D;oBAC7D,mEAAmE;oBACnE,MAAK;YACT,CAAC;QACH,CAAC;QACD,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IACvB,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { MdNode } from './node.ts';
2
+ import type { ParserOptions, RefMap } from './options.ts';
3
+ /**
4
+ * Phase 2 entry point: walk the block tree and parse the string content of
5
+ * every paragraph and heading into inline children.
6
+ */
7
+ export declare function parseInlines(doc: MdNode, refmap: RefMap, options: ParserOptions): void;
8
+ /**
9
+ * Consume link reference definitions from the front of a paragraph's raw
10
+ * content, adding them to `refmap`. Returns the number of characters
11
+ * consumed, or 0 if `s` does not start with a definition.
12
+ */
13
+ export declare function parseReference(s: string, refmap: RefMap): number;