markdown-plus is a Markdown to HTML plug-in written in TypeScript that not only supports common conversions of Markdown syntax, but also extends multi-column layouts and icon syntax.(markdown-plus是一款基于TypeScript编写的Markdown转HTML插件,它不仅支持Markdown语法的常见转换,还扩展了
npm install markdown-transform-htmlshell
pnpm install markdown-transform-html
`
or
`shell
npm install markdown-transform-html
`
or
`shell
yarn add markdown-transform-html
`
Example
`ts
import { markdownToHTML } from "markdown-transform-html"
import "markdown-transform-html/lib/styles/index.css";const markdownContent =
#### level 4;
const html = markdownToHTML(markdownContent);
(document.querySelector("#app") as Element).innerHTML = html;
`
Highlighting
If you want to highlight code, then you need to introduce the following css styles and configure options, which is optional.`ts
markdownToHTML(markdownContent, { highlight: true });
`MarkdownToHTML Options
Configure the markdownToHTML options
| property name | type | default value | meaning |
| -------------------- | ------- | ------------- | ------- |
| lineNumber | Boolean | false | If you need line numbers, turn this option on |
| highlight | Boolean | false | If you need to highlight code in markdown, turn this option on |
| xss | Boolean | true | To prevent users from xss attacks on your application, xss is used by default. If you want to turn it off, you can set it to false |Problems
Q: Why does highlighting fail after code changes?A: After the content has been modified you should re-highlight the code using the
reHighlight method
`js
// example
import { reHighlight } from "markdown-transform-html"
reHighlight();
``If you think this project is helpful to you and circumstances permit, you can give me a little support. In short, thank you very much for your support ~

Alipay

MIT © coderlei