ESM Only
Mmmark : Convert Md to Html with Showdown.Js.
This package focus on convert markdown to html . If you want more, recommended to use Showdown.js
Showdown.js is a powerful JavaScript library used for converting Markdown into HTML. It's a key dependency in our project, providing the core functionality of our Markdown to HTML conversion.
JS-YAML is a JavaScript implementation of YAML, a human-friendly data serialization standard. In our project, it's used for parsing YAML front matter in Markdown files.
npm i mm-mark
yarn add mm-mark
pnpm i mm-mark
deno
deno add @ptm/mm-mark
npm
npx jsr add @ptm/mm-mark
yarn
yarn dlx jsr add @ptm/mm-mark
pnpm
pnpm dlx jsr add @ptm/mm-mark
bun
bunx jsr add @ptm/mm-mark
Import
import * as mod from "@ptm/mm-mark";
import { mdConverter } from "mm-mark"; const mdcontent = ` --- title: hello world date: 2024-07-07 tags: - foo - bar --- ## Hello `; const converter = mdConverter(/*{Showdown Options} */); // set flavor for this converter converter.setFlavor("github"); const html = converter.makeHtml(mdcontent); console.log(html); // <h2 id="hello">Hello</h2>
import { frontmatter } from "mm-mark/frontmatter"; type MyType = { type: string; title: string; }; const mdcontent = ` --- title: hello world date: 2024-07-07 tags: - foo - bar --- ## Hello `; const foo = frontmatter<MyType>(mdcontent); console.log(foo.data); // { title: 'hello world', date: 2024-07-07T00:00:00.000Z, tags: [ 'foo', 'bar' ] } console.log(foo.content); // ## Hello
Available Extensions
icons
copyCode
customClass
twitter
youtube
You can use any showdown
extensions.
import { mdConverter } from "mm-mark"; import { icons } from "mm-mark/extensions"; const converter = mdConverter( /*{Showdown Extensions} */ { extensions: [icons] } ); const html = converter.makeHtml("@fa-home");
Add Package
deno add jsr:@ptm/mm-mark
Import symbol
import * as mm_mark from "@ptm/mm-mark";
Import directly with a jsr specifier
import * as mm_mark from "jsr:@ptm/mm-mark";
Add Package
pnpm i jsr:@ptm/mm-mark
pnpm dlx jsr add @ptm/mm-mark
Import symbol
import * as mm_mark from "@ptm/mm-mark";
Add Package
yarn add jsr:@ptm/mm-mark
yarn dlx jsr add @ptm/mm-mark
Import symbol
import * as mm_mark from "@ptm/mm-mark";
Add Package
npx jsr add @ptm/mm-mark
Import symbol
import * as mm_mark from "@ptm/mm-mark";
Add Package
bunx jsr add @ptm/mm-mark
Import symbol
import * as mm_mark from "@ptm/mm-mark";