Skip to content

Commit 298c323

Browse files
committed
Initial commit
0 parents  commit 298c323

13 files changed

Lines changed: 818 additions & 0 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# md4wc
2+
3+
A Web component for rendering Markdown to HTML.
4+
5+
## Features
6+
7+
- ⚡ Insane fast rendering using [md4w](https://github.com/ije/md4w) (written in Zig)
8+
- ✨ Declarative usage
9+
- 💡 Lightweight
10+
- 📘 ESM modules
11+
12+
## Installation
13+
14+
```sh
15+
npm install md4wc md4c
16+
# or pnpm install md4wc md4c
17+
```
18+
19+
## How to use
20+
21+
### Register
22+
23+
Register the `MarkdownContent` and optionally `MarkdownContext`.
24+
25+
```js
26+
import { MarkdownContent } from "md4wc";
27+
customElements.define("md-content", new MarkdownContent());
28+
```
29+
30+
Or you can use the static helper
31+
32+
```js
33+
import { MarkdownContent } from "md4wc";
34+
class YourComponent extends MarkdownContent {
35+
static {
36+
this.register("md-content", YourComponent);
37+
}
38+
}
39+
40+
export default MarkdownContextComponent;
41+
```
42+
43+
### Usage
44+
45+
Declare your markup and pass the `WASM` module path as `href`. This will initialize the `md4c` module under to hood. But you can do the same thing manually using `import { init } from "md4w`.
46+
47+
```html
48+
<md-context href="/path/to/md4w.wasm">
49+
<md-content></md-content>
50+
</md-context>
51+
```
52+
53+
```js
54+
const md = this.querySelector("md-content");
55+
md.dispatchEvent(new CustomEvent("render", { detail: "Markdown content" }));
56+
```
57+
58+
## References
59+
60+
- https://developer.mozilla.org/en-US/docs/Web/API/Web_components
61+
62+
```
63+
64+
```

jsr.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "md4wc",
3+
"version": "1.0.1",
4+
"exports": {
5+
".": "./src/index.js"
6+
}
7+
}

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "md4wc",
3+
"repository": "https://github.com/karesztrk/md4wc",
4+
"version": "1.0.1",
5+
"description": "",
6+
"type": "module",
7+
"types": "./types/index.d.ts",
8+
"module": "./dist/index.js",
9+
"scripts": {
10+
"build": "rollup -c && pnpm generate:types",
11+
"generate:types": "node ./scripts/generate-types.js",
12+
"prepublishOnly": "pnpm build"
13+
},
14+
"exports": {
15+
".": {
16+
"types": "./types/index.d.ts",
17+
"browser": "./dist/index.js",
18+
"default": "./dist/index.js"
19+
},
20+
"./package.json": "./package.json"
21+
},
22+
"files": [
23+
"dist",
24+
"types"
25+
],
26+
"author": "",
27+
"license": "MIT",
28+
"dependencies": {
29+
"@karesztrk/webcomponent-base": "^1.0.9"
30+
},
31+
"devDependencies": {
32+
"@rollup/plugin-node-resolve": "^15.2.3",
33+
"@rollup/plugin-terser": "^0.4.4",
34+
"dts-buddy": "^0.5.1",
35+
"prettier": "^3.3.3",
36+
"rollup": "^4.19.0"
37+
},
38+
"peerDependencies": {
39+
"md4w": "^0.2.6"
40+
}
41+
}

0 commit comments

Comments
 (0)