kates / html2markdown Goto Github PK
View Code? Open in Web Editor NEWConverts HTML to Markdown
License: MIT License
Converts HTML to Markdown
License: MIT License
I understand the reason why, by default, html2markdown should ignore certain unsafe HTML. However, in my case, I would like html2markdown to copy HTML it doesn't understand to the markdown.
This is required when our (trusted) users wish to embed a youtube video or twitter embed.
var html2markdown = require('html2markdown');
var fs = require('fs');
var http = require('http');
http.createServer(function(req, res){
fs.readFile('index.html',function (err, data){
if (err) throw new Error(err);
res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
res.write(html2markdown(data));
res.end();
});
}).listen(8000);
ERROR:
`
L:\github\Java\springmvc-cookbook\cloudstreetmarket-parent\cloudstreetmarket-webapp\src\main\webapp\static\node_modules\html2markdown\markdown_html_parser.js:105
match = html.match( startTag );
^
TypeError: html.match is not a function
at HTMLParser (L:\github\Java\springmvc-cookbook\cloudstreetmarket-parent\cloudstreetmarket-webapp\src\main\webapp\static\node_modules\html2markdown\markdown_html_parser.js:105:19)
at html2markdown (L:\github\Java\springmvc-cookbook\cloudstreetmarket-parent\cloudstreetmarket-webapp\src\main\webapp\static\node_modules\html2markdown\html2markdown.js:197:2)
at module.exports (L:\github\Java\springmvc-cookbook\cloudstreetmarket-parent\cloudstreetmarket-webapp\src\main\webapp\static\node_modules\html2markdown\index.js:7:10)
at L:\github\Java\springmvc-cookbook\cloudstreetmarket-parent\cloudstreetmarket-webapp\src\main\webapp\static\js\html2markdown.js:16:13
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
`
If I pass a html from a url , it got an error:
Parse Error: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'><title>Aggregation Pipeline — MongoDB Manual 2.4.8</title><link rel="shortcut icon" href="http://media.mongodb.org/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript" src="markdown_dom_parser.js"></script>
<script type="text/javascript" src="html2markdown.js"></script>
console.log(html2markdown("<h1>Hello markdown!</h1>"))
node mode is good.
Hello,
The GitHub Security Lab team has found a potential vulnerability in your project. Please create a Security Advisory and invite me in to further disclose and discuss the vulnerability details and potential fix. Alternatively, please add a Security Policy containing a security email address to send the details to.
Kind regards,
A
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.