https://github.com/cellular/tinymd
Tiny markdown processor
https://github.com/cellular/tinymd
Last synced: 10 months ago
JSON representation
Tiny markdown processor
- Host: GitHub
- URL: https://github.com/cellular/tinymd
- Owner: cellular
- License: mit
- Created: 2017-07-27T09:56:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-15T09:41:25.000Z (over 8 years ago)
- Last Synced: 2025-07-06T19:24:02.604Z (12 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 7
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinymd 💃
[](https://travis-ci.org/fgnass/tinymd) 
## Why
All other solutions were either _too large_ to be used in webapps where bundle size is important or _too constraint_ (like missing support for paragraphs or nested lists).
Tinymd tries to strike a good balance between size and features. It's fully tested and works in browsers as well as in Node.
The underlying parsing alorithm is heavily based on Vladimir Antonov's [nano-markdown](https://github.com/Holixus/nano-markdown) implementation.
## Basic Usage
```js
import tinymd from 'tinymd';
const opts = {};
const html = tinymd('', opts);
```
### Supported markdown syntax
```markdown
# tinymd
supports ...
* lists
- nested lists
1. ordered
2. with [links](http://example.com)
- 
- rulers
----
All ~~common~~ **inline** _styles_
code blocks
rulers
And \[escaping]\(of special chars).
```
## Options
### Target _blank
By default all links starting with `+` will get `target="_blank"` attribute. You can customize this behavior by providing an `isBlank` function:
```js
tinynmd('[link](http://example.com)', {
isBlank: ref => ~ref.indexOf('://')
}
};
```
### Rewriting URLs
You can rewrite all links and image sources by providing a `rewrite` function:
```js
tinynmd('[Issue 42](#42)', {
rewrite: s => {
const m = /^#(\d+)/.exec(s);
return m ? `/issue${m[1]}` : s;
}
};
```
### Adding headline anchors
```js
tinynmd('# hello world', { addIds: true });
//
hello world
```
## License
MIT