diff --git a/exampleOutput.md b/exampleOutput.md index c68989c..a355ca0 100644 --- a/exampleOutput.md +++ b/exampleOutput.md @@ -1,5 +1,5 @@ -> medium-to-markdown@0.0.2 convert C:\dev\misc\medium-to-markdown +> medium-to-markdown@0.0.3 convert C:\dev\misc\medium-to-markdown > node index.js "https://medium.com/@almenon214/keeping-yourself-motivated-as-a-coder-a16a6fcf49c7" Keeping yourself motivated as a coder @@ -15,8 +15,6 @@ Follow Programmers probably have one of the most distracting jobs in existence. Their entire workday is spent in front of a computer — a literally endless source of entertainment and pleasure, a limitless virtual heaven. With literally just a click of a button, you could be in another world. You could be slaying dragons. You could be learning about the [great molasses flood of 1919](https://www.damninteresting.com/the-great-molasses-flood-of-1919/). You could literally be doing _anything._ So why do programmers spend their time programming, a hobby that could only be described as exciting by masochistic workaholics? -![](https://miro.medium.com/max/60/1*S15R5ty8G-kRGo-ghk2EGA.jpeg?q=20) - Pictured: sticky, sweet, syrupy disaster diff --git a/lib/convertFromUrl.js b/lib/convertFromUrl.js index 654a216..be76587 100644 --- a/lib/convertFromUrl.js +++ b/lib/convertFromUrl.js @@ -33,6 +33,22 @@ turndownService.addRule('mediumInlineLink', { } }) +// Medium has these weird hidden images that are in the html and get rendered +// by turndown. We filter these out. +turndownService.addRule('noHiddenImages', { + filter: function (node, options) { + return ( + node.nodeName === 'IMG' && + node.getAttribute('src') && + node.getAttribute('src').endsWith('?q=20') + ) + }, + + replacement: function () { + return '' + } +}) + function convertFromUrl(url) { return new Promise(function(resolve, reject) { request({