Comparing version 0.3.0 to 0.3.1
24
index.js
@@ -5,3 +5,3 @@ var posthtml = require('posthtml') | ||
var nonTextTags = ['script', 'style', 'link', 'head'] | ||
var nonTextTags = ['script', 'style', 'link', 'head', 'noscript'] | ||
var commentRegex = /<!--[\s\S]*?-->/g | ||
@@ -16,3 +16,4 @@ var nonTextStringMatchers = ['<!DOCTYPE html>', commentRegex, /^\s+$/] | ||
"`": "`", | ||
" ": " " | ||
" ": " ", | ||
" ": " " | ||
} | ||
@@ -80,3 +81,3 @@ | ||
case 'em': | ||
txt = node.content[0] | ||
txt = getTextInNode(node) | ||
if (txt) { | ||
@@ -88,3 +89,3 @@ text.push(`*${txt.trim()}*`) | ||
case 'strong': | ||
txt = node.content && node.content[0] | ||
txt = getTextInNode(node) | ||
if (txt) { | ||
@@ -96,3 +97,3 @@ text.push(`**${txt.trim()}**`) | ||
case 'code': | ||
txt = node.content[0] | ||
txt = getTextInNode(node) | ||
if (txt) { | ||
@@ -104,3 +105,3 @@ text.push(`\`${txt.trim()}\``) | ||
case 'a': | ||
txt = getTextInNode(node) | ||
txt = getTextInNode(node) || node.attrs.href | ||
if (txt) { | ||
@@ -123,3 +124,3 @@ text.push(`[${txt}](${node.attrs.href})`) | ||
}) | ||
return text.join('').replace(commentRegex, '').trim() | ||
return unescape(text.join('').replace(commentRegex, '').trim()) | ||
} | ||
@@ -147,3 +148,3 @@ | ||
case 'em': | ||
text = node.content && node.content[0] | ||
text = getTextInNode(node) | ||
if (text) { | ||
@@ -155,3 +156,3 @@ md.push(`*${text}*`) | ||
case 'strong': | ||
text = node.content && node.content[0] | ||
text = getTextInNode(node) | ||
if (text) { | ||
@@ -163,3 +164,3 @@ md.push(`**${text}**`) | ||
case 'code': | ||
text = node.content && node.content[0] | ||
text = getTextInNode(node) | ||
if (text) { | ||
@@ -212,3 +213,6 @@ md.push(`\`${text}\``) | ||
break | ||
// pure block element | ||
case 'div': | ||
// figcaption http://www.w3schools.com/tags/tag_figcaption.asp | ||
case 'figcaption': | ||
md.push(`\n\n${getMarkdownInTree(node.content)}`) | ||
@@ -215,0 +219,0 @@ node.content = [] |
{ | ||
"name": "h2m", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Transform HTML to markdown base on posthtml.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"test": "mocha && npm run coverage", | ||
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"build": "browserify browser.js -o dist/h2m.js" | ||
@@ -15,9 +16,23 @@ }, | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/island205/h2m.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/island205/h2m/issues" | ||
}, | ||
"homepage": "http://island205.github.io/h2m/", | ||
"author": "island205@gmail.com", | ||
"license": "ISC", | ||
"dependencies": { | ||
"chai": "^3.4.1", | ||
"posthtml": "^0.8.1", | ||
"posthtml-parser": "^0.1.1" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"coveralls": "^2.11.4", | ||
"jscoverage": "^0.6.0", | ||
"mocha": "^2.3.4", | ||
"mocha-lcov-reporter": "^1.0.0" | ||
} | ||
} |
# h2m | ||
![logo](./design/logo@0.5.png) | ||
[![npm](https://img.shields.io/npm/v/h2m.svg)](https://www.npmjs.com/package/h2m) | ||
[![Build Status](https://travis-ci.org/island205/h2m.svg)](https://travis-ci.org/island205/h2m) | ||
[![Coverage Status](https://coveralls.io/repos/island205/h2m/badge.svg?branch=master)](https://coveralls.io/github/island205/h2m) | ||
@@ -21,8 +25,10 @@ Tool for converting HTML to Markdown. | ||
var md = html('<h1>Hello World</h1>') | ||
var md = h2m('<h1>Hello World</h1>') | ||
// md = '# Hello World' | ||
``` | ||
## Supported | ||
## Support | ||
`h2m` supports standard Markdown sytax: [CommonMark](http://commonmark.org/help/) now. | ||
- :heavy_check_mark: br | ||
@@ -41,2 +47,5 @@ - :heavy_check_mark: em | ||
- :heavy_check_mark: h1 ~ h6 | ||
- :airplane: table | ||
## Contribution | ||
PRs are welcome to implement other extend Markdown language, like [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra), [GFM](https://help.github.com/articles/github-flavored-markdown/) and so on. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1005558
2
27
1
1
50
6
5
8913
8
- Removedchai@^3.4.1
- Removedassertion-error@1.1.0(transitive)
- Removedchai@3.5.0(transitive)
- Removeddeep-eql@0.1.3(transitive)
- Removedtype-detect@0.1.11.0.0(transitive)