Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azu/markdown-function
Markdown builder functions.
https://github.com/azu/markdown-function
builder escape markdown tempalte
Last synced: 24 days ago
JSON representation
Markdown builder functions.
- Host: GitHub
- URL: https://github.com/azu/markdown-function
- Owner: azu
- License: mit
- Created: 2021-01-17T13:33:16.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-16T03:13:32.000Z (almost 2 years ago)
- Last Synced: 2024-10-04T16:15:45.571Z (about 1 month ago)
- Topics: builder, escape, markdown, tempalte
- Language: TypeScript
- Size: 87.9 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# markdown-function
Markdown builder functions.
## Features
- Simple tag builder function
- Escape markdown syntax
- Combination with Template Literal
- [Tiny size(~1kb)](https://bundlephobia.com/result?p=markdown-function)
- Tree Shaking support
- TypeScriptIf you want to add more function, Please create issue and Pull Request!
## Install
Install with [npm](https://www.npmjs.com/):
npm install markdown-function
## Usage
````js
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`
```js
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](https://github.com/azu/markdown-function/releases).
## 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](https://github.com/azu/markdown-function/issues).
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
- azu: [GitHub](https://github.com/azu), [Twitter](https://twitter.com/azu_re)
## License
MIT © azu
## Related
- [Deprecated] [30-seconds/markdown-builder](https://github.com/30-seconds/markdown-builder)