@raketa-builder/support 1.4.8 → 1.4.10

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