gunar / medium-converter

Convert Medium posts to PDF, MOBI & EPUB
https://medium-converter.com/
52 stars 9 forks source link

Add images and code scripts #5

Open matbrik opened 6 years ago

matbrik commented 6 years ago

Most of the medium articles make heavy use of images and code snippets to describe concepts. Would it be possible add the images or media in general to the generated pdfs?

Cl0v1s commented 6 years ago

Yup, good idea !

Maybe I could try to do this, without breaking the building process this time x)

gunar commented 6 years ago

As far as I know, it is possible yes! PRs are welcome :-)

It would seem that medium-parser accepts images already so I guess we need to solve it at the markdown to pdf conversion.

We might need a new provider for this service.

Cl0v1s commented 6 years ago

After further tests, it seems that the problem with images doesnt come from docverter.

Here is a sample of the markdown produced by the parser:

Blockchain Is a New Model That Makes the Existing Model Obsolete

The geeks are building a new, digital substrate for the global economy

![](undefined)

# Blockchain is a very strange thing — simultaneously the most overhyped, least understood and most disruptive technology of our time

Some say it’s the biggest change to finance since the invention of double-entry bookkeeping during the Renaissance. That solved the problem of merchants knowing whether they could trust their own books, and allowed entrepreneurs and investors to form corporations, paving the way for modern capitalism. However, a third, trusted party was still needed to verify that the information in the books was correct. Half a millennium later, blockchain adds another entry to the ledger: a verifiable cryptographic receipt of any transaction, paving the way for a fairer, safer and more transparent global financial system.

As you can see the image is not correctly generated: ![](undefined)

Maybe we should rework the parser a bit ?

Cl0v1s commented 6 years ago

Hum... It seems that this bug doesnt occur every time.

I've achieved converting this page by switching to the markdowntopdf converter. It works pretty well with images and code samples !

Here is a sample of what it produces:

awselbandautoscalingusingterraform.pdf

The facts is that it only supports converting to pdf :/ Is this a problem ?

My code is here for now, I will rework it a bit.

gunar commented 6 years ago

Great that it worked!

Sounds good to me. For e-book formats, we should be able to transform the generated .pdf into .mobi and .epub.

pettymn commented 6 years ago

Hi,

![](undefined) It's not an image error, this problem happens when there are gistfile mentioned.

Like this:

gistfile

@gunar I really like your lib, it's very useful.

gunar commented 6 years ago

@Pettymn Hi Peterson, glad you like it. Can I ask you two small favors? 1. Open a separate issue for this bug. 2. Link to the exact post you're having trouble with. This will help us move forward. Thanks!

pettymn commented 6 years ago

Done

danarth commented 6 years ago

@Clovis-Portron The issue with only some images being displayed is an issue with medium-parser. I opened an issue over there: gunar/medium-parser#13 that highlights the problem and a solution.

I am currently working on a PR to fix this! 👍

danarth commented 6 years ago

Also @Clovis-Portron where did you find the documentation for markdowntopdf? I have been looking for it and could only work out how to use it by looking at your code :joy:

Cl0v1s commented 6 years ago

@DanielArthurUK I do not think they provide any documentation, I've "reverse-engineered" how they use their own system when we press "Select a file" on this page. :P