@jxsuite/parser 0.17.0 → 0.19.0

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/package.json +2 -2
  2. package/src/transpile.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxsuite/parser",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Jx markdown parser and external class integration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,6 +41,6 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@happy-dom/global-registrator": "^20.9.0",
44
- "@jxsuite/runtime": "^0.15.0"
44
+ "@jxsuite/runtime": "^0.18.0"
45
45
  }
46
46
  }
package/src/transpile.js CHANGED
@@ -29,13 +29,21 @@ export { htmlToJx };
29
29
  const JX_DOLLAR_KEYS = new Set(["prototype", "ref", "component", "props", "switch", "elements"]);
30
30
 
31
31
  /**
32
- * Re-add `$` prefix to known Jx reserved keywords.
32
+ * Annotation keys written as `--key` in markdown directives, mapped to `$key` in JX JSON. These use
33
+ * `--` prefix to avoid collision with HTML attributes like `title`.
34
+ */
35
+ const JX_ANNOTATION_KEYS = new Set(["title", "description"]);
36
+
37
+ /**
38
+ * Re-add `$` prefix to known Jx reserved keywords and annotation keys.
33
39
  *
34
40
  * @param {string} key
35
41
  * @returns {string}
36
42
  */
37
43
  export function jxKey(key) {
38
- return JX_DOLLAR_KEYS.has(key) ? `$${key}` : key;
44
+ if (JX_DOLLAR_KEYS.has(key)) return `$${key}`;
45
+ if (key.startsWith("--") && JX_ANNOTATION_KEYS.has(key.slice(2))) return `$${key.slice(2)}`;
46
+ return key;
39
47
  }
40
48
 
41
49
  /**
@@ -48,6 +56,9 @@ export function mdKey(key) {
48
56
  if (key.startsWith("$") && JX_DOLLAR_KEYS.has(key.slice(1))) {
49
57
  return key.slice(1);
50
58
  }
59
+ if (key.startsWith("$") && JX_ANNOTATION_KEYS.has(key.slice(1))) {
60
+ return `--${key.slice(1)}`;
61
+ }
51
62
  return key;
52
63
  }
53
64