Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sethvincent/beldown

create dom nodes from markdown inside tagged template strings using bel & marked
https://github.com/sethvincent/beldown

Last synced: about 1 month ago
JSON representation

create dom nodes from markdown inside tagged template strings using bel & marked

Awesome Lists containing this project

README

        

# beldown

Create dom nodes from markdown inside tagged template strings using [bel](https://github.com/shama/bel) & [marked](https://github.com/chjj/marked).

## Install

```
npm install --save beldown
```

## Why

Because maybe you're working with [yo-yo](https://github.com/maxogden/yo-yo) or [choo](https://github.com/yoshuawuyts/choo) and want a way to easily turn markdown into dom nodes they can use.

## Example

```js
var md = require('beldown')

var html = md`
# hi

this is markdown
`

console.log(html.toString())
```

This returns:

```html


hi


this is markdown



```

## Passing options to [marked](https://github.com/chjj/marked)

```js
var md = require('beldown')

md.setOptions({
gfm: false
})

var html = md`~~Github flavored markdown is off~~`
console.log(html.toString())
```

This returns:

```html


~~Github flavored markdown is off~~



```

## Caveats:
The wrapping div is required because multiple root elements must be wrapped in an enclosing tag. I'm not sure if there's a great way around that.

Leading whitespace of each line is currently stripped. Maybe there's a case where that breaks things?

## License
[ISC](LICENSE.md)