ije / md4w Goto Github PK
View Code? Open in Web Editor NEWA Markdown renderer written in Zig & C, compiled to WebAssymbly.
License: MIT License
A Markdown renderer written in Zig & C, compiled to WebAssymbly.
License: MIT License
---
title: Hello World
desc: Hello world!
slug: hello-world
cover: /images/hello-world.png
---
![Cover]({cover})
# {title}
Hello world!
๐
<html>
<head>
<title>Hello World</title>
<meta name="description" content="Hello world!">
</head>
<body>
<p><image alt="Cover" src="/images/hello-world.png"></p>
<h1>Hello World</h1>
<p>Hello world!<p>
</body>
</html>
Hey @ije. I'm still a fan of your lib. For this reason, I've created a Web component library that consumes yours.
You can check it @ https://github.com/karesztrk/md4wc
I hope it ok, if you are interested we can move it into a monorepo or something.
I'm a big fan of this lib and thanks for sharing it.
I wanted to ask about the preferred way to load md4w in the browser (client side).
I tried it using Vite (without a CDN). However the dynamic nature of loading prevents Vite from building the final bundle.
<script>
import { init, mdToHtml } from "md4w";
await init();
</script>
Error:
โ [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
node_modules/.pnpm/[email protected]/node_modules/md4w/js/index.js:12:23: 12 โ const { readFile } = await import(m); โต ~~~~~
Shouldn't be there a dedicated Build for Browsers on npm.js?
Hi! Kinda excited to see this project since I was planning to work on some markdown utils pkg and was looking for a fast native parser, this is an amazing effort ๐ฅ
Some context:
There is an outstanding proposal from WebAssmbly working group to support .wasm
imports as ESM imports, resolving the ever-lasting issues of inconsistent WASM support across platforms and tools.
Besides this, we have Cloudflare Workers that have their specific requirement that requires a wasm import to be predictable (and not compiled on demand) (and other worker runtimes that don't like top-level await for init
)
To allow widely adopting wasm libraries within Nuxt and UnJS ecosystems, I have recently started working on unwasm which is an effort to allow adopting ESM WASM modules ahead of time in toolings and allow a universal way of wasm module consumption. unwasm is under development but also constantly tested to make sure has maximum compatibility at the same time.
What is required for it to work?
A small refactor to split the init
functionality from the rest of logic (mem alloc, and util exports).
If you are interested, I can happily make a minimal environment for you to easily try this.
reproduction:
import { init, mdToJSON } from 'md4w'
const commonMark = await fetch('https://github.com/ije/md4w/raw/main/test/commonmark-spec.md').then(r => r.text())
await init()
try {
console.log(mdToJSON(commonMark))
} catch (error) {
console.error(error.stack.slice(0, 200))
}
\Error: Failed to parse JSON: Bad escaped character in JSON at position 4959
[{"type":5},{"type":9,"children":["title: CommonMark Spec","\n","author: John MacFarlane","\n","version: '0.31.2'","\n","data
currently we create a new writer for each renderer call, a global writer without memory alloc/free in each render should have better perfermance.
Hi. I quickly made this tracker issue while writing unjs/automd#32 to see if you are interested to also expose a simple parse util? (could be either stream or returning whole AST). This can be used as parser core in unjs/omark โค๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.