Skip to main content

@ptm/mm-mark@0.2.22
Built and signed on GitHub Actions

Convert Markdown to HTML

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
8 months ago (0.2.22)

mm-mark

ESM Only

md-html


Convert Markdown to HTML

Mmmark : Convert Md to Html with Showdown.Js.

Note

This package focus on convert markdown to html . If you want more, recommended to use Showdown.js


Main dependencies bundled license information.

1. 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.

2. JS-YAML

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.

3. Other dependencies

  • Prism.Js for code block highlight.
  • Mathjax for math support.
  • tsup for typescript compile and bundle.

npm version

Install from npm

npm i mm-mark
yarn add mm-mark
pnpm i mm-mark

JSR

Install from jsr.io

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";

Markdown to HTML.

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>

Frontmatter

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

Extensions

Available Extensions

  1. icons

  2. copyCode

  3. customClass

  4. twitter

  5. 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");
Built and signed on
GitHub Actions
View transparency log

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@ptm/mm-mark

Import symbol

import * as mm_mark from "@ptm/mm-mark";
or

Import directly with a jsr specifier

import * as mm_mark from "jsr:@ptm/mm-mark";

Add Package

pnpm i jsr:@ptm/mm-mark
or (using pnpm 10.8 or older)
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
or (using Yarn 4.8 or older)
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";