@threadlabs/looma 0.28.18 → 0.28.19
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/editor/chunks/extensions.js +5 -2
- package/markdown/fixtures.js +2 -0
- package/markdown/index.d.ts +3 -1
- package/markdown/index.js +5 -2
- package/package.json +1 -1
|
@@ -311,10 +311,13 @@ function parseLoomaFenceInfo(info) {
|
|
|
311
311
|
}
|
|
312
312
|
var MAPPING_KEY = /^(?:[^\s#:'"\-?,[\]{}&*!|>%@`][^:\n]*?|"[^"\n]*"|'[^'\n]*')[ \t]*:(?:[ \t]|$)/;
|
|
313
313
|
var NOTATION = /[ \t]*(?:\/\/|#|--|<!--|\{?\/\*)[ \t]*\[!code highlight(?::(\d+))?\][ \t]*(?:-->|\*\/\}?)?[ \t]*$/;
|
|
314
|
+
var ESCAPED_NOTATION = /\[\\(\\*!code highlight)/g;
|
|
314
315
|
/**
|
|
315
316
|
* Applies code notation: a line ending in a `[!code highlight]` comment is highlighted and loses
|
|
316
317
|
* the comment, `[!code highlight:3]` covers three lines, and a marker alone on its line is removed
|
|
317
|
-
* with the line and applies to the lines after it.
|
|
318
|
+
* with the line and applies to the lines after it. A backslash between `[` and `!` escapes a
|
|
319
|
+
* marker, `[\!code highlight]`, which then shows as text with one backslash fewer and highlights
|
|
320
|
+
* nothing.
|
|
318
321
|
* @contract Returns the code a reader sees and its highlighted line numbers, from 1, ascending.
|
|
319
322
|
* ponytail: matched on source lines, so a string that ends in the marker counts too.
|
|
320
323
|
*/
|
|
@@ -333,7 +336,7 @@ function applyLoomaCodeNotation(code) {
|
|
|
333
336
|
for (let count = 0; count < Number(match[1] ?? 1); count++) lines.add(kept.length + (own ? 0 : 1) + count);
|
|
334
337
|
}
|
|
335
338
|
return {
|
|
336
|
-
code: kept.join("\n"),
|
|
339
|
+
code: kept.join("\n").replace(ESCAPED_NOTATION, "[$1"),
|
|
337
340
|
lines: [...lines].sort((a, b) => a - b)
|
|
338
341
|
};
|
|
339
342
|
}
|
package/markdown/fixtures.js
CHANGED
|
@@ -25,6 +25,8 @@ var files = /* #__PURE__ */ Object.assign({
|
|
|
25
25
|
"../../markdown-fixtures/code-blocks/long-fence.md": "````md\n```ts\nconst a = 1;\n```\n````\n",
|
|
26
26
|
"../../markdown-fixtures/code-meta/notation-alone.html": "<pre><code class=\"language-ts\">const host = "localhost";\nconst port = 8080;</code></pre>\n",
|
|
27
27
|
"../../markdown-fixtures/code-meta/notation-alone.md": "```ts\n// [!code highlight:2]\nconst host = \"localhost\";\nconst port = 8080;\n```\n",
|
|
28
|
+
"../../markdown-fixtures/code-meta/notation-escaped.html": "<pre><code class=\"language-md\">const port = 8080; // [!code highlight]\nconst host = "localhost"; // [\\!code highlight:2]</code></pre>\n",
|
|
29
|
+
"../../markdown-fixtures/code-meta/notation-escaped.md": "```md\nconst port = 8080; // [\\!code highlight]\nconst host = \"localhost\"; // [\\\\!code highlight:2]\n```\n",
|
|
28
30
|
"../../markdown-fixtures/code-meta/notation.html": "<pre><code class=\"language-ts\">const port = 8080;</code></pre>\n",
|
|
29
31
|
"../../markdown-fixtures/code-meta/notation.md": "```ts\nconst port = 8080; // [!code highlight]\n```\n",
|
|
30
32
|
"../../markdown-fixtures/code-meta/title-lines.html": "<pre><code class=\"language-ts\" data-meta=\"title="config.ts" {1,3-4} :line-numbers\">export default {\n name: "docs",\n base: "/docs/",\n};</code></pre>\n",
|
package/markdown/index.d.ts
CHANGED
|
@@ -95,7 +95,9 @@ export declare function parseLoomaFenceInfo(info: string): LoomaFenceInfo;
|
|
|
95
95
|
/**
|
|
96
96
|
* Applies code notation: a line ending in a `[!code highlight]` comment is highlighted and loses
|
|
97
97
|
* the comment, `[!code highlight:3]` covers three lines, and a marker alone on its line is removed
|
|
98
|
-
* with the line and applies to the lines after it.
|
|
98
|
+
* with the line and applies to the lines after it. A backslash between `[` and `!` escapes a
|
|
99
|
+
* marker, `[\!code highlight]`, which then shows as text with one backslash fewer and highlights
|
|
100
|
+
* nothing.
|
|
99
101
|
* @contract Returns the code a reader sees and its highlighted line numbers, from 1, ascending.
|
|
100
102
|
* ponytail: matched on source lines, so a string that ends in the marker counts too.
|
|
101
103
|
*/
|
package/markdown/index.js
CHANGED
|
@@ -206,10 +206,13 @@ function parseLoomaFenceInfo(info) {
|
|
|
206
206
|
}
|
|
207
207
|
var MAPPING_KEY = /^(?:[^\s#:'"\-?,[\]{}&*!|>%@`][^:\n]*?|"[^"\n]*"|'[^'\n]*')[ \t]*:(?:[ \t]|$)/;
|
|
208
208
|
var NOTATION = /[ \t]*(?:\/\/|#|--|<!--|\{?\/\*)[ \t]*\[!code highlight(?::(\d+))?\][ \t]*(?:-->|\*\/\}?)?[ \t]*$/;
|
|
209
|
+
var ESCAPED_NOTATION = /\[\\(\\*!code highlight)/g;
|
|
209
210
|
/**
|
|
210
211
|
* Applies code notation: a line ending in a `[!code highlight]` comment is highlighted and loses
|
|
211
212
|
* the comment, `[!code highlight:3]` covers three lines, and a marker alone on its line is removed
|
|
212
|
-
* with the line and applies to the lines after it.
|
|
213
|
+
* with the line and applies to the lines after it. A backslash between `[` and `!` escapes a
|
|
214
|
+
* marker, `[\!code highlight]`, which then shows as text with one backslash fewer and highlights
|
|
215
|
+
* nothing.
|
|
213
216
|
* @contract Returns the code a reader sees and its highlighted line numbers, from 1, ascending.
|
|
214
217
|
* ponytail: matched on source lines, so a string that ends in the marker counts too.
|
|
215
218
|
*/
|
|
@@ -228,7 +231,7 @@ function applyLoomaCodeNotation(code) {
|
|
|
228
231
|
for (let count = 0; count < Number(match[1] ?? 1); count++) lines.add(kept.length + (own ? 0 : 1) + count);
|
|
229
232
|
}
|
|
230
233
|
return {
|
|
231
|
-
code: kept.join("\n"),
|
|
234
|
+
code: kept.join("\n").replace(ESCAPED_NOTATION, "[$1"),
|
|
232
235
|
lines: [...lines].sort((a, b) => a - b)
|
|
233
236
|
};
|
|
234
237
|
}
|