Leanpub produces the book starting from Markdown/Markua files. Markua is a dialect/fork of Markdown that implements book-related features like footnotes. So I just wrote it with an editor. You can find the source code of the book here https://github.com/pycabook/pycabook. Thank you for reading the book