{"id":11283,"date":"2019-07-14T10:23:57","date_gmt":"2019-07-14T08:23:57","guid":{"rendered":"http:\/\/flaven.fr\/?p=11283"},"modified":"2019-07-17T06:54:01","modified_gmt":"2019-07-17T04:54:01","slug":"using-pandoc-to-generate-documentation-manuals-in-pdf-docx-html-from-markdown-documents","status":"publish","type":"post","link":"https:\/\/flaven.fr\/2019\/07\/using-pandoc-to-generate-documentation-manuals-in-pdf-docx-html-from-markdown-documents\/","title":{"rendered":"Using Pandoc to generate documentation, manuals in pdf, docx, html from markdown documents"},"content":{"rendered":"<p>Since few months, as I am working on new back-office made with Symfony, I tried to explore the best way to share information with the minimum of repeatedly work. The documentation is gathered mostly for user support. It should be available for any kind of users from end-users to training people through developers and in especially in any format (pdf, html&#8230;) without depreciations.<\/p>\n<p><b>You can find the files on GitHub at<br \/>\n<a href=\"https:\/\/github.com\/bflaven\/BlogArticlesExamples\/tree\/master\/using_pandoc\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/bflaven\/BlogArticlesExamples\/tree\/master\/using_pandoc<\/a><\/b><\/p>\n<p>To solve these common issues, I headed to video tutorials as it is the best way to share as no one is reading anymore \ud83d\ude42 but I still had a lot stuff written and unexploited! To make it shareable at least, I have converted them into markdown format as it seems the format commonly accepted by developers. This format, I discovered it through an intensive usage of GitHub.<\/p>\n<p>Still, making a documentation is an hassle, in particular if you want to release in the end a manual in pdf for instance. At the very beginning, with the markdown, I had low expectations in term of design and appearance. Even though I was making progress in markdown coding, the more my document&#8217;s markdown structure becoming complex the less the output in pdf for instance was satisfying! <\/p>\n<p>For the conversion from readme to pdf, I discovered and used Pandoc, a great tool however if you want to make a true layout for a pdf for instance, better used a desktop publishing software like Scrivener or even InDesign for instance.<\/p>\n<h3>Using Pandoc<\/h3>\n<p><b>If you need to install Pandoc on a Mac, Homebrew remains the best way to do it!<\/b><\/p>\n<pre lang=\"bash\">\r\n  #install pandoc\r\n  brew update && brew install pandoc\r\n  #update pandoc\r\n  brew update && brew upgrade pandoc\r\n<\/pre>\n<p>When Pandoc is installed, you can try to enter few commands to generate whether a PDF or an EPUB, converting on fly your markdown files. Below you can find some command that can be passed in the console to generate whether an .pdf file or an .epub file.<\/p>\n<pre lang=\"bash\">\r\n#go to the dir\r\ncd [path-to-your-dir]\/using_pandoc\/\r\n\r\n\r\n#OK for PDF\r\npandoc --toc --latex-engine=xelatex chapters\/*.md -o readme_to_pdf_all.pdf\r\n\r\n#OK for epub with no cover\r\npandoc --toc --latex-engine=xelatex --table-of-contents --toc-depth=3 --epub-chapter-level=3 --webtex chapters\/*.md -o readme_to_pdf_all.epub\r\n\r\n#OK for epub with cover\r\npandoc --toc --latex-engine=xelatex --epub-cover-image=images\/cover_1563x2500.jpg --table-of-contents --toc-depth=3 --epub-chapter-level=3 --webtex chapters\/*.md -o readme_to_pdf_all.epub\r\n<\/pre>\n<h3>Using a <code>Makefile<\/code><\/h3>\n<p>To ease the creation, let&#8217;s create a <code>Makefile<\/code> to automate the delivery. You can find it in the github account. <\/p>\n<p><b>All the files will be created in a directory named <code>output<\/code><\/b><\/p>\n<pre lang=\"bash\">\r\n# Run \"make\" (or \"make all\") to convert to all other formats\r\n# Run \"make epub\" to convert file in .epub\r\n# Run \"make pdf\" to convert file in .pdf\r\n# Run \"make docx\" to convert file in .docx\r\n# Run \"make html\" to convert file in .html\r\n# Run \"make delete\" to remove to all files and directories\r\n<\/pre>\n<p><H3>Conclusion<\/H3><br \/>\nI must admit Pandoc is pretty powerful to generate all kind of document on fly with the help of a makefile. For instance, if you are quoting code in your book e.g ruby, javascript, php&#8230; The rendering is almost as good for syntax highlight as a text editor like Sublime or Visual Code or even Polacode for Visual Studio Code. Yes, it is definitely essential for documentation, it is easy and quick but for layout a real book, I &#8216;d rather use another software like Scrivener.<\/b><\/p>\n<p><b>Launching the command <code>make<\/code><\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_1.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>Launching the command <code>make delete<\/code><\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_2.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>Editing the epub with calibre<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_3.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>Output of a code extract in a PDF produced with Pandoc from markdown file.<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_4.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>A picture inside the pdf with a legend<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_5.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>The front page for the epub<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_6.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<p><b>A code extract captured with Polacode from Visual Studio Code<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_7.jpg\" alt=\"Using Pandoc to generate documentation, manuals in\npdf, docx, html from markdown documents\" width=\"585\" height=\"330\" \/><\/p>\n<h2>Read more<\/h2>\n<ul>\n<li>Example of makefile<br \/><a href=\"https:\/\/gist.github.com\/kristopherjohnson\/7466917\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/gist.github.com\/kristopherjohnson\/7466917<\/a><\/li>\n<li>Markdown Basics<br \/><a href=\"https:\/\/markdown-guide.readthedocs.io\/en\/latest\/basics.html\"\ntarget=\"_blank\" rel=\"noopener noreferrer\">https:\/\/markdown-guide.readthedocs.io\/en\/latest\/basics.html<\/a><\/li>\n<li>Markdown &#8211; Basic writing and formatting syntax<br \/><a href=\"https:\/\/help.github.com\/en\/articles\/basic-writing-and-formatting-syntax\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/help.github.com\/en\/articles\/basic-writing-and-formatting-syntax<\/a><\/li>\n<li>Another good example of makefile<br \/><a \n    href=\"https:\/\/github.com\/open-review-toolkit\/open-review-toolkit\/blob\/master\/Makefile\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/open-review-toolkit\/open-review-toolkit\/blob\/master\/Makefile<\/a><\/li>\n<li>A simple Pandoc template to build documents and ebooks.<br \/><a href=\"https:\/\/github.com\/wikiti\/pandoc-book-template\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/wikiti\/pandoc-book-template<\/a><\/li>\n<li>A nice memoir bootstrap package for Pandoc<br \/><a href=\"https:\/\/github.com\/mre\/pandoc-memoir\/blob\/master\/pub.md\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/mre\/pandoc-memoir\/blob\/master\/pub.md<\/a><\/li>\n<li>Creating PDFs from Markdown with Pandoc and LaTeX<br \/>\n  <br \/><a href=\"https:\/\/www.sitepoint.com\/creating-pdfs-from-markdown-with-pandoc-and-latex\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.sitepoint.com\/creating-pdfs-from-markdown-with-pandoc-and-latex\/<\/a><\/li>\n<li>Utils: Writing a book in Markdown<br \/><a href=\"http:\/\/blog.danielherzog.es\/2017-01-15-utils-writing-a-book-in-markdown\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/blog.danielherzog.es\/2017-01-15-utils-writing-a-book-in-markdown\/<\/a><\/li>\n<li>A good example on how to structure a book and release it with Pandoc<br \/><a href=\"https:\/\/github.com\/progit\/progit2\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/progit\/progit2<\/a><\/li>\n<li>Mastering Markdown, things you need to know to perform in markdown.<br \/><a href=\"https:\/\/guides.github.com\/features\/mastering-markdown\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/guides.github.com\/features\/mastering-markdown\/<\/a><\/li>\n<li>Installing pandoc<br \/><a href=\"https:\/\/pandoc.org\/installing.html\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/pandoc.org\/installing.htmlclear<\/a><\/li>\n<li>LaTeX on Mac, the Easy Way<br \/><a href=\"https:\/\/thetechsolo.wordpress.com\/2016\/01\/28\/latex-on-mac-the-easy-way\/\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/thetechsolo.wordpress.com\/2016\/01\/28\/latex-on-mac-the-easy-way\/<\/a><\/li>\n<li>LaTeX<br \/><a href=\"https:\/\/sourabhbajaj.com\/mac-setup\/LaTeX\/\"\n    target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/sourabhbajaj.com\/mac-setup\/LaTeX\/<\/a><\/li>\n<li>Install LaTeX on Mac with Brew<br \/><a href=\"http:\/\/yabas.net\/blog\/install-latex-on-mac-with-brew\/\"\n    target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/yabas.net\/blog\/install-latex-on-mac-with-brew\/<\/a><\/li>\n<li>22 Best Visual Studio Code Extensions for Web Development<br \/><a href=\"https:\/\/scotch.io\/bar-talk\/22-best-visual-studio-code-extensions-for-web-development\"\n        target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/scotch.io\/bar-talk\/22-best-visual-studio-code-extensions-for-web-development<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Since few months, as I am working on new back-office made with Symfony, I tried to explore the best way to share information with the&hellip; <\/p>\n<p class=\"text-center\"><a href=\"https:\/\/flaven.fr\/2019\/07\/using-pandoc-to-generate-documentation-manuals-in-pdf-docx-html-from-markdown-documents\/\" class=\"more-link\">Continue reading &rarr; <span class=\"screen-reader-text\">Using Pandoc to generate documentation, manuals in pdf, docx, html from markdown documents<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":11291,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"bf_ai_meta_description":"Generate documentation, manuals in PDF, DOCX, HTML from markdown using Pandoc. Streamline information sharing for users, developers, and trainers.","bf_ai_og_title":"Pandoc for Documentation","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3447,3448,3449,3435],"tags":[524,2479,2474,2476,303,2478,2477,2475,2473,2480],"class_list":["post-11283","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology-trends","category-tools-productivity","category-tutorials-how-to","category-web-development","tag-console","tag-documents","tag-epub","tag-generate-document","tag-html","tag-markdown","tag-md","tag-pandoc","tag-pdf","tag-readme"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3Vuhl-2VZ","jetpack_featured_media_url":"https:\/\/flaven.fr\/wp-content\/uploads\/2019\/07\/using_pandoc_b.jpg","_links":{"self":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/11283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/comments?post=11283"}],"version-history":[{"count":10,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/11283\/revisions"}],"predecessor-version":[{"id":11302,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/11283\/revisions\/11302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media\/11291"}],"wp:attachment":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media?parent=11283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/categories?post=11283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/tags?post=11283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}