mdzjs 0.0.2 → 0.0.4

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.
@@ -10,7 +10,7 @@
10
10
  "dependencies": {
11
11
  "highlight.js": "^11.11.0",
12
12
  "jsdom": "^25.0.1",
13
- "prism": "^4.1.2",
13
+ "prism": "^1.0.0",
14
14
  "ziko": "^0.0.27",
15
15
  "ziko-gl": "^0.0.3",
16
16
  "ziko-lottie": "^0.0.7",
@@ -691,24 +691,12 @@
691
691
  "node": ">= 14"
692
692
  }
693
693
  },
694
- "node_modules/asap": {
695
- "version": "2.0.6",
696
- "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
697
- "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
698
- "license": "MIT"
699
- },
700
694
  "node_modules/asynckit": {
701
695
  "version": "0.4.0",
702
696
  "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
703
697
  "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
704
698
  "license": "MIT"
705
699
  },
706
- "node_modules/change-emitter": {
707
- "version": "0.1.6",
708
- "resolved": "https://registry.npmjs.org/change-emitter/-/change-emitter-0.1.6.tgz",
709
- "integrity": "sha512-YXzt1cQ4a2jqazhcuSWEOc1K2q8g9H6eWNsyZgi640LDzRWVQ2eDe+Y/kVdftH+vYdPF2rgDb3dLdpxE1jvAxw==",
710
- "license": "MIT"
711
- },
712
700
  "node_modules/combined-stream": {
713
701
  "version": "1.0.8",
714
702
  "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -721,24 +709,6 @@
721
709
  "node": ">= 0.8"
722
710
  }
723
711
  },
724
- "node_modules/core-js": {
725
- "version": "1.2.7",
726
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
727
- "integrity": "sha512-ZiPp9pZlgxpWRu0M+YWbm6+aQ84XEfH1JRXvfOc/fILWI0VKhLC2LX13X1NYq4fULzLMq7Hfh43CSo2/aIaUPA==",
728
- "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
729
- "license": "MIT"
730
- },
731
- "node_modules/create-react-class": {
732
- "version": "15.7.0",
733
- "resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.7.0.tgz",
734
- "integrity": "sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng==",
735
- "license": "MIT",
736
- "peer": true,
737
- "dependencies": {
738
- "loose-envify": "^1.3.1",
739
- "object-assign": "^4.1.1"
740
- }
741
- },
742
712
  "node_modules/cssstyle": {
743
713
  "version": "4.1.0",
744
714
  "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.1.0.tgz",
@@ -796,15 +766,6 @@
796
766
  "node": ">=0.4.0"
797
767
  }
798
768
  },
799
- "node_modules/encoding": {
800
- "version": "0.1.13",
801
- "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
802
- "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
803
- "license": "MIT",
804
- "dependencies": {
805
- "iconv-lite": "^0.6.2"
806
- }
807
- },
808
769
  "node_modules/entities": {
809
770
  "version": "4.5.0",
810
771
  "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
@@ -856,21 +817,6 @@
856
817
  "@esbuild/win32-x64": "0.21.5"
857
818
  }
858
819
  },
859
- "node_modules/fbjs": {
860
- "version": "0.8.18",
861
- "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.18.tgz",
862
- "integrity": "sha512-EQaWFK+fEPSoibjNy8IxUtaFOMXcWsY0JaVrQoZR9zC8N2Ygf9iDITPWjUTVIax95b6I742JFLqASHfsag/vKA==",
863
- "license": "MIT",
864
- "dependencies": {
865
- "core-js": "^1.0.0",
866
- "isomorphic-fetch": "^2.1.1",
867
- "loose-envify": "^1.0.0",
868
- "object-assign": "^4.1.0",
869
- "promise": "^7.1.1",
870
- "setimmediate": "^1.0.5",
871
- "ua-parser-js": "^0.7.30"
872
- }
873
- },
874
820
  "node_modules/form-data": {
875
821
  "version": "4.0.1",
876
822
  "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
@@ -909,11 +855,6 @@
909
855
  "node": ">=12.0.0"
910
856
  }
