markdown-function
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

markdown-function

Markdown builder functions.

Features

  • Simple tag builder function
  • Escape markdown syntax
  • Combination with Template Literal
  • Tiny size(~1kb)
  • Tree Shaking support
  • TypeScript

If you want to add more function, Please create issue and Pull Request!

Install

Install with npm:

npm install markdown-function

Usage

import { mdLink, mdImg, mdCodeBlock, mdEscape } from "markdown-function"
const markdown = `## ${mdLink({ text: "**TITLE**", url: "https://example.com" })}
    
**${mdEscape("**text**")}**    

- list item
- ${mdLink({ text: "__inline__", url: "https://example.com" })} Text

${mdImg({ url: "https://example.com/img.png" })}

${mdCodeBlock({ value: `var a = 1;`, lang: "js" })}
`;
console.log(markdown);
/*
## [\*\*TITLE\*\*](https://example.com)

**\*\*text\*\***

- list item
- [\_\_inline\_\_](https://example.com) Text

![](https://example.com/img.png)

```js
var a = 1;
```
*/

No escape value

trusted function prevent the escaping by markdown-function

import { mdLink, trusted } from "markdown-function"
const markdown = `## ${mdLink({ text: trusted("**TITLE**"), url: "https://example.com" })};
console.log(markdown); // => "## [**TITLE**](https://example.com)

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Related

Dependents (3)

Package Sidebar

Install

npm i markdown-function

Weekly Downloads

157

Version

2.0.0

License

MIT

Unpacked Size

29.4 kB

Total Files

59

Last publish

Collaborators

  • azu