@jxsuite/parser 0.18.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.
- package/package.json +1 -1
- package/src/transpile.js +13 -2
package/package.json
CHANGED
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
|
-
*
|
|
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
|
-
|
|
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
|
|