1 unstable release
0.1.0 | Oct 23, 2020 |
---|
#50 in #author
Used in 3 crates
1MB
5.5K
SLoC
This crate allows the construction of an abstract book source which others can render into a particular out format.
lib.rs
:
This crate makes the building of a BookSrc
easy;
this struct can then be used to render to a specific backend
after being adapted to various options.
General usage is to create a BookSrcBuilder
, set metadata values and add content,
then create a BookSrc
from the builder.
Because books get complicated quickly, there are a lot of builder methods and toggles. Simple usage, however, is very simple.
use bookbinder_ast::BookSrcBuilder;
let src = BookSrcBuilder::new("A Book")
.subtitle("Serving as an Example")
.author("A.N. Author")
.add_mainmatter("# Hello World\n\nText goes here...")
.process();
Because we incorporate the idea of semantic divisions,
various pieces of ancillary text can be added and formatted appropriately:
see, for example, add_foreword
.
Markdown
The markdown source interpreted has a few small extensions from CommonMark:
- footnotes: add footnotes using
[^marker] ... [^marker]: definition
- formatting spans: text can be wrapped in a handful of spans to format it in various ways:
<span class="sans">Sans Text</span>
<span class="smallcaps">Small caps text</span>
<span class="centred">Centred text</span>
<span class="right-aligned">Right aligned text</span>
- escaping:
--
and---
are turned into en and em-dashes respectively, while a row of three full stops (...
) becomes an ellipsis. - quotes: straight quotes are -- at least in theory -- turned into appropriate curly quotes; this is a problem impossible to get absolutely right without actually understanding text, but the algorithm used is fairly robust and takes into account semantics (so that, for example, quotes in code are not transformed). Still, for perfect accuracy, it's best to use curly quotes explicitly.
- sub and superscript:
22^nd^ July
,H~2~0
;
Dependencies
~17MB
~293K SLoC