@franken-suite/franken-markdown
v0.3.2
Published
Browser/WASM package for franken_markdown Markdown to HTML/PDF rendering.
Maintainers
Readme
franken_markdown WASM Package
This directory contains the source wrapper for the browser package. Generated
wasm-bindgen glue is intentionally not committed here; scripts/check-wasm-package.sh
builds it into target/fmd-checks/wasm-package/.
Build
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version 0.2.126 --locked
scripts/check-wasm-package.shThe assembled package contains:
franken_markdown.js- ergonomic hand-written ESM wrapper,franken_markdown.d.ts- exact TypeScript API contract,demo/- static browser demo that uses the public package wrapper,package.json- package metadata and exports,pkg/- generated wasm-bindgen glue and.wasmbinary.
Demo
After scripts/check-wasm-package.sh, serve the assembled package directory
with any static file server and open demo/index.html:
python3 -m http.server 8787 --directory target/fmd-checks/wasm-packageThen open http://127.0.0.1:8787/demo/. The demo is plain HTML/CSS/ESM and
does not require a bundler or network access for normal rendering. It imports
../franken_markdown.js, renders the HTML preview through renderHtml, and
downloads PDF bytes through renderPdf.
Browser Usage
import { createRenderer } from "./franken_markdown.js";
const fmd = await createRenderer();
const html = await fmd.renderHtml("# Hello", { font: "sans", darkMode: "auto" });
document.body.innerHTML = html.text();
const pdf = await fmd.renderPdf("# Report", {
title: "Report",
metadataEpochSeconds: 1700000000
});
const url = URL.createObjectURL(pdf.blob());Every render result has:
format:htmlorpdf,mimeType: browser Blob MIME type,extension: default download extension,sourceLength: Markdown source byte length,bytes:Uint8Array,diagnostics: recoverable parser diagnostics,text(),blob(), andfilename()helpers.
