@raketa-builder/support 1.4.9 → 1.4.11
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 +48 -51
- package/package.json +3 -3
package/dist/toHTML.js
CHANGED
|
@@ -2,62 +2,59 @@ import './chunk-ORMEWXMH.js';
|
|
|
2
2
|
import { Marked } from 'marked';
|
|
3
3
|
import parseAttrs from 'attributes-parser';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
5
|
+
const markedInstance = new Marked();
|
|
6
|
+
const attributes = {
|
|
7
|
+
name: "attributes",
|
|
8
|
+
level: "inline",
|
|
9
|
+
start(src) {
|
|
10
|
+
return src[0] === "{" ? 0 : void 0;
|
|
11
|
+
},
|
|
12
|
+
tokenizer(src, tokens) {
|
|
13
|
+
const match = /^\{([^}]*)\}/.exec(src);
|
|
14
|
+
if (match && tokens.length > 0) {
|
|
15
|
+
const last = tokens[tokens.length - 1];
|
|
16
|
+
if (last.type === "link" && last.raw) {
|
|
17
|
+
try {
|
|
18
|
+
last.attributes = parseAttrs(match[1]);
|
|
19
|
+
return {
|
|
20
|
+
type: "attributes",
|
|
21
|
+
raw: match[0]
|
|
22
|
+
};
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return false;
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
return false;
|
|
32
|
-
},
|
|
33
|
-
renderer(token) {
|
|
34
|
-
return "";
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
renderer(token) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const renderer = {
|
|
35
|
+
link(token) {
|
|
36
|
+
let attributeString = "";
|
|
37
|
+
if (token.attributes) {
|
|
38
|
+
attributeString = Object.entries(token.attributes).map(([key, value]) => ` ${key}="${value}"`).join("");
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
return `<a href="${token.href}"${attributeString}>${token.text}</a>`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
markedInstance.use({
|
|
44
|
+
extensions: [attributes],
|
|
45
|
+
renderer,
|
|
46
|
+
useNewRenderer: true
|
|
47
|
+
});
|
|
48
|
+
markedInstance.setOptions({
|
|
49
|
+
breaks: true,
|
|
50
|
+
gfm: true,
|
|
51
|
+
headerIds: false,
|
|
52
|
+
mangle: false
|
|
53
|
+
});
|
|
54
|
+
const toHTML = (string, inline = false) => {
|
|
55
|
+
if (!string) return "";
|
|
58
56
|
try {
|
|
59
|
-
|
|
60
|
-
return result;
|
|
57
|
+
return inline ? markedInstance.parseInline(string) : markedInstance.parse(string);
|
|
61
58
|
} catch (error) {
|
|
62
59
|
console.error("Parse error:", error);
|
|
63
60
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/support",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"marked": "^16.1.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@biomejs/biome": "1.
|
|
38
|
-
"@types/react": "19.
|
|
37
|
+
"@biomejs/biome": "2.1.2",
|
|
38
|
+
"@types/react": "19.1.8",
|
|
39
39
|
"@types/react-dom": "19.1.6",
|
|
40
40
|
"prettier": "3.6.2",
|
|
41
41
|
"react": "19.1.0",
|