Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upPDF generation #1
Comments
This comment has been minimized.
This comment has been minimized.
|
BTW I have some experience with |
This comment has been minimized.
This comment has been minimized.
|
Thanks. How would you implement PDF generation using pandoc? |
This comment has been minimized.
This comment has been minimized.
|
First step would be to generate a single page output (even HTML would be interesting in itself, e.g. if you want to email the documentation). Pandoc needs an input and a template. The input could be said HTML document, or markdown or what it is you currently generate. The template is in LaTeX. Pandoc would than be required on the path. Creating PDF files through LaTeX is a bit of a pain through, as it depends on texlive which is over 2GB when installed fully. Maybe offer the option to compile through docker? Most developers have that installed nowadays I guess... Some alternatives are possible:
|
This comment has been minimized.
This comment has been minimized.
|
I tried pandoc to convert pdoc documentation index.html as well as some other HTML. It didn't work. The latex converters seem picky about everything, including non-ASCII characters and referenced SVG images. There are some indications (jgm/pandoc#1793 (comment)) that alternative engines should be preferred for better results. Engine Pdoc indeed already contains some provisions for printing: Line 353 in e7868e2 Lines 302 to 381 in e7868e2 If we could somehow leverage the common web browsers, some instance of which exists in almost all environments, that'd be great! I was looking into Selenium / WebDriver API and whether it supports printing to file, but it appears this is not the (common) case. I found this Reddit thread, comparing several possible approaches, and of the listed I feel like preferring running Chrome the most. chromium --headless --disable-gpu --print-to-pdf=output.pdf input.htmlSecond to that maybe WeasyPrint, but that has a list of dependencies that may not be so easy to support in all environments (e.g. Windos without a C/C++ compiler). |
kernc
changed the title
PDF generation is mentioned in docs but seems unavailable
PDF generation
Jan 18, 2019
This comment has been minimized.
This comment has been minimized.
|
I like the chromium route best. How much work would it be to generate a single HTML file? The current index file can become the TOC, the rest chapters, all links internal. |
This comment has been minimized.
This comment has been minimized.
|
Currently, every module is rendered and written out separately: Lines 253 to 275 in e7868e2 So not too much, but it would certainly bear generating a new mako template that handles a list of modules and in which all Is ths something you would care to work on? |
This comment has been minimized.
This comment has been minimized.
|
Or, probably better yet, adapting existing HTML template. It already handles a list of modules in a way when pdoc is run as Lines 66 to 81 in e7868e2 |
kernc
added this to the 0.6.0 milestone
Jan 24, 2019
kernc
added
the
enhancement
label
Jan 27, 2019
This comment has been minimized.
This comment has been minimized.
|
@victorklos I made some progress #20 using markdown and pandoc. If you're still interested, please have a look. |
This comment has been minimized.
This comment has been minimized.
|
Great! I will, but earliest this weekend... |
This comment has been minimized.
This comment has been minimized.
|
The generated PDF already looks great though! Maybe add some |
This comment has been minimized.
This comment has been minimized.
|
It now prints straight to markdown, so any styling would need to be overridden on pandoc/LaTeX level, or a new set of CSS written and included as raw HTML for conversion through intermediate HTML. |
victorklos commentedJan 18, 2019
Expected Behavior
A generated pdf document after
pdoc3 --pdf time.Actual Behavior
Steps to Reproduce
Additional info