How it Works
mkbook generates a completely static, javascript-free website from a series of Markdown files. All of the layout and styling is controlled purely by hand-crafted CSS specific to this book’s purpose.
Assets
mkbook currently bundles two assets which get written into the book directory: favicon.ico
, and icons.svg
. favicon.ico
is the Font Awesome 5 book icon, and icons.svg
contains 3 Font Awesome 5 arrow icons: arrow-left, arrow-right, and arrow-up which are used for navigation. These files are compiled into the mkbook binary using the include_bytes!
macro, and written to the output folder on each build.
Styling
mkbook utilizes Sass to define it’s styles; you can view the sources on github. In mkbook’s build script, the styles are compiled from their native .scss
format into a single, compressed .css
file using sass-rs. The resulting .css
file is then bundled into the binary using the include_str!
macro. When a book is generated, this .css
is written to the output folder as style.css
, where it is included by each generated .html
file.
Templates
mkbook contains two template files: one for the index, and one for each page / chapter, and uses Askama to render the templates. Since the Askama templates are compiled when mkbook is compiled, it is not currently possible to change the templates at run time. You can view the sources for these templates on github.
Markdown Formatting
Markdown is formatted usiing comrak with some specific options, see the Markdown chapter for more information.
Syntax Highlighting
Code is syntax-highlighted using syntect with the default langauges and the base16-eighties
colour scheme. Some additional languages above the base list supported by syntect have been aded: