@raketa-builder/support 1.4.3 → 1.4.4
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/toHTML.js +46 -12
- package/package.json +3 -2
package/dist/toHTML.js
CHANGED
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
import './chunk-ORMEWXMH.js';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { marked } from 'marked';
|
|
3
|
+
import parseAttrs from 'attributes-parser';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const attributes = {
|
|
6
|
+
name: "attributes",
|
|
7
|
+
level: "inline",
|
|
8
|
+
start(src) {
|
|
9
|
+
var _a;
|
|
10
|
+
return (_a = src.match(/\{([^}]*)\}/g)) == null ? void 0 : _a.index;
|
|
11
|
+
},
|
|
12
|
+
tokenizer(src, tokens) {
|
|
13
|
+
const match = src.match(/\{([^}]*)\}/g);
|
|
14
|
+
if (match && tokens.length > 0) {
|
|
15
|
+
const last = tokens[tokens.length - 1];
|
|
16
|
+
if (last.type === "link") {
|
|
17
|
+
last.attributes = parseAttrs(match[1]);
|
|
18
|
+
return {
|
|
19
|
+
type: "attributes",
|
|
20
|
+
raw: match[0]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
renderer(token) {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const renderer = {
|
|
30
|
+
link(token) {
|
|
31
|
+
let attributeString = "";
|
|
32
|
+
if (token.attributes) {
|
|
33
|
+
attributeString = Object.entries(token.attributes).map(([key, value]) => ` ${key}="${value}"`).join("");
|
|
34
|
+
}
|
|
35
|
+
return `<a href="${token.href}"${attributeString}>${token.text}</a>`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
marked.use({
|
|
39
|
+
extensions: [attributes],
|
|
40
|
+
renderer,
|
|
41
|
+
useNewRenderer: true
|
|
42
|
+
});
|
|
43
|
+
marked.setOptions({
|
|
44
|
+
breaks: true,
|
|
45
|
+
gfm: true,
|
|
46
|
+
headerIds: false,
|
|
47
|
+
mangle: false
|
|
14
48
|
});
|
|
15
49
|
const toHTML = (string, inline = false) => {
|
|
16
50
|
if (!string) return;
|
|
17
|
-
return inline ?
|
|
51
|
+
return inline ? marked.parseInline(string) : marked.parse(string);
|
|
18
52
|
};
|
|
19
53
|
var toHTML_default = toHTML;
|
|
20
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/support",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"markdown-it": "13.0.1",
|
|
33
|
-
"markdown-it-attrs": "4.1.4"
|
|
33
|
+
"markdown-it-attrs": "4.1.4",
|
|
34
|
+
"marked": "^16.1.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@biomejs/biome": "1.9.4",
|