@lacspace/markdown
v1.0.0
Published
A small, safe Markdown → HTML renderer — headings with anchor ids, nested & task lists, fenced code, blockquotes, GFM tables, images and links. HTML in the source is escaped. Includes extractHeadings() for a table of contents. Zero-dependency, isomorphic.
Maintainers
Readme
@lacspace/markdown
Markdown → HTML in a few KB — safe by default, with a table-of-contents extractor.
Everything a blog or docs page needs — headings with anchor ids, nested & task lists, fenced code, blockquotes, GFM tables, images and links — rendering to clean HTML with source HTML escaped by default. No dependencies, isomorphic.
Install
npm i @lacspace/markdownUse it
import { markdownToHtml, extractHeadings, slugify } from "@lacspace/markdown";
const html = markdownToHtml(`
# Getting started
Some **bold** text, a [link](https://lacspace.com) and \`inline code\`.
- a list
- that nests
- [x] and task items
| Feature | Status |
| ------- | :----: |
| Tables | ✅ |
\`\`\`ts
const x = 1;
\`\`\`
`);A table of contents, for free
extractHeadings(md);
// [{ level: 1, text: "Getting started", id: "getting-started" }, …]
slugify("Hello, World!"); // "hello-world"Supports
- Headings
#–######with auto anchorids (toggle withheadingIds, shift withheadingOffset) - Lists — ordered, unordered, nested, and task lists (
- [x]) - Fenced code
```withlanguage-*class (HTML-escaped) - Blockquotes (nested Markdown inside)
- GFM tables with column alignment
- Inline —
**bold**,*italic*,~~strike~~,`code`,[links](…),,<autolinks>, hard line breaks - Safety — raw HTML in the source is escaped, not passed through
Options
| Option | Default | Meaning |
| --- | --- | --- |
| headingIds | true | add slug ids to headings |
| headingOffset | 0 | shift levels (1 → # becomes <h2>) |
| openLinksInNewTab | false | add target="_blank" rel="noopener noreferrer" to external links |
Perfect for a Markdown-powered blog — it's what the blog template in create-lacspace-app uses.
Licensing
Free under the Lacspace Free Licence — MIT-equivalent freedoms. Use it in personal and commercial projects at no cost; just keep the notice. See the Lacspace Licence Centre.
Part of the Lacspace ecosystem — zero-dependency, isomorphic TypeScript packages.
