npm.io
14.2.0 • Published 2 weeks ago

@putout/processor-markdown

Licence
MIT
Version
14.2.0
Deps
10
Size
10 kB
Vulns
0
Weekly
0
Stars
795

@putout/processor-markdown NPM version

Markdown, the simple and easy-to-use markup language you can use to format virtually any document.

(c) markdownguide.org

Putout processor adds ability to get JavaScript, JSX, JSON and TypeScript code from Markdown files.

Install

npm i @putout/processor-markdown -D

Config

{
    "processors": ["markdown"]
}

Usage

Processor converts markdown to JavaScript, it looks like this.

# hello

Became:

__putout_processor_markdown([
    header(1, 'hello'),
]);
Writing Putout Plugins for Markdown
The core idea

Under the hood, @putout/processor-markdown uses a small library called happy-mark to turn your document into nested function calls. A heading becomes a call to heading(...), a paragraph becomes paragraph(...), a link becomes link(...), and so on. For example, this Markdown:

# Hello world

Some *emphasis* and a [link](https://example.com).

turns into this JavaScript:

heading(1, 'Hello world');
paragraph('Some ', italic('emphasis'), ' and a ', link('link', 'https://example.com'), '.');

Rules

Checkout markdown-related rules in @putout/plugin-markdown

License

MIT

Keywords