TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How I Wrote My Book

96 pointsby kevinmcconnellover 3 years ago

14 comments

hollaschover 3 years ago
Very cool. I co-edit Peter Shirley&#x27;s _Ray Tracing in One Weekend_ (<a href="https:&#x2F;&#x2F;raytracing.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;raytracing.github.io&#x2F;</a>) and have taken a similar approach, though with a different toolset. At some point if I find the time, I&#x27;ll write up a similar article on our approach and what we&#x27;ve learned. Our books are open-sourced on GitHub (<a href="https:&#x2F;&#x2F;github.com&#x2F;raytracing&#x2F;raytracing.github.io" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;raytracing&#x2F;raytracing.github.io</a>), and we also use GitHub to host our books.<p>Basically, we use Markdeep (<a href="https:&#x2F;&#x2F;casual-effects.com&#x2F;markdeep&#x2F;" rel="nofollow">https:&#x2F;&#x2F;casual-effects.com&#x2F;markdeep&#x2F;</a>), a _very_ powerful Markdown implementation with a bunch of built-in features. The killer feature is that with a handful of boilerplate lines (UTF-8 declaration at the top, and JavaScript loader at the bottom), you get content that automatically self-transforms in the browser into a full HTML document. This eliminates any build step, and means you can treat it as you would any other HTML file, with optional CSS and other features. It also bundles in a LaTeX engine, ASCII diagram rendering, and a whole host of other features. If you look at the three ray tracing books, you can see how simple the source is, and how pleasing the final rendering.<p>Check out the books and the GitHub repo — it&#x27;s a _great_ way to quickly and easily pound out a web book.
pezzanaover 3 years ago
&gt; But when writing a book, pretty soon you run into things that Markdown doesn’t natively know how to do, and so you have to either look for extra tooling to fill in the gaps, or build support for those things yourself. There are open source projects that address some of this, but I didn’t see anything that would do everything I needed.<p>I&#x27;m surprised there&#x27;s no mention of Pandoc, which does pretty much what the author wanted (at least at a high level) and works with markdown:<p><a href="https:&#x2F;&#x2F;pandoc.org&#x2F;epub.html" rel="nofollow">https:&#x2F;&#x2F;pandoc.org&#x2F;epub.html</a>
adamgordonbellover 3 years ago
I would recommend using Vale for linting prose in a text editor. It can approach grammarly like rules as well as handling spelling for technical documents fairly well.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;errata-ai&#x2F;vale" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;errata-ai&#x2F;vale</a>
评论 #29470340 未加载
bArrayover 3 years ago
&gt; At the end of the day, Markdown’s biggest strength — simplicity — is also its limitation.<p>But also its strength again. It&#x27;s missing features, sure, but the features it does have you can be very sure exist in all the export formats. Formatting is really something you should be doing at the end, otherwise it&#x27;s a distraction.<p>I tend to use markdown for the initial writing of academic papers for example, only exporting to LaTeX .tex at the very last minute to address formatting.
danrlover 3 years ago
I wrote mine in LaTeX. I remember that making terminal output fancy was a pain. Eventually I managed to even get scissors to indicate omitted output. I was proud of that. Example: <a href="https:&#x2F;&#x2F;bayimg.com&#x2F;gAaLbAaHI" rel="nofollow">https:&#x2F;&#x2F;bayimg.com&#x2F;gAaLbAaHI</a><p>Then I had so many dependencies that I didn&#x27;t want to update my computer anymore as it could break my build process and the Makefile which did everything from taking the .tex files, to image processing, to PDF generation and cover art integration. So I moved everything into a virtual machine. I still keep it around but I am too afraid to boot it nowadays. Would be pwnd in a second after years of no updates :)<p>Next time I write a book it&#x27;ll be likely non-technical and then markdown should be fine.<p>My book was about IPv6 and since it is no longer up to date I stopped selling it. It&#x27;s available at <a href="https:&#x2F;&#x2F;danrl.com&#x2F;ipv6" rel="nofollow">https:&#x2F;&#x2F;danrl.com&#x2F;ipv6</a> (Book language is German, though)
gorgoilerover 3 years ago
I wrote a school textbook in asciidoc. It was a wonderful tool to use but it soon became rather painful and I wish I had used something more lightweight. 30s build times are misery for tweaking.<p>Whatever was going on in the background — Prawn::PDF or something — was very slow about churning PNGs to format them into a PDF. I added some build logic to make “draft” PDFs with low res PNGs to speed things along, but it felt messy.<p>Ultimately, I wish I had authored with HTML and CSS instead. Markdown isn’t a document format — it’s a means to creating HTML, sort of like an IDE except you write in test instead of use a specific editor runtime. The beauty is being able to drop HTML into your markdown and not have the processor trip over it. &lt;aside&gt;, &lt;figure&gt; etc all because first class entities as opposed to by products of some arbitrary ascii syntax fencing, and it brought me closer to the resultant HTML that made formatting with CSS much easier (in a later, much smaller project.)<p>Print CSS is still very challenging unless you have the budget for Prince. You can do a lot if you give up hope of having everything happen automatically a la LaTeX. When you focus on the content over the formatting, these worries tend to evaporate.
评论 #29467421 未加载
AnonCover 3 years ago
This was an interesting read. Thanks for sharing the template repository too. The part about “Writing one sentence per line” made a lot of sense for the source text and for diffs being easier to handle.<p>Overall, the process of writing text and turning it into a book format like ePub and PDF seemed a lot easier with this post (of course, this post is not for books with mathematical equations and other more stringent typography and layout requirements).
lihaoyiover 3 years ago
For my book Hands on Scala, I did a totaly different approach: parsed markdown into HTML myself, used puppeteer to turn it into PDFs. I extended markdown with some macros to do the things I needed (e.g. named cross-references, two-column sections, graphviz diagram blocks, pulling in code snippets from the examples folder)<p>The build tool made it easy to import libraries like CommonMark-Java or ApachePDFBox to do what I wanted, wire in external tools like Puppeteer, and gave parallelism and incrementality for free. End result was &lt;1s turnaround on editing chapters and &lt;60s turnaround to regenerate the whole book from scratch, with the ability to spit out pdf&#x2F;epub&#x2F;web versions of the book in both 5-chapter-preview and 20-chapter-full versions. Since it&#x27;s all HTML&#x2F;CSS, and I&#x27;m a web developer, I could make it look any way I wanted.<p>The build pipeline is here, if anyone wants to take a look <a href="https:&#x2F;&#x2F;github.com&#x2F;handsonscala&#x2F;build" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;handsonscala&#x2F;build</a>. There&#x27;s a link to the main website you can download samples to see how it ends up looking
评论 #29470009 未加载
codazodaover 3 years ago
AsciiDoc looks like a cool option. I wrote mine in Libre Office Write. Then I wrote a small book with step by step instructions for how to do it.<p>Here’s the book. It’s available on Kindle Unlimited if you have that.<p><a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B00A4112ZM" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B00A4112ZM</a>
invalidnameover 3 years ago
This is another book with Asciidoc that takes things a bit further: <a href="https:&#x2F;&#x2F;medium.com&#x2F;sketch-app-sources&#x2F;using-sketch-and-asciidoc-to-generate-a-professional-tech-book-ef5b5d8dd410" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;sketch-app-sources&#x2F;using-sketch-and-ascii...</a>
ambivalentsover 3 years ago
This is awesome. You have successfully made writing a book look like fun (although I know it’s actually very hard). Now I just need something to write about.
Blammarover 3 years ago
This is arguably within the context of &quot;how to write books&quot; -- what did you do to draw illustrations and figures? (I&#x27;ve taken a look at Inkscape. What I want to do is have line drawings of crystallographic shapes, so a constraint-based illustrator would be ideal. I&#x27;ve never understood why the ideas behind Ivan Sutherland&#x27;s Sketchbook have never seemed to make it into existing drawing packages.)
andaiover 3 years ago
Thanks for this article, I will come back to it in the future. By the way, the link to the Spell Right extension actually links to the AsciiDoc extension.
评论 #29470334 未加载
dadarecitover 3 years ago
This is an interesting approach to self promotion.<p>Instead of outright saying “I wrote a book, you should buy it!”, you generate some form of meta-content revolving around your book, that ideally fits the kind of content that would be appreciated by the people on whatever platform you’re doing the promotion on.<p>Admittedly this ain’t exactly rocket science and in this specific case the actual agenda is so obvious as to make ones eye roll but it does make you wonder about other more subtle techniques being applied.<p>And very quickly this can lead to a form of existential crisis where you wonder if anything you see, even say on hn, has any actual value or maybe its all just people finding ways to hijack and abuse basic human neural mechanisms in order to generate revenue off of others.<p>And then you wonder, what does that make them? If these people and what they do are solely defined by what others find “interesting”, or by what can be profitable - what does that mean about who they are? Like, they are essentially non-entities, with no real human substance to them: they are the descriptions of our worst tendencies and reflections of economic mechanisms. I think this is called “soulless”.<p>Maybe I should write a post about how I wrote this post. Like subscribe and leave a comment :)
评论 #29469139 未加载