Commit 9e04b54
authored
Render a BITS book-part-wrapper (one NCBI Bookshelf chapter) (#10)
Europe PMC serves a Bookshelf chapter (a GeneReviews entry, say) as BITS
Book Interchange XML: a <book-part-wrapper> holding <book-meta> and one
unit of the book, normally a <book-part> whose <book-part-meta> carries
the chapter's title and abstracts and whose <body>/<back> share the JATS
Archiving content model. convert() dispatches that root to
jats.render_book_part_wrapper, which renders the part's labelled title
and subtitles as the H1 and each abstract through render_abstract in
place of an article's <front>, then hands the body and back to the
article code path. A wrapper holding anything but a single <book-part>
(a <book-app>, a <preface>, a <book-part> beside a sibling unit, or
nothing) raises ValueError naming what it holds. Both entry points share
_render_document, so the rule separators and the split-superscript
collapse apply alike; a section that renders nothing leaves no rule.
BITS lets a part's <body> end in further <book-part>s (a Bookshelf part
whose chapters nest). render_body renders them through the same pieces,
one heading level down per nesting: every heading is built by _heading,
which clamps at Markdown's six, and render_body, render_abstract,
render_back, render_ref_list, render_fn_group, render_glossary,
render_p and render_boxed_text take the level they head at (default 2,
the article layout).
<subtitle> joins the title after a colon in an article's and a book
part's H1 alike, through one title-group helper.
Bookshelf chapters nest their <ref-list> inside a body <sec>
(References > Literature Cited), which render_sec dropped along with
every reference. JATS Archiving permits <ref-list> in <sec>, so
render_sec renders it: the enclosing section's title heads the list,
and the list's own <title> adds a heading one level down only when it
differs from the section's.
A <ref> without a <label> is numbered from its id only when the id is a
bare number or a PMC-style B-number; an opaque id (Springer's CR45,
Elsevier's bib7, Bookshelf's brca1.REF.doe.2020) leaves the citation
unlabelled behind its anchor instead of heading it with the id itself.
Bookshelf table cells carry raw newlines and indentation. inline_to_md
already flattens ASCII whitespace for every input and md_escape_cell
trims it, so no book-specific handling is needed; a test pins the
invariant for that cell shape.
Bump version to 0.6.0 and refresh uv.lock for it.1 parent 5f0102d commit 9e04b54
7 files changed
Lines changed: 614 additions & 99 deletions
File tree
- litdown
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
60 | | - | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| |||
84 | 96 | | |
85 | 97 | | |
86 | 98 | | |
87 | | - | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
| |||
98 | 110 | | |
99 | 111 | | |
100 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
101 | 122 | | |
102 | 123 | | |
103 | 124 | | |
| |||
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | 184 | | |
167 | 185 | | |
168 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
0 commit comments