mdzjs 0.0.8 → 0.0.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.
- package/README.md +2 -2
- package/package.json +4 -3
- package/src/bundlers/vite.js +15 -0
- package/src/transpiler/process.js +10 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> This project is part of the [ZikoJS](https://github.com/zakarialaoui10/ziko.js) ecosystem.
|
|
3
3
|
|
|
4
4
|
# MDZjs
|
|
5
|
-
A Markdown preprocessor for Zikojs.
|
|
5
|
+
A Markdown preprocessor for Zikojs.
|
|
6
6
|
It combines the simplicity of Markdown syntax with the power and flexibility of ***Javascript***
|
|
7
7
|
|
|
8
8
|
## Install
|
|
@@ -25,7 +25,7 @@ export default defineConfig({
|
|
|
25
25
|
|
|
26
26
|
*Article.mdz :*
|
|
27
27
|
|
|
28
|
-
```
|
|
28
|
+
```jsx
|
|
29
29
|
---
|
|
30
30
|
title : MDZ
|
|
31
31
|
name : world
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdzjs",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"description": "markdown preprocessor for zikojs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"markdown",
|
|
23
23
|
"remark",
|
|
24
24
|
"mdx",
|
|
25
|
-
"preprocessor"
|
|
25
|
+
"preprocessor",
|
|
26
|
+
"astro-integration"
|
|
26
27
|
],
|
|
27
28
|
"license": "MIT",
|
|
28
29
|
"dependencies": {
|
package/src/bundlers/vite.js
CHANGED
|
@@ -10,6 +10,21 @@ export default function ViteMDZ({extensions = [".mdx"], useVanJs = false}={}){
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
+
handleHotUpdate({ file, server }) {
|
|
14
|
+
if (file.endsWith('.mdz')) {
|
|
15
|
+
// Send update to Vite HMR client
|
|
16
|
+
server.ws.send({
|
|
17
|
+
type: 'custom',
|
|
18
|
+
event: 'custom-update',
|
|
19
|
+
data: {
|
|
20
|
+
file,
|
|
21
|
+
timestamp: Date.now(),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return [file];
|
|
26
|
+
}
|
|
27
|
+
},
|
|
13
28
|
};
|
|
14
29
|
}
|
|
15
30
|
|
|
@@ -62,7 +62,9 @@ const processMDZAST = (markdownAST) => {
|
|
|
62
62
|
const childNodes = node.children.map(transformNode).join(', ');
|
|
63
63
|
return hyperscript("li", "{}", childNodes);
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
case 'inlineCode' : {
|
|
66
|
+
return hyperscript("code", "{}", `"${node.value}"`)
|
|
67
|
+
}
|
|
66
68
|
case 'code': {
|
|
67
69
|
hasCode = true;
|
|
68
70
|
// const language = node.lang ? `{ 'data-lang': '${node.lang}' }` : '';
|
|
@@ -74,7 +76,7 @@ const processMDZAST = (markdownAST) => {
|
|
|
74
76
|
// language,
|
|
75
77
|
// JSON.stringify(node.value)
|
|
76
78
|
// ));
|
|
77
|
-
return `HTMLWrapper('<pre>${formatedCode}</pre>')`
|
|
79
|
+
return `HTMLWrapper('<pre><code>${formatedCode}</code></pre>')`
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
case 'blockquote': {
|
|
@@ -114,6 +116,12 @@ const processMDZAST = (markdownAST) => {
|
|
|
114
116
|
attrs
|
|
115
117
|
}
|
|
116
118
|
}
|
|
119
|
+
case 'mdxJsxTextElement': {
|
|
120
|
+
const {name, attributes, children} = node;
|
|
121
|
+
const childNodes = children.map(transformNode).join(', ');
|
|
122
|
+
const hasChildren = childNodes.length > 0;
|
|
123
|
+
return `h("${name}", ${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
|
|
124
|
+
};
|
|
117
125
|
case 'mdxJsxFlowElement':{
|
|
118
126
|
const {name, attributes, children} = node;
|
|
119
127
|
const childNodes = children.map(transformNode).join(', ');
|