Ask HN: What's the best way to write a book in Markdown?
What are the best available tools to use if I want to write a book in markdown and export it as a pdf primarly?
It needs to handle displaying code well as I want to write a technical book.
It needs to handle displaying code well as I want to write a technical book.
25 comments
[ 2.7 ms ] story [ 66.9 ms ] threadAnd keep each chapter as separate file…
* you can easily charge money
* they have support for marketing your book (mostly buying spots in their newsletter)
* you can change what you charge over time (so you can charge less when starting, and gauge interest in your book)
* you can collect email addresses of people who have bought your book and notify them of new chapters
Sure, they take some money, but it's a great platform not just for writing a book, but marketing and selling one.
You can also use it to make your book a knowledge base.
Check out their docs for an example of what can be achieved.
https://docs.obsidian.md/Home
Books are huge undertakings that require a lot of data management and formatting specifications. I don't think Obsidian is particularly well suited to this task, based on what I've experienced.
First, Obsidian's .pdf export/formatting features are nearly non-existent. I struggle to print 4 page documents that are enjoyable to read. Formatting their book as a .pdf will get very tedious very quickly if anything other than the most basic, raw, formatting is needed.
While I love typing in Markdown for notes, Obsidian has almost no native features to help you format long form work. Perhaps there are plugins that grant these features, but I'm not aware of them.
I've done something similar but I burnt so much time on configuring Pandoc, citations, formulas, and a compilation process, instead of writing the actual book. If you're writing in Markdown, most of this process for you can be done at the end too.
With that said, Pandoc has been great. Gotta dive into some configuration to get things how you want for the finalized PDF, but it's great.
https://pandoc.org/index.html
https://asciidoctor.org/
What I like about it is that its easily extendable. You can write preprocessors to give yourself new features or an entire backend/renderer to render the book differently. I've written a very simple one myself.
1: https://weasyprint.org/ 2: https://github.com/adewes/beam-up 3: https://pagedjs.org/ 4: https://pandoc.org/
i've wrote custom code for it that i'll share maybe 1 day but not yet.
what i did was use markdown with node.js & wrote a script that all chapters are read from it.
it looks like this:
_book/ chapter1/ pic1.jpg index.md chapter2/ . . . chapter100/
and then it uses princexml with 100 loc of css to output a beautiful pdf.
this should definitely be a saas though. it has massive potential.
My pipeline went via a custom latex template which unlocks all the formatting power of latex without having to deal with it for the content.
https://komsciguy.com/misc/write-a-programming-book-with-mar...
I've wrote a few books (https://kerkour.com/books) with only markdown, https://excalidraw.com and https://figma.com
I've detailed my complete setup and shared the Dockerfile that I use to convert the markdown into ebooks (EPUB, PDF and Kindle) on my blog: https://kerkour.com/book-self-publishing-pandoc
I recently contributed several chapters to a book. Years ago I wrote a book in MS Word. But this time around we used AsciiDoc. RestructuredText is another option.
I used MS Code's AsciiDoc support, and it worked generally great.
For my sci-fi novel, my character sheet was inside of a spreadsheet. It dawned on me that the character sheet could be replaced with a YAML file and integrated with a Markdown editor. I developed KeenWrite[2] to replace the scripts while allowing me to use interpolated variables and R inside of the prose.
My novel has two separate timelines and I wanted to make sure that dates lined up correctly without having to do the date math manually. I implemented a number date functions in R[3] based around an "anchor" date. As long as all my other dates are relative (in days) to the anchor date, all the math checks out. Possessives and pronouns are also handled in R (meaning I can change a character's gender by changing a single variable, provided I haven't referenced any sex-specific body parts or characteristics).
Also, I wanted a nice-looking PDF file to send to alpha readers (still looking, see profile). For that, I crafted KeenWrite Themes[4] along with a video tutorial series showing how all the software components work together.
On the technical side, Markdown lacks a standard syntax for citations and cross-references. I've written about this at length.[6] If flexmark-java were to get support, then it would help resolve a long-standing issue with KeenWrite.[7]
[1]: https://dave.autonoma.ca/blog/2019/05/22/typesetting-markdow...
[2]: https://keenwrite.com/
[3]: https://gitlab.com/DaveJarvis/KeenWrite/-/blob/main/R/conver...
[4]: https://gitlab.com/DaveJarvis/keenwrite-themes/
[5]: https://www.youtube.com/playlist?list=PLB-WIt1cZYLm1MMx2FBG9...
[6]: https://talk.commonmark.org/t/cross-references-and-citations...
[7]: https://gitlab.com/DaveJarvis/KeenWrite/-/issues/145