skerkour / black-hat-rust

Applied offensive security with Rust - https://kerkour.com/black-hat-rust

Home Page:https://kerkour.com/black-hat-rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code block styling in .epub version

chrisboyce opened this issue · comments

While the pdf and mobi formats show the code blocks in fixed-width font, it seems that the epub version does not (at least in calibre 3.21).

image

Thank you for the feedback!
It's for sure a bug and not a feature and thus need to be fixed.

Do you have any idea about the root cause?

After poking at the source for a bit, I realized that the font it was using for code blocks (Courier New) was not a font I had installed locally. After installing it, the code blocks are showing up correctly. I'm not sure how much control you have over the content that's generated, but if the styling can be changed from

.c0 {
    color: #000000;
    font-weight: 400;
    text-decoration: none;
    vertical-align: baseline;
    font-size: 11pt;
    font-family: "Courier New";
    font-style: normal;
}

to

.c0 {
    color: #000000;
    font-weight: 400;
    text-decoration: none;
    vertical-align: baseline;
    font-size: 11pt;
    font-family: "Courier New", monospace; /* <---- added "monospace" fallback */
    font-style: normal;
}

then the ebook viewer should fall back on whichever monospace fonts they have locally if the named font isn't found.

Thank you very much for this extremely detailed report!
I'm currently working on it and it should be fixed by tomorrow.

Update:
I have hard time fixing it with Google Docs so I'm currently trying other publishing software.

Update:
Due to Google Docs awfulness I'm moving away from it to Markdown + pandoc. It will take some time but according to my tests it will solve the issue.

Fixed thanks to pandoc.

The output is not perfect yet, but with some work on the theme and template it will be awesome!