Home
Forums
New posts
Search forums
What's new
New posts
New resources
New profile posts
Latest activity
Resources
Latest reviews
Search resources
Members
Current visitors
New profile posts
Search profile posts
DMCA Policy
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
FEEL FREE TO SHARE TUTORIALS, YOUR SKILS & KNOWLEDGE ON CODING, SCRIPTS, THEMES, PLUGINS OR ANY RESOURCES YOU HAVE WITH THE COMMUNITY-
Click Here To Post Your Request,
JOIN COMPUTER REPAIR FORUM
Home
Forums
TUTORIALS
CODING TUTORIALS
Node.js
Convert HTML to Markdown
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="codeguru" data-source="post: 63" data-attributes="member: 2"><p>One of my biggest mistakes with this blog was not finding a WordPress plugin that would allow me to write my posts with markdown; to this day I still need to write posts in “Visual” mode and then manually convert the post to HTML for “Text” mode. One of these days I want to convert existing posts to Markdown and then enable a plugin that will convert Markdown to HTML. This painful process made me ask myself: is there a way I can use Node.js JavaScript to convert HTML to Markdown? There is, and it’s called <a href="https://github.com/domchristie/turndown" target="_blank">Turndown</a> by Dom Christie.</p><p></p><p><strong>Convert HTML to Markdown with Node.js</strong></p><p></p><p>Start by installing Turndown:</p><p></p><p></p><p>yarn add turndown</p><p></p><p></p><p>Then use Turndown’s simple API to convert HTML to markdown:</p><p></p><p></p><p>var TurndownService = require('turndown');</p><p>var turndownService = new TurndownService();</p><p></p><p>var markdown = turndownService.turndown(`</p><p> </p><h2>Title</h2><p></p><p> </p><p><a href="https://davidwalsh.name" target="_blank">DavidWalsh.Name</a> is awesome!</p><p></p><p></p><p>`);</p><p></p><p>/*</p><p>Title</p><p>=====</p><p></p><p>[DavidWalsh.Name](https://davidwalsh.name) is awesome!</p><p>*/</p><p></p><p></p><p>You can use the <a href="http://domchristie.github.io/turndown/" target="_blank">interactive Turndown demo</a> to experiment with its capabilities. Turndown has a <a href="https://github.com/domchristie/turndown#options" target="_blank">number of options</a> and allows you to use <a href="https://github.com/domchristie/turndown#keepfilter" target="_blank">filters</a> to keep elements you believe could be at risk for improper conversion.</p><p></p><p>Most developers look for a Markdown to HTML solution so it’s rate to find myself in a position to need to convert HTML to Markdown. I look forward to migrating my site’s content to Markdown so that writing posts is much less stressful in the future!</p><p></p><p>The post <a href="https://davidwalsh.name/convert-html-markdown" target="_blank">Convert HTML to Markdown</a> appeared first on <a href="https://davidwalsh.name" target="_blank">David Walsh Blog</a>.</p><p></p><p><a href="https://tkjs.us/dwb" target="_blank"><img src="https://davidwalsh.name/demo/tjs_block-1.svg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p></p><p><a href="https://davidwalsh.name/convert-html-markdown" target="_blank">Continue reading...</a></p></blockquote><p></p>
[QUOTE="codeguru, post: 63, member: 2"] One of my biggest mistakes with this blog was not finding a WordPress plugin that would allow me to write my posts with markdown; to this day I still need to write posts in “Visual” mode and then manually convert the post to HTML for “Text” mode. One of these days I want to convert existing posts to Markdown and then enable a plugin that will convert Markdown to HTML. This painful process made me ask myself: is there a way I can use Node.js JavaScript to convert HTML to Markdown? There is, and it’s called [URL='https://github.com/domchristie/turndown']Turndown[/URL] by Dom Christie. [B]Convert HTML to Markdown with Node.js[/B] Start by installing Turndown: yarn add turndown Then use Turndown’s simple API to convert HTML to markdown: var TurndownService = require('turndown'); var turndownService = new TurndownService(); var markdown = turndownService.turndown(` [HEADING=1]Title[/HEADING] [URL='https://davidwalsh.name']DavidWalsh.Name[/URL] is awesome! `); /* Title ===== [DavidWalsh.Name](https://davidwalsh.name) is awesome! */ You can use the [URL='http://domchristie.github.io/turndown/']interactive Turndown demo[/URL] to experiment with its capabilities. Turndown has a [URL='https://github.com/domchristie/turndown#options']number of options[/URL] and allows you to use [URL='https://github.com/domchristie/turndown#keepfilter']filters[/URL] to keep elements you believe could be at risk for improper conversion. Most developers look for a Markdown to HTML solution so it’s rate to find myself in a position to need to convert HTML to Markdown. I look forward to migrating my site’s content to Markdown so that writing posts is much less stressful in the future! The post [URL='https://davidwalsh.name/convert-html-markdown']Convert HTML to Markdown[/URL] appeared first on [URL='https://davidwalsh.name']David Walsh Blog[/URL]. [URL='https://tkjs.us/dwb'][IMG]https://davidwalsh.name/demo/tjs_block-1.svg[/IMG][/URL] [url="https://davidwalsh.name/convert-html-markdown"]Continue reading...[/url] [/QUOTE]
Insert quotes…
Verification
Post reply
Richest Freecoded User
Most Freecoin
freecoded
4,838 Freecoin
Davy200
590 Freecoin
J
Johnhendrick
575 Freecoin
S
Smith16
527 Freecoin
nathan69
426 Freecoin
Laureine
415 Freecoin
A
anajeen
370 Freecoin
C
codeguru
287 Freecoin
Tekera
267 Freecoin
A
Akubay
170 Freecoin
Home
Forums
TUTORIALS
CODING TUTORIALS
Node.js
Convert HTML to Markdown
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top