1.7.8 • Published 6 months ago

markdown-transform-html v1.7.8

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

Introduce

Markdown converter, convert Markdwon content to HTML format, and provide code line number display and code highlighting effect (currently support javascript, HTML and other languages, later will support C, C++, Java, JS, TS, Ruby, Rust, PHP, GO, ...).

The online demo

Prompt

To make the style apply only to the part that needs to be parsed, be sure to add a 'markdown-transform-html' class declaration to the parsed container.

Use

install

pnpm install markdown-transform-html

or

npm install markdown-transform-html

or

yarn add markdown-transform-html

Example

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.

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

// example
import { reHighlight } from "markdown-transform-html"
reHighlight();

Sponsorship

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 ~

License

MIT © coderlei

1.7.8

6 months ago

1.7.7

6 months ago

1.7.6

6 months ago

1.7.5

7 months ago

1.7.4

7 months ago

1.7.3

7 months ago

1.7.2

10 months ago

1.7.1

10 months ago

1.7.0

10 months ago

1.6.9

10 months ago

1.6.8

10 months ago

1.6.7

10 months ago

1.6.6

11 months ago

1.6.4

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.5

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.6.0

1 year ago

1.5.9

1 year ago

1.5.8

1 year ago

1.5.7

1 year ago

1.5.6

1 year ago

1.4.6

2 years ago

1.3.7

2 years ago

1.4.5

2 years ago

1.3.6

2 years ago

1.5.3

1 year ago

1.4.4

2 years ago

1.3.5

2 years ago

1.5.2

1 year ago

1.4.3

2 years ago

1.3.4

2 years ago

1.5.1

1 year ago

1.4.2

2 years ago

1.5.0

1 year ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.9

1 year ago

1.4.8

1 year ago

1.3.9

2 years ago

1.4.7

1 year ago

1.3.8

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago