medium-markdown
v0.2.0
Published
A package to convert HTML to Markdown, specifically for Medium posts.
Downloads
4
Maintainers
Readme
Medium Markdown
Introduction
This package provides two functions:
- generating markdown from an Medium article
- writing the article to file
The package supports Jekyll style blogging,
such that you can directly copy the generated file into your _posts/
folder.
Usage
const markdownConverter = require('medium-markdown');
async function main(postUrl) {
markdownConverter.generateFile(
await markdownConverter.convert(postUrl));
}
The convert
function returns a dict containing { markdown, heading, time }
for the Medium post.
generateFile
also takes in an optional padding before and after argument, which it
adds to the markdown. Thus, to directly generate Jekyll suitable markdown posts,
you can do the following (this is the script I use too):
const markdownConverter = require('medium-markdown');
const url = 'your medium article url';
const paddingBefore = `---
layout: post
---
Originally published on [Medium](${url})
`;
async function main(postUrl) {
markdownConverter.generateFile(
await markdownConverter.convert(postUrl),
paddingBefore,
);
}
main(url);
Further, I have fixed the subtitles for images looking pathetic. To style the subtitles
however you want, you can use the following css. Or add it to your existing .scss
file on Jekyll.
img + em {
font-style: italic;
font-weight: 600;
margin-bottom: 20px;
margin-top: 8px;
display: block;
text-align: center;
font-size: 14px;
color: black;
}
This returns me, precisely, this