-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 298c323
Showing
13 changed files
with
818 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# md4wc | ||
|
||
A Web component for rendering Markdown to HTML. | ||
|
||
## Features | ||
|
||
- ⚡ Insane fast rendering using [md4w](https://github.com/ije/md4w) (written in Zig) | ||
- ✨ Declarative usage | ||
- 💡 Lightweight | ||
- 📘 ESM modules | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install md4wc md4c | ||
# or pnpm install md4wc md4c | ||
``` | ||
|
||
## How to use | ||
|
||
### Register | ||
|
||
Register the `MarkdownContent` and optionally `MarkdownContext`. | ||
|
||
```js | ||
import { MarkdownContent } from "md4wc"; | ||
customElements.define("md-content", new MarkdownContent()); | ||
``` | ||
|
||
Or you can use the static helper | ||
|
||
```js | ||
import { MarkdownContent } from "md4wc"; | ||
class YourComponent extends MarkdownContent { | ||
static { | ||
this.register("md-content", YourComponent); | ||
} | ||
} | ||
|
||
export default MarkdownContextComponent; | ||
``` | ||
|
||
### Usage | ||
|
||
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`. | ||
|
||
```html | ||
<md-context href="/path/to/md4w.wasm"> | ||
<md-content></md-content> | ||
</md-context> | ||
``` | ||
|
||
```js | ||
const md = this.querySelector("md-content"); | ||
md.dispatchEvent(new CustomEvent("render", { detail: "Markdown content" })); | ||
``` | ||
|
||
## References | ||
|
||
- https://developer.mozilla.org/en-US/docs/Web/API/Web_components | ||
|
||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "md4wc", | ||
"version": "1.0.1", | ||
"exports": { | ||
".": "./src/index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "md4wc", | ||
"repository": "https://github.com/karesztrk/md4wc", | ||
"version": "1.0.1", | ||
"description": "", | ||
"type": "module", | ||
"types": "./types/index.d.ts", | ||
"module": "./dist/index.js", | ||
"scripts": { | ||
"build": "rollup -c && pnpm generate:types", | ||
"generate:types": "node ./scripts/generate-types.js", | ||
"prepublishOnly": "pnpm build" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"browser": "./dist/index.js", | ||
"default": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist", | ||
"types" | ||
], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@karesztrk/webcomponent-base": "^1.0.9" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"dts-buddy": "^0.5.1", | ||
"prettier": "^3.3.3", | ||
"rollup": "^4.19.0" | ||
}, | ||
"peerDependencies": { | ||
"md4w": "^0.2.6" | ||
} | ||
} |
Oops, something went wrong.