add back converters from earlier

This commit is contained in:
almenon 2019-12-23 22:26:04 -08:00
parent c729d04a7a
commit b6e4e16e60
3 changed files with 38 additions and 7 deletions

View File

@ -5,13 +5,7 @@
Keeping yourself motivated as a coder
=====================================
[![Almenon](https://miro.medium.com/fit/c/96/96/1*4FAOBq9qVna6uHkxaolTtA.png)](https://medium.com/@almenon214?source=post_page-----a16a6fcf49c7----------------------)
[Almenon](https://medium.com/@almenon214?source=post_page-----a16a6fcf49c7----------------------)
Follow
[Sep 23, 2018](https://medium.com/@almenon214/keeping-yourself-motivated-as-a-coder-a16a6fcf49c7?source=post_page-----a16a6fcf49c7----------------------) · 4 min read
[![Almenon](https://miro.medium.com/fit/c/96/96/1*4FAOBq9qVna6uHkxaolTtA.png)](https://medium.com/@almenon214?source=post_page-----a16a6fcf49c7----------------------)[Almenon](https://medium.com/@almenon214?source=post_page-----a16a6fcf49c7----------------------)Follow[Sep 23, 2018](https://medium.com/@almenon214/keeping-yourself-motivated-as-a-coder-a16a6fcf49c7?source=post_page-----a16a6fcf49c7----------------------) · 4 min read
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?

View File

@ -5,9 +5,16 @@ const cheerio = require('cheerio');
const TurndownService = require('turndown')
const gfm = require('turndown-plugin-gfm').gfm
const converters = require('./mdConverters');
const turndownService = new TurndownService()
turndownService.use(gfm)
converters.forEach((converter)=>{
turndownService.addRule(converter.filter, converter)
})
// following block adapted from https://github.com/domchristie/turndown/blob/61c2748c99fc53699896c1449f953ea492311c5b/src/commonmark-rules.js#L131
turndownService.addRule('mediumInlineLink', {
filter: function (node, options) {

30
lib/mdConverters.js Normal file
View File

@ -0,0 +1,30 @@
'use strict';
const converters = [
{
filter: 'section',
replacement: function(content) {
return content;
}
},
{
filter: 'div',
replacement: function(content) {
return content;
}
},
{
filter: 'figure',
replacement: function(content) {
return content;
}
},
{
filter: 'figcaption',
replacement: function(content) {
return content;
}
},
]
module.exports = converters