1.0.0 • Published 5 months ago

@mdit-kdu/plugin-title v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@mdit-vkduue/plugin-title

A markdown-it plugin to get page title.

  • Extracts title (the content of the first level-1 heading) into markdown-it env.title.

Install

npm i @mdit-kdu/plugin-title

Usage

import MarkdownIt from 'markdown-it';
import { titlePlugin } from '@mdit-kdu/plugin-title';
import type { MarkdownItEnv } from '@mdit-kdu/types';

const md = MarkdownIt({ html: true }).use(titlePlugin);
const env: MarkdownItEnv = {};

const rendered = md.render(
  `\
# h1
## h2
### h3
`,
  env,
);

console.log(env.title);