911
857
  },
912
- "node_modules/hoist-non-react-statics": {
913
- "version": "1.2.0",
914
- "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz",
915
- "integrity": "sha512-r8huvKK+m+VraiRipdZYc+U4XW43j6OFG/oIafe7GfDbRpCduRoX9JI/DRxqgtBSCeL+et6N6ibZoedHS2NyOQ=="
916
- },
917
858
  "node_modules/html-encoding-sniffer": {
918
859
  "version": "4.0.0",
919
860
  "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz",
@@ -970,31 +911,6 @@
970
911
  "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
971
912
  "license": "MIT"
972
913
  },
973
- "node_modules/is-stream": {
974
- "version": "1.1.0",
975
- "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
976
- "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==",
977
- "license": "MIT",
978
- "engines": {
979
- "node": ">=0.10.0"
980
- }
981
- },
982
- "node_modules/isomorphic-fetch": {
983
- "version": "2.2.1",
984
- "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
985
- "integrity": "sha512-9c4TNAKYXM5PRyVcwUZrF3W09nQ+sO7+jydgs4ZGW9dhsLG2VOlISJABombdQqQRXCwuYG3sYV/puGf5rp0qmA==",
986
- "license": "MIT",
987
- "dependencies": {
988
- "node-fetch": "^1.0.1",
989
- "whatwg-fetch": ">=0.10.0"
990
- }
991
- },
992
- "node_modules/js-tokens": {
993
- "version": "4.0.0",
994
- "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
995
- "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
996
- "license": "MIT"
997
- },
998
914
  "node_modules/jsdom": {
999
915
  "version": "25.0.1",
1000
916
  "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz",
@@ -1066,18 +982,6 @@
1066
982
  "@types/trusted-types": "^2.0.2"
1067
983
  }
1068
984
  },
1069
- "node_modules/loose-envify": {
1070
- "version": "1.4.0",
1071
- "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
1072
- "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
1073
- "license": "MIT",
1074
- "dependencies": {
1075
- "js-tokens": "^3.0.0 || ^4.0.0"
1076
- },
1077
- "bin": {
1078
- "loose-envify": "cli.js"
1079
- }
1080
- },
1081
985
  "node_modules/lottie-web": {
1082
986
  "version": "5.12.2",
1083
987
  "resolved": "https://registry.npmjs.org/lottie-web/-/lottie-web-5.12.2.tgz",
@@ -1130,31 +1034,12 @@
1130
1034
  "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
1131
1035
  }
1132
1036
  },
1133
- "node_modules/node-fetch": {
1134
- "version": "1.7.3",
1135
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
1136
- "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
1137
- "license": "MIT",
1138
- "dependencies": {
1139
- "encoding": "^0.1.11",
1140
- "is-stream": "^1.0.1"
1141
- }
1142
- },
1143
1037
  "node_modules/nwsapi": {
1144
1038
  "version": "2.2.16",
1145
1039
  "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.16.tgz",
1146
1040
  "integrity": "sha512-F1I/bimDpj3ncaNDhfyMWuFqmQDBwDB0Fogc2qpL3BWvkQteFD/8BzWuIRl83rq0DXfm8SGt/HFhLXZyljTXcQ==",
1147
1041
  "license": "MIT"
1148
1042
  },
1149
- "node_modules/object-assign": {
1150
- "version": "4.1.1",
1151
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
1152
- "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
1153
- "license": "MIT",
1154
- "engines": {
1155
- "node": ">=0.10.0"
1156
- }
1157
- },
1158
1043
  "node_modules/pako": {
1159
1044
  "version": "2.1.0",
1160
1045
  "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
@@ -1210,53 +1095,10 @@
1210
1095
  }
1211
1096
  },
1212
1097
  "node_modules/prism": {
1213
- "version": "4.1.2",
1214
- "resolved": "https://registry.npmjs.org/prism/-/prism-4.1.2.tgz",
1215
- "integrity": "sha512-SsqrfKkYKYEYz/7RRET2KVZd9O22Rnj3331Al06ClLMycKWoM+MpfrjQrKuHGoIJ9IOy+k27kPEFnqPoAeFZpA==",
1216
- "license": "MIT",
1217
- "dependencies": {
1218
- "prism-react": "^1.0.2",
1219
- "prism-redux": "^1.0.2"
1220
- }
1221
- },
1222
- "node_modules/prism-react": {
1223
- "version": "1.0.2",
1224
- "resolved": "https://registry.npmjs.org/prism-react/-/prism-react-1.0.2.tgz",
1225
- "integrity": "sha512-OoBo0kX55Fi+M4oGuYQ+AkU4/xSvB357mLXbYGP3j4oi4RtsdY5Rn3ViJ6gGU8IkZKs5cnmF7IteWWwUFyVd7Q==",
1226
- "license": "MIT",
1227
- "dependencies": {
1228
- "recompose": "^0.22.0"
1229
- },
1230
- "peerDependencies": {
1231
- "react": "^15.0.2 || ^0.14.8"
1232
- }
1233
- },
1234
- "node_modules/prism-redux": {
1235
- "version": "1.0.2",
1236
- "resolved": "https://registry.npmjs.org/prism-redux/-/prism-redux-1.0.2.tgz",
1237
- "integrity": "sha512-e1DGRK+V/dxL6n6M25Py1QrAQLHkeueXyNxDTURT1y+KAMwSJdnlNvGU3ZLY2RIaA+ZdFTc9oTvTSR+mS88VyQ==",
1238
- "license": "MIT"
1239
- },
1240
- "node_modules/promise": {
1241
- "version": "7.3.1",
1242
- "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
1243
- "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
1244
- "license": "MIT",
1245
- "dependencies": {
1246
- "asap": "~2.0.3"
1247
- }
1248
- },
1249
- "node_modules/prop-types": {
1250
- "version": "15.8.1",
1251
- "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
1252
- "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
1253
- "license": "MIT",
1254
- "peer": true,
1255
- "dependencies": {
1256
- "loose-envify": "^1.4.0",
1257
- "object-assign": "^4.1.1",
1258
- "react-is": "^16.13.1"
1259
- }
1098
+ "version": "1.0.0",
1099
+ "resolved": "https://registry.npmjs.org/prism/-/prism-1.0.0.tgz",
1100
+ "integrity": "sha512-nPYWvGqE1dRk1QMKiQwdIxbGUIvp0i89U/JidlRIxQtu+I5089N+nY8w4eGxG76PnjB7Xc4cmMMiTwRJ87aVhQ==",
1101
+ "license": "ISC"
1260
1102
  },
1261
1103
  "node_modules/punycode": {
1262
1104
  "version": "2.3.1",
@@ -1267,45 +1109,6 @@
1267
1109
  "node": ">=6"
1268
1110
  }
1269
1111
  },
1270
- "node_modules/react": {
1271
- "version": "15.7.0",
1272
- "resolved": "https://registry.npmjs.org/react/-/react-15.7.0.tgz",
1273
- "integrity": "sha512-5/MMRYmpmM0sMTHGLossnJCrmXQIiJilD6y3YN3TzAwGFj6zdnMtFv6xmi65PHKRV+pehIHpT7oy67Sr6s9AHA==",
1274
- "license": "MIT",
1275
- "peer": true,
1276
- "dependencies": {
1277
- "create-react-class": "^15.6.0",
1278
- "fbjs": "^0.8.9",
1279
- "loose-envify": "^1.1.0",
1280
- "object-assign": "^4.1.0",
1281
- "prop-types": "^15.5.10"
1282
- },
1283
- "engines": {
1284
- "node": ">=0.10.0"
1285
- }
1286
- },
1287
- "node_modules/react-is": {
1288
- "version": "16.13.1",
1289
- "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
1290
- "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
1291
- "license": "MIT",
1292
- "peer": true
1293
- },
1294
- "node_modules/recompose": {
1295
- "version": "0.22.0",
1296
- "resolved": "https://registry.npmjs.org/recompose/-/recompose-0.22.0.tgz",
1297
- "integrity": "sha512-QjNK/CgNg6wa7sqaQelgkRdl7ktIYbOV4xp0m2n8TexmHI5h3gjOc5a6nNQhtH3Js63hGZ1HfvJ3DUErrvZ2yg==",
1298
- "license": "MIT",
1299
- "dependencies": {
1300
- "change-emitter": "^0.1.2",
1301
- "fbjs": "^0.8.1",
1302
- "hoist-non-react-statics": "^1.0.0",
1303
- "symbol-observable": "^1.0.4"
1304
- },
1305
- "peerDependencies": {
1306
- "react": "^0.14.0 || ^15.0.0"
1307
- }
1308
- },
1309
1112
  "node_modules/resize-observer-polyfill": {
1310
1113
  "version": "1.5.1",
1311
1114
  "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
@@ -1372,12 +1175,6 @@
1372
1175
  "node": ">=v12.22.7"
1373
1176
  }
1374
1177
  },
1375
- "node_modules/setimmediate": {
1376
- "version": "1.0.5",
1377
- "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
1378
- "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
1379
- "license": "MIT"
1380
- },
1381
1178
  "node_modules/source-map-js": {
1382
1179
  "version": "1.2.1",
1383
1180
  "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -1388,15 +1185,6 @@
1388
1185
  "node": ">=0.10.0"
1389
1186
  }
1390
1187
  },
1391
- "node_modules/symbol-observable": {
1392
- "version": "1.2.0",
1393
- "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
1394
- "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==",
1395
- "license": "MIT",
1396
- "engines": {
1397
- "node": ">=0.10.0"
1398
- }
1399
- },
1400
1188
  "node_modules/symbol-tree": {
1401
1189
  "version": "3.2.4",
1402
1190
  "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@@ -1451,36 +1239,10 @@
1451
1239
  "node": ">=18"
1452
1240
  }
1453
1241
  },
1454
- "node_modules/ua-parser-js": {
1455
- "version": "0.7.40",
1456
- "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.40.tgz",
1457
- "integrity": "sha512-us1E3K+3jJppDBa3Tl0L3MOJiGhe1C6P0+nIvQAFYbxlMAx0h81eOwLmU57xgqToduDDPx3y5QsdjPfDu+FgOQ==",
1458
- "funding": [
1459
- {
1460
- "type": "opencollective",
1461
- "url": "https://opencollective.com/ua-parser-js"
1462
- },
1463
- {
1464
- "type": "paypal",
1465
- "url": "https://paypal.me/faisalman"
1466
- },
1467
- {
1468
- "type": "github",
1469
- "url": "https://github.com/sponsors/faisalman"
1470
- }
1471
- ],
1472
- "license": "MIT",
1473
- "bin": {
1474
- "ua-parser-js": "script/cli.js"
1475
- },
1476
- "engines": {
1477
- "node": "*"
1478
- }
1479
- },
1480
1242
  "node_modules/vite": {
1481
- "version": "5.4.8",
1482
- "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz",
1483
- "integrity": "sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==",
1243
+ "version": "5.4.19",
1244
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
1245
+ "integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
1484
1246
  "dev": true,
1485
1247
  "license": "MIT",
1486
1248
  "dependencies": {
@@ -1570,12 +1332,6 @@
1570
1332
  "node": ">=18"
1571
1333
  }
1572
1334
  },
1573
- "node_modules/whatwg-fetch": {
1574
- "version": "3.6.20",
1575
- "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz",
1576
- "integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==",
1577
- "license": "MIT"
1578
- },
1579
1335
  "node_modules/whatwg-mimetype": {
1580
1336
  "version": "4.0.0",
1581
1337
  "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "highlight.js": "^11.11.0",
16
16
  "jsdom": "^25.0.1",
17
- "prism": "^4.1.2",
17
+ "prism": "^1.0.0",
18
18
  "ziko": "^0.0.27",
19
19
  "ziko-gl": "^0.0.3",
20
20
  "ziko-lottie": "^0.0.7",
@@ -1,6 +1,8 @@
1
1
  import { defineConfig } from "vite";
2
2
  // import { MDZ } from "../src/vite/index.js";
3
- import ViteMDZ from "../src/bundlers/vite.js"
3
+ // import ViteMDZ from "../src/bundlers/vite.js"
4
+ import ViteMDZ from "mdzjs/vite"
5
+
4
6
  export default defineConfig({
5
7
  plugins : [ViteMDZ()]
6
8
  })
@@ -6,6 +6,7 @@ import {
6
6
  } from "../utils/index.js"
7
7
  import hljs from "highlight.js"
8
8
  const processMDZAST = (markdownAST) => {
9
+ let hasCode = false;
9
10
  const transformNode = (node) => {
10
11
  switch(node.type){
11
12
  case 'mdxjsEsm' : {
@@ -16,7 +17,8 @@ const processMDZAST = (markdownAST) => {
16
17
  }
17
18
  case 'text' : {
18
19
  const text = node.value;
19
- return `"${text}"`
20
+ const escaped = text.replace(/"/g, '\\"');
21
+ return `"${escaped}"`;
20
22
  }
21
23
  case 'mdxTextExpression' : {
22
24
  const {value} = node
@@ -25,23 +27,19 @@ const processMDZAST = (markdownAST) => {
25
27
  case 'heading' : {
26
28
  const childNodes = node.children.map(transformNode).join(', ');
27
29
  return hyperscript(`h${node.depth}`,"{}", childNodes);
28
- // return `h('h${node.depth}', {}, ${childNodes})`;
29
30
  }
30
31
  case 'paragraph' : {
31
32
  const childNodes = node.children.map(transformNode).join(', ');
32
33
  return hyperscript("p","{}", childNodes)
33
- // return `h('p', {}, ${childNodes})`
34
34
  }
35
35
  case 'strong': {
36
36
  const childNodes = node.children.map(transformNode).join(', ');
37
37
  return hyperscript("strong","{}", childNodes);
38
- // return `h('strong', {}, ${childNodes})`;
39
38
  }
40
39
 
41
40
  case 'emphasis': {
42
41
  const childNodes = node.children.map(transformNode).join(', ');
43
- return hyperscript("emphasis","{}", childNodes);
44
- // return `h('em', {}, ${childNodes})`;
42
+ return hyperscript("em","{}", childNodes);
45
43
  }
46
44
 
47
45
  case 'link': {
@@ -58,27 +56,25 @@ const processMDZAST = (markdownAST) => {
58
56
  const listTag = node.ordered ? 'ol' : 'ul';
59
57
  const childNodes = node.children.map(transformNode).join(', ');
60
58
  return hyperscript(listTag, "{}", childNodes);
61
- // return `h('${listTag}', {}, ${childNodes})`;
62
59
  }
63
60
 
64
61
  case 'listItem': {
65
62
  const childNodes = node.children.map(transformNode).join(', ');
66
63
  return hyperscript("li", "{}", childNodes);
67
- // return `h('li', {}, ${childNodes})`;
68
64
  }
69
65
 
70
66
  case 'code': {
71
- const language = node.lang ? `{ 'data-lang': '${node.lang}' }` : '';
67
+ hasCode = true;
68
+ // const language = node.lang ? `{ 'data-lang': '${node.lang}' }` : '';
72
69
  const highlightedCode = hljs.highlightAuto(node.value, [node.lang || '']).value;
73
- hljs
70
+ // hljs
74
71
  const formatedCode = highlightedCode.replace(/(\r\n|\n|\r)/g, "<br>")
75
- const out = hyperscript("pre", "{}", hyperscript(
76
- "code",
77
- language,
78
- JSON.stringify(node.value)
79
- ));
72
+ // const out = hyperscript("pre", "{}", hyperscript(
73
+ // "code",
74
+ // language,
75
+ // JSON.stringify(node.value)
76
+ // ));
80
77
  return `HTMLWrapper('<pre>${formatedCode}</pre>')`
81
- // return out
82
78
  }
83
79
 
84
80
  case 'blockquote': {
@@ -110,6 +106,7 @@ const processMDZAST = (markdownAST) => {
110
106
  // return `h('td', {}, ${childNodes}).style({border : "1px solid darkblue", borderCollapse: "collapse", padding : "5px"})`;
111
107
  }
112
108
  case 'yaml':{
109
+ // console.log({yml : node.value})
113
110
  const {props, attrs} = parseYml(node.value)
114
111
  return {
115
112
  type : "yaml",
@@ -121,10 +118,12 @@ const processMDZAST = (markdownAST) => {
121
118
  const {name, attributes, children} = node;
122
119
  const childNodes = children.map(transformNode).join(', ');
123
120
  const hasChildren = childNodes.length > 0;
124
- console.log({name})
125
- console.log(componentType(name))
121
+ // console.log({name})
122
+ // console.log(componentType(name))
126
123
  switch(componentType(name)){
127
- case "jsx" : return `${name}(${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
124
+ case "jsx" : {
125
+ return `${name}(${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
126
+ }
128
127
  case "html" : return `h("${name}", ${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
129
128
  case "script" : {
130
129
  const statements = [];
@@ -149,8 +148,8 @@ const processMDZAST = (markdownAST) => {
149
148
  switch(node.type){
150
149
  case 'yaml' : {
151
150
  const Transformed = transformNode(node)
152
- props = Transformed.props,
153
- attrs = Transformed.attrs
151
+ props = Transformed.props;
152
+ attrs = Transformed.attrs;
154
153
  } break;
155
154
  case 'mdxjsEsm' : esm.push(node.value); break;
156
155
  default : {
@@ -164,7 +163,8 @@ const processMDZAST = (markdownAST) => {
164
163
  attrs,
165
164
  props,
166
165
  esm,
167
- statements
166
+ statements,
167
+ hasCode
168
168
  }
169
169
  };
170
170
  export {
@@ -1,20 +1,21 @@
1
1
  import { parseMDZ } from "./parser.js";
2
2
  import { processMDZAST } from "./process.js";
3
+ import { stringifyProps } from "../utils/parse-yml.js";
3
4
 
4
- const transpileMDZ=(Markdown)=>{
5
+ const transpileMDZ=(Markdown, CodeStyle = "1c-light")=>{
5
6
  const ast = parseMDZ(Markdown);
6
- const {attrs, props, esm, statements}= processMDZAST(ast)
7
- console.log({props})
7
+ const {attrs, props, esm, statements, hasCode}= processMDZAST(ast)
8
8
  const body = [
9
9
  'import {h, HTMLWrapper, Flex} from "ziko"',
10
10
  attrs,
11
11
  ...esm,
12
- `export default (${props})=>{`,
12
+ `export default (${stringifyProps(props)})=>{`,
13
13
  'const __items__ = []',
14
14
  ...statements,
15
15
  "const UI = Flex(...__items__).vertical(0, 0)",
16
16
  "return UI }"
17
17
  ]
18
+ if(hasCode) body.unshift(`import("highlight.js/styles/${CodeStyle}.css")`);
18
19
  return body.join("\n");
19
20
  }
20
21
  export{
@@ -0,0 +1,84 @@
1
+ export type Style =
2
+ | '1c-light'
3
+ | 'a11-dark'
4
+ | 'a11-dark'
5
+ | 'agate'
6
+ | 'an-old-hope'
7
+ | 'androidstudio'
8
+ | 'arduino-light'
9
+ | 'arta'
10
+ | 'ascetic'
11
+ | 'atom-one-dark-reasonable'
12
+ | 'atom-one-dark'
13
+ | 'atom-one-light'
14
+ | 'brown-paper'
15
+ | 'codepen-embed'
16
+ | 'color-brewer'
17
+ | 'cybertopia-cherry'
18
+ | 'cybertopia-dimmer'
19
+ | 'cybertopia-icecap'
20
+ | 'cybertopia-saturated'
21
+ | 'dark'
22
+ | 'default'
23
+ | 'devibeans'
24
+ | 'docco'
25
+ | 'far'
26
+ | 'felipec'
27
+ | 'foundation'
28
+ | 'github-dark-dimmed'
29
+ | 'github-dark'
30
+ | 'github'
31
+ | 'gml'
32
+ | 'googlecode'
33
+ | 'gradient-dark'
34
+ | 'gradient-light'
35
+ | 'grayscale'
36
+ | 'hybrid'
37
+ | 'idea'
38
+ | 'intellij-light'
39
+ | 'ir-black'
40
+ | 'isbl-editor-dark'
41
+ | 'isbl-editor-light'
42
+ | 'kimbie-dark'
43
+ | 'kimbie-light'
44
+ | 'lightfair'
45
+ | 'lioshi'
46
+ | 'magula'
47
+ | 'mono-blue'
48
+ | 'monokai-sublime'
49
+ | 'monokai'
50
+ | 'night-owl'
51
+ | 'nnfx-dark'
52
+ | 'nord'
53
+ | 'obsidian'
54
+ | 'panda-syntax-dark'
55
+ | 'panda-syntax-light'
56
+ | 'paraiso-dark'
57
+ | 'paraiso-light'
58
+ | 'pojoaque'
59
+ | 'purebasic'
60
+ | 'qtcreator-dark'
61
+ | 'qtcreator-light'
62
+ | 'rainbow'
63
+ | 'rose-pine-dawn'
64
+ | 'rose-pine-moon'
65
+ | 'rose-pine'
66
+ | 'routeros'
67
+ | 'school-book'
68
+ | 'shades-of-purple'
69
+ | 'srcery'
70
+ | 'stackoverflow-dark'
71
+ | 'stackoverflow-light'
72
+ | 'sunburst'
73
+ | 'tokyo-night-dark'
74
+ | 'tokyo-night-light'
75
+ | 'tomorrow-night-blue'
76
+ | 'tomorrow-night-bright'
77
+ | 'vs'
78
+ | 'vs2015'
79
+ | 'xcode'
80
+ | 'xt256'
81
+
82
+
83
+
84
+
@@ -1,4 +1,29 @@
1
1
  export const hyperscript = (tag, attrs, children="") => {
2
2
  const HasChildren = !!children;
3
+
4
+ if(tag === "p"){
5
+ children = children + ',""'
6
+ const splitted = splitQuotedLines(children);
7
+ children = insertBetween(splitted, 'h("br")')
8
+ children[children.length - 1] = children.at(-1).slice(0, -3)
9
+ }
3
10
  return `h("${tag}", ${attrs}${HasChildren ?`, ${children}` : ""})`
4
- }
11
+ }
12
+
13
+ function splitQuotedLines(str) {
14
+ return str
15
+ .slice(1, -1) // Remove the surrounding quotes
16
+ .split(/\r\n|\r|\n/) // Split by newline types
17
+ .map(line => `"${line}"`); // Re-wrap each line in quotes
18
+ }
19
+
20
+ function insertBetween(arr, value) {
21
+ const result = [];
22
+ for (let i = 0; i < arr.length; i++) {
23
+ result.push(arr[i]);
24
+ if (i < arr.length - 1) {
25
+ result.push(value);
26
+ }
27
+ }
28
+ return result;
29
+ }