0.3.8 • Published 11 months ago

mm-mark v0.3.8

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

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 mmmark from "mm-mark";
const mdcontent = `
---
title: hello world
date: 2024-07-07
tags:
    - foo
    - bar
---


## Hello

`;
const converter = mmmark.Converter(/*{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 mmmark from "mm-mark";
type MyType = {
  type: string;
  title: string;
};

const mdcontent = `
    ---
    title: hello world
    date: 2024-07-07
    tags:
        - foo
        - bar
    ---


    ## Hello

    `;

const foo = mmmark.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
import mmmark from "mm-mark";
import { customClass } from "mm-mark";

const converter = mmmark.Converter({
  extensions: [icons],
});

const md = `@fa-home`;
const html = converter.makeHtml(md);
console.log(html); // <i class="fa fa-home"></i>
  1. customClass
import mmmark from "mm-mark";
import { customClass } from "mm-mark";

const converter = mmmark.Converter({
  noHeaderId: true, // recommended to set `true` for option `noHeaderId` when using customClass extension
  extensions: [customClass],
});
const md = `#[.header]Header`;
const html = converter.makeHtml(md);
console.log(html); // <h1 class="header">Header</h1>

You can use any showdown extensions.

0.2.22

12 months ago

0.3.0

11 months ago

0.3.6

11 months ago

0.3.8

11 months ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.10

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.7

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago