shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.48k stars 173 forks source link

eBook > PDF results in a PDF file with only "nullnull" in it #1287 (reopen) #1206

Open miskovics opened 4 years ago

miskovics commented 4 years ago

I've updated to the newest version 0.17.5 and now I get an exception

Error: Command failed: ebook-convert /tmp/mume202011-6956-ydaqil.55ic.html /home/g/Desktop/ebook-example-master/ALICE.pdf --level1-toc //[@ebook-toc-level-1]/@heading --level2-toc //[@ebook-toc-level-2]/@heading --level3-toc //*[@ebook-toc-level-3]/@heading --no-chapters-in-toc --title Alice's Adventures in Wonderland --cover /home/g/Desktop/ebook-example-master/cover.jpg --margin-top=72 --margin-bottom=72 --margin-left=72 --margin-right=72 --paper-size letter --pdf-default-font-size=14 --pdf-header-template SECTION --pdf-footer-template

PAGENUM
Traceback (most recent call last): File "site.py", line 77, in main File "site-packages/calibre/ebooks/conversion/cli.py", line 401, in main File "site-packages/calibre/ebooks/conversion/plumber.py", line 1275, in run File "site-packages/calibre/ebooks/conversion/plugins/pdf_output.py", line 188, in convert File "site-packages/calibre/ebooks/conversion/plugins/pdf_output.py", line 255, in convert_text File "site-packages/calibre/ebooks/pdf/html_writer.py", line 1221, in convert File "site-packages/calibre/ebooks/pdf/html_writer.py", line 606, in add_toc File "site-packages/calibre/ebooks/pdf/html_writer.py", line 585, in create ValueError: Invalid page number: 3

The logged command above is not complete, the shell wants more in a terminal, so I can not test it by direct call. Is there any way to see the complete command?

~/Desktop/ebook-example-master$ ebook-convert /tmp/mume202011-6225-1c4d7zc.ep8yf.html /home/g/Desktop/ebook-example-master/ALICE.pdf --level1-toc //[@ebook-toc-level-1]/@heading --level2-toc //[@ebook-toc-level-2]/@heading --level3-toc //*[@ebook-toc-level-3]/@heading --no-chapters-in-toc --title Alice's Adventures in Wonderland --cover /home/g/Desktop/ebook-example-master/cover.jpg --margin-top=72 --margin-bottom=72 --margin-left=72 --margin-right=72 --paper-size letter --pdf-default-font-size=14 --pdf-header-template SECTION --pdf-footer-template
> ^C
~/Desktop/ebook-example-master$ 

I also had to fix ALICE.md. This time not only "/cover.jpg", but also the path to the embedded .md's.

Whenever you pass arguments to ebook-convert that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces” -- https://manual.calibre-ebook.com/generated/en/ebook-convert.html

Doesn't the title of the book (--title Alice's Adventures in Wonderland) need to be enclosed in quotation marks?

_Originally posted by @miskovics in https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1207

shd101wyy commented 4 years ago

Hmmm weird. It works fine on my laptop (Ubuntu 18.04). I will take a closer look. Thanks.

miskovics commented 4 years ago

I tested this again on Ubuntu 19.10 (new installation), latest Calibre 4.12 directly from their website.

Problem shd101wyy/markdown-preview-enhanced#1: paths and tags are not enclosed in quotation marks and if they have a space inside, the PDF conversion aborts.

So I copied the command from the error message and fixed it by adding quotation marks by hand. (this is not the Alice ebook, but an other one!)

$ ebook-convert /tmp/mume202029-12492-16pkznp.5l9y.html "/home/****.pdf" --level1-toc //[@ebook-toc-level-1]/@heading --level2-toc //[@ebook-toc-level-2]/@heading --level3-toc //*[@ebook-toc-level-3]/@heading --no-chapters-in-toc --title Truth --authors "****" --cover "/home/****.png" --publisher "****" --book-producer "****" --pubdate 2020 --language en --tags "****" --rating 5 --margin-top=22 --margin-bottom=22 --margin-left=22 --margin-right=22 --paper-size a5 --pdf-default-font-size=13 --pdf-page-numbers --pretty-print
Conversion options changed from defaults:
  pretty_print: True
  level3_toc: u'//*[@ebook-toc-level-3]/@heading'
  pubdate: u'2020'
  margin_right: 22.0
  margin_top: 22.0
  title: u'Truth'
  cover: u'/home/****.png'
  book_producer: u'****'
  publisher: u'****'
  pdf_page_numbers: True
  margin_bottom: 22.0
  pdf_default_font_size: 13.0
  level1_toc: u'//[@ebook-toc-level-1]/@heading'
  language: u'en'
  margin_left: 22.0
  paper_size: u'a5'
  rating: u'5'
  authors: u'****'
  tags: u'****'
  level2_toc: u'//[@ebook-toc-level-2]/@heading'
  no_chapters_in_toc: True
1% Converting input to HTML...
InputFormatPlugin: HTML Input running
on /tmp/mume202029-12492-16pkznp.5l9y.html
Building file list...
Normalizing filename cases
Rewriting HTML links
34% Running transforms on e-book...
Merging user specified metadata...
Detecting structure...
Invalid ToC expression, ignoring: //[@ebook-toc-level-1]
Auto generated TOC with 0 entries.
Flattening CSS and remapping font sizes...
Ignoring CSS rule with invalid selector: u'.scrollbar-style::-webkit-scrollbar' (The pseudo-class :-webkit-scrollbar is not supported)
Ignoring CSS rule with invalid selector: u'.scrollbar-style::-webkit-scrollbar-track' (The pseudo-class :-webkit-scrollbar-track is not supported)
Ignoring CSS rule with invalid selector: u'.scrollbar-style::-webkit-scrollbar-thumb' (The pseudo-class :-webkit-scrollbar-thumb is not supported)
Ignoring CSS rule with invalid selector: u'html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar' (The pseudo-class :-webkit-scrollbar is not supported)
Ignoring CSS rule with invalid selector: u'html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track' (The pseudo-class :-webkit-scrollbar-track is not supported)
Ignoring CSS rule with invalid selector: u'html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb' (The pseudo-class :-webkit-scrollbar-thumb is not supported)
Source base font size is 11.52000pt
Removing fake margins...
Cleaning up manifest...
Trimming unused files from manifest...
Creating PDF Output...
67% Running PDF Output plugin
68% Parsed all content for markup transformation
70% Completed markup transformation
90% Rendered all HTML as PDF
91% Added links to PDF content
93% Adding headers and footers
96% Headers and footers added
100% Updated metadata in PDF
PDF output written to /home/****.pdf
Output saved to   /home/****.pdf
$ 

Problem shd101wyy/markdown-preview-enhanced#2: the resulting .pdf looks good, has cover image, but has only 3 pages (1 cover + 2 normal). The source has much more, visible in Atom's right-pane preview and the generated EPUB.

Can you, please, enclose the paths, title, and tags in quotation marks for the PDF generation? Do you have any idea why only 3 pages are generated? (there seems to be a problem with CSS, see Ignoring CSS rule with invalid selector above)

miskovics commented 4 years ago

Retested with https://github.com/shd101wyy/ebook-example and still can't generate epub/PDF, the starting slashes in

* [I. Down the Rabbit-Hole](/contents/down-the-rabbit-hole.md)
* [II. The Pool of Tears](/contents/the-pool-of-tears.md)
* [III. A Caucus-Race and a Long Tale](/contents/a-caucus-race-and-a-long.md)
* [About this project](/contents/project-intro.md)

break the conversion.

@shd101wyy is this a software or content bug? If the latter one, shall I submit a bug report in https://github.com/shd101wyy/ebook-example ?

miskovics commented 4 years ago

Hello @shd101wyy , I would really need this feature working. Can I do something to move this issue forward?

shd101wyy commented 4 years ago

Hi @miskovics . Sorry I have been busy recently. The code related to ebook generation defined in eBookExport function:

https://github.com/shd101wyy/mume/blob/master/src/markdown-engine.ts#L1889

in @shd101wyy/mume project.
I just tried the Alice ebook exmaple again on my Ubuntu 18.04 with the shipped Calibre 3.44, everything works fine.
If you have time, could you please try and modify the mume library to see if it helps.
It will take me a while to come back to the MPE project though. Sorry for the trouble.