van-mdx 0.0.0 → 0.0.1
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/README.md +5 -3
- package/package.json +1 -1
- package/src/transpiler/process.js +4 -6
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ A Markdown preprocessor for [Vanjs](https://vanjs.org/).
|
|
|
4
4
|
It combines the simplicity of Markdown syntax with the power and flexibility of ***Javascript***
|
|
5
5
|
|
|
6
6
|
## Demos :
|
|
7
|
+
- ***Hello World*** :
|
|
8
|
+
[](https://stackblitz.com/fork/github/zakarialaoui10/van-mdx/tree/main/examples/hello-world?file=src%2Fcontent%2FArticle.mdx)
|
|
7
9
|
|
|
8
10
|
## Install :
|
|
9
11
|
|
|
@@ -28,10 +30,10 @@ export default defineConfig({
|
|
|
28
30
|
- ***Article.mdx :***
|
|
29
31
|
```jsx
|
|
30
32
|
---
|
|
31
|
-
title : Van-Mdx Starter
|
|
32
|
-
name : world
|
|
33
|
+
title : "Van-Mdx Starter"
|
|
34
|
+
name : "world"
|
|
33
35
|
__props__ :
|
|
34
|
-
background : tomato
|
|
36
|
+
background : "tomato"
|
|
35
37
|
data : []
|
|
36
38
|
---
|
|
37
39
|
|
package/package.json
CHANGED
|
@@ -57,13 +57,15 @@ const processMDAST = (markdownAST) => {
|
|
|
57
57
|
const childNodes = node.children.map(transformNode).join(', ');
|
|
58
58
|
return hyperscript("li", "{}", childNodes);
|
|
59
59
|
};
|
|
60
|
-
|
|
60
|
+
case 'inlineCode' : {
|
|
61
|
+
return `van.tags.code("${node.value}")`
|
|
62
|
+
}
|
|
61
63
|
case 'code': {
|
|
62
64
|
hasCode = true;
|
|
63
65
|
// const language = node.lang ? `{ 'data-lang': '${node.lang}' }` : '';
|
|
64
66
|
const highlightedCode = hljs.highlightAuto(node.value, [node.lang || '']).value;
|
|
65
67
|
const formatedCode = highlightedCode.replace(/(\r\n|\n|\r)/g, "<br>")
|
|
66
|
-
return `HTMLWrapper('<pre>${formatedCode}</pre>').element`
|
|
68
|
+
return `HTMLWrapper('<pre><code>${formatedCode}</code></pre>').element`
|
|
67
69
|
}
|
|
68
70
|
case 'blockquote': {
|
|
69
71
|
const childNodes = node.children.map(transformNode).join(', ');
|
|
@@ -78,10 +80,6 @@ const processMDAST = (markdownAST) => {
|
|
|
78
80
|
const thead = hyperscript("thead", "{}", hyperscript("tr", "{}", headerRows));
|
|
79
81
|
const tbody = hyperscript("tbody", "{}", bodyRows);
|
|
80
82
|
return hyperscript("table", "{}", [thead, tbody].join(","))
|
|
81
|
-
// console.log({thead, tbody})
|
|
82
|
-
// const thead = `h('thead', {}, h('tr', {}, ${headerRows})`;
|
|
83
|
-
// const tbody = `h('tbody', {}, ${bodyRows})`
|
|
84
|
-
// return `h('table', {}, ${thead}), ${tbody}).style({border : "1px solid darkblue", borderCollapse: "collapse"}`;
|
|
85
83
|
}
|
|
86
84
|
case 'tableRow': {
|
|
87
85
|
const cells = node.children.map(transformNode).join(', ');
|