Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
lowlighter/libsWorks with
•JSR Score94%•This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




License
•MIT
Downloads35/wk
•Published2 weeks ago (4.0.0)
🖨️ Render markdown to HTML using the unified ecosystem.
🖨️ Markdown
📑 Examples
Rendering markdown
import { markdown } from "./mod.ts" // Render markdown (GitHub Flavored Markdown is enabled by default) markdown("# Hello, world!") // Toggle additional features through options markdown("$\\pi$ is ==irrational==", { math: true, markers: true }) // Raw HTML is escaped by default, opt-in with the `html` option markdown("<b>trusted</b>", { html: true }) // Retrieve frontmatter metadata const { value, metadata } = markdown("---\ntitle: foo\n---\nbar", { frontmatter: true, metadata: true }) console.log(value, metadata.frontmatter) // "bar" { title: "foo" }
Reusing a renderer and hooking custom rules
import { Renderer } from "./renderer.ts" const renderer = new Renderer({ highlighting: true, wikilinks: { resolve: (link) => `/wiki/${link}` }, // Hook the underlying markdown-it instance for custom rules and renderers hooks(engine) { engine.renderer.rules.code_inline = (tokens, index) => `<kbd>${engine.utils.escapeHtml(tokens[index].content)}</kbd>` }, }) renderer.render("# Hello, world!")
✨ Features
- Single
markdown(text, options)function where every feature is a simple toggle. - Renders GitHub Flavored Markdown by default (tables, strikethrough, autolinks, footnotes and tasklists).
- Raw HTML is escaped by default, making the output safe against HTML injection (opt-in with the
htmloption). - Optional features:
- Math and mermaid are rendered as plain markup intended for client-side processing (KaTeX, MathJax, mermaid), so no heavyweight server-side dependency is required.
- Escape hatch to the underlying markdown-it instance through the
hooksoption for custom syntax and rendering rules.
📜 Licenses and credits
Copyright (c) Simon Lecoq <@lowlighter>. (MIT License) https://github.com/lowlighter/libs/blob/main/LICENSE
This library relies on the awesome markdown-it library.
Built and signed on
GitHub Actions
Add Package
deno add jsr:@libs/markdown
Import symbol
import * as markdown from "@libs/markdown";
Import directly with a jsr specifier
import * as markdown from "jsr:@libs/markdown";