@raketa-builder/support 1.4.6 → 1.4.8

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.
Files changed (2) hide show
  1. package/dist/toHTML.js +21 -10
  2. package/package.json +1 -1
package/dist/toHTML.js CHANGED
@@ -3,24 +3,28 @@ import { Marked } from 'marked';
3
3
  import parseAttrs from 'attributes-parser';
4
4
 
5
5
  const toHTML = (string, inline = false) => {
6
- if (!string) return "";
7
6
  const markedInstance = new Marked();
8
7
  const attributes = {
9
8
  name: "attributes",
10
9
  level: "inline",
11
10
  start(src) {
12
- return src[0] === "{" ? 0 : void 0;
11
+ const result = src[0] === "{" ? 0 : void 0;
12
+ return result;
13
13
  },
14
14
  tokenizer(src, tokens) {
15
15
  const match = /^\{([^}]*)\}/.exec(src);
16
16
  if (match && tokens.length > 0) {
17
17
  const last = tokens[tokens.length - 1];
18
- if (last.type === "link" && last.raw && src.startsWith("{", 0)) {
19
- last.attributes = parseAttrs(match[1]);
20
- return {
21
- type: "attributes",
22
- raw: match[0]
23
- };
18
+ if (last.type === "link" && last.raw) {
19
+ try {
20
+ last.attributes = parseAttrs(match[1]);
21
+ return {
22
+ type: "attributes",
23
+ raw: match[0]
24
+ };
25
+ } catch (error) {
26
+ return false;
27
+ }
24
28
  }
25
29
  }
26
30
  return false;
@@ -35,7 +39,8 @@ const toHTML = (string, inline = false) => {
35
39
  if (token.attributes) {
36
40
  attributeString = Object.entries(token.attributes).map(([key, value]) => ` ${key}="${value}"`).join("");
37
41
  }
38
- return `<a href="${token.href}"${attributeString}>${token.text}</a>`;
42
+ const result = `<a href="${token.href}"${attributeString}>${token.text}</a>`;
43
+ return result;
39
44
  }
40
45
  };
41
46
  markedInstance.use({
@@ -49,7 +54,13 @@ const toHTML = (string, inline = false) => {
49
54
  headerIds: false,
50
55
  mangle: false
51
56
  });
52
- return inline ? markedInstance.parseInline(string) : markedInstance.parse(string);
57
+ try {
58
+ const result = inline ? markedInstance.parseInline(string) : markedInstance.parse(string);
59
+ return result;
60
+ } catch (error) {
61
+ console.error("Parse error:", error);
62
+ throw error;
63
+ }
53
64
  };
54
65
  var toHTML_default = toHTML;
55
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/support",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",