@raketa-builder/support 1.4.5 → 1.4.6

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