> A JS library for converting HTML to Markdown.[中文](./README.md) --- [](https://travis-ci.org/stonehank/html-to-md) [](https://www.npmjs.com/package/html-to-md) [](https://codecov.io/gh/stonehank/html-to-md)   ### Feature - speed, none of dependencies, `gizp` 10kb - support `nodeJs` - 200+`unit test` and `module test`, code coverage `97%` > Only valid HTML will be output correctly, eg. `
abc<`, `abc>` are **Not Valid** text.
### Live Demo
[live-demo](https://stonehank.github.io/html-to-md/)
### Useage
##### install
`npm i html-to-md`
##### example
```js
const html2md = require('html-to-md')
// or if you're using ES6
import html2md from 'html-to-md'
console.log(html2md('strong and italic', options))
// ***strong and italic***
```
### Config(Optional):
#### options:
> Priority:skipTags > emptyTags > ignoreTags > aliasTags
Example:
```javascript
html2md('<>abc>', { ignoreTags: [''] })
// ''
html2md('<>abc>', { skipTags: [''] })
// ***abc***
html2md('<>abc>', { emptyTags: [''] })
// abc
html2md('<>abc>', {
skipTags: [''],
aliasTags: { b: 'ul', i: 'li' },
})
// * abc
html2md('
name
date type
default value
description
skipTags
Array
[
'div',
'html',
'body',
'nav',
'section',
'footer',
'main',
'aside',
'article',
'header'
]Declare which tags need to skip
emptyTags
Array
[]Skip all the tags inside it
ignoreTags
Array
[
'',
'style',
'head',
'!doctype',
'form',
'svg',
'noscript',
'script',
'meta'
] Ignore all tag and content inside the tag
aliasTags
Object
{
figure :'p',
figcaption:'p',
dl:'p',
dd:'p',
dt:'p'
} Define an alias tag name
renderCustomTags
Boolean
|'SKIP'
|'EMPTY'
|'IGNORE'
trueDefine how to render not valida HTML tags
true: render all custom tagsfalse | SKIP: render as skipTagsEMPTY: render as emptyTagsIGNORE: render as ignoreTags
tagListener
Function
(tagName: String, props: TagListenerProps): TagListenerReturnProps => props
Custom the tag props