New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

h2m

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h2m - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

.travis.yml

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+$/]

"&#x60;": "`",
"&nbsp;": " "
"&nbsp;": " ",
"&#8202;": " "
}

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc