mdzjs 0.0.7 → 0.0.8
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
CHANGED
package/src/transpiler/index.js
CHANGED
package/src/transpiler/parser.js
CHANGED
|
@@ -4,11 +4,11 @@ import remarkFrontmatter from 'remark-frontmatter';
|
|
|
4
4
|
import remarkGFM from "remark-gfm";
|
|
5
5
|
import remarkMdx from "remark-mdx"
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const parseMarkdown = (markdown) => unified()
|
|
8
8
|
.use(remarkParse)
|
|
9
9
|
.use(remarkGFM)
|
|
10
10
|
.use(remarkFrontmatter, ['yaml'])
|
|
11
11
|
.use(remarkMdx)
|
|
12
12
|
.parse(markdown)
|
|
13
13
|
|
|
14
|
-
export{
|
|
14
|
+
export{parseMarkdown}
|
|
@@ -118,8 +118,6 @@ const processMDZAST = (markdownAST) => {
|
|
|
118
118
|
const {name, attributes, children} = node;
|
|
119
119
|
const childNodes = children.map(transformNode).join(', ');
|
|
120
120
|
const hasChildren = childNodes.length > 0;
|
|
121
|
-
// console.log({name})
|
|
122
|
-
// console.log(componentType(name))
|
|
123
121
|
switch(componentType(name)){
|
|
124
122
|
case "jsx" : {
|
|
125
123
|
return `${name}(${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseMarkdown } from "./parser.js";
|
|
2
2
|
import { processMDZAST } from "./process.js";
|
|
3
3
|
import { stringifyProps } from "../utils/parse-yml.js";
|
|
4
4
|
|
|
5
5
|
const transpileMDZ=(Markdown, useVanJs = false, CodeStyle = "1c-light")=>{
|
|
6
|
-
const ast =
|
|
6
|
+
const ast = parseMarkdown(Markdown);
|
|
7
7
|
const {attrs, props, esm, statements, hasCode}= processMDZAST(ast)
|
|
8
8
|
const body = [
|
|
9
9
|
'import {h, HTMLWrapper, Flex} from "ziko"',
|
package/src/utils/parse-yml.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parse } from 'yaml';
|
|
2
2
|
|
|
3
3
|
const parseYml = yml => {
|
|
4
|
-
const {__props__, ...__attrs__} = parse(yml) ;
|
|
4
|
+
const {__props__, ...__attrs__} = yml ? parse(yml) : {__props__ : {}} ;
|
|
5
5
|
const HasAttributs = Object.keys(__attrs__).length > 0
|
|
6
6
|
return {
|
|
7
7
|
props : __props__,
|