docbook 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/CLAUDE.md +19 -0
  4. data/CODE_OF_CONDUCT.md +10 -0
  5. data/README.adoc +335 -0
  6. data/Rakefile +12 -0
  7. data/docs/.lycheeignore +33 -0
  8. data/docs/Gemfile +10 -0
  9. data/docs/INDEX.adoc +67 -0
  10. data/docs/_config.yml +186 -0
  11. data/docs/advanced/element-classes.adoc +185 -0
  12. data/docs/advanced/frontend-customization.adoc +193 -0
  13. data/docs/advanced/index.adoc +14 -0
  14. data/docs/advanced/templates.adoc +123 -0
  15. data/docs/features/element-coverage.adoc +373 -0
  16. data/docs/features/html-output/data-model.adoc +285 -0
  17. data/docs/features/html-output/directory-mode.adoc +180 -0
  18. data/docs/features/html-output/index.adoc +90 -0
  19. data/docs/features/html-output/single-file-mode.adoc +125 -0
  20. data/docs/features/index-generation.adoc +197 -0
  21. data/docs/features/index.adoc +63 -0
  22. data/docs/features/numbering.adoc +183 -0
  23. data/docs/features/toc-generation.adoc +150 -0
  24. data/docs/features/xinclude/fragid-schemes.adoc +287 -0
  25. data/docs/features/xinclude/index.adoc +119 -0
  26. data/docs/features/xinclude/text-includes.adoc +123 -0
  27. data/docs/features/xinclude/xml-includes.adoc +167 -0
  28. data/docs/getting-started/index.adoc +50 -0
  29. data/docs/getting-started/installation.adoc +113 -0
  30. data/docs/getting-started/quick-start.adoc +161 -0
  31. data/docs/guides/converting-article.adoc +188 -0
  32. data/docs/guides/converting-book.adoc +192 -0
  33. data/docs/guides/index.adoc +12 -0
  34. data/docs/guides/roundtrip-testing.adoc +129 -0
  35. data/docs/interfaces/cli/format-command.adoc +109 -0
  36. data/docs/interfaces/cli/index.adoc +73 -0
  37. data/docs/interfaces/cli/roundtrip-command.adoc +125 -0
  38. data/docs/interfaces/cli/to-html-command.adoc +178 -0
  39. data/docs/interfaces/cli/validate-command.adoc +104 -0
  40. data/docs/interfaces/index.adoc +101 -0
  41. data/docs/interfaces/ruby-api/html-output.adoc +186 -0
  42. data/docs/interfaces/ruby-api/index.adoc +111 -0
  43. data/docs/interfaces/ruby-api/parsing.adoc +202 -0
  44. data/docs/interfaces/ruby-api/xinclude.adoc +162 -0
  45. data/docs/interfaces/ruby-api/xref-resolution.adoc +156 -0
  46. data/docs/lychee.toml +42 -0
  47. data/docs/reference/cli-options.adoc +155 -0
  48. data/docs/reference/content-block-types.adoc +243 -0
  49. data/docs/reference/glossary.adoc +119 -0
  50. data/docs/reference/index.adoc +12 -0
  51. data/docs/reference/supported-elements.adoc +749 -0
  52. data/docs/understanding/architecture.adoc +145 -0
  53. data/docs/understanding/content-pipeline.adoc +102 -0
  54. data/docs/understanding/data-models.adoc +156 -0
  55. data/docs/understanding/index.adoc +34 -0
  56. data/exe/docbook +7 -0
  57. data/frontend/dist/app.css +1 -0
  58. data/frontend/dist/app.iife.js +24 -0
  59. data/frontend/package-lock.json +1445 -0
  60. data/frontend/package.json +22 -0
  61. data/frontend/src/App.vue +230 -0
  62. data/frontend/src/app.ts +8 -0
  63. data/frontend/src/components/AppSidebar.vue +116 -0
  64. data/frontend/src/components/AppendixSection.vue +39 -0
  65. data/frontend/src/components/BlockRenderer.vue +358 -0
  66. data/frontend/src/components/ChapterSection.vue +32 -0
  67. data/frontend/src/components/ContentRenderer.vue +13 -0
  68. data/frontend/src/components/EbookContainer.vue +147 -0
  69. data/frontend/src/components/EbookTopBar.vue +116 -0
  70. data/frontend/src/components/PartSection.vue +44 -0
  71. data/frontend/src/components/ReferenceEntry.vue +80 -0
  72. data/frontend/src/components/SearchModal.vue +286 -0
  73. data/frontend/src/components/SectionContent.vue +31 -0
  74. data/frontend/src/components/SettingsPanel.vue +236 -0
  75. data/frontend/src/components/TocTreeItem.vue +135 -0
  76. data/frontend/src/composables/useEbookStore.ts +191 -0
  77. data/frontend/src/composables/useSearch.ts +249 -0
  78. data/frontend/src/env.d.ts +7 -0
  79. data/frontend/src/stores/documentStore.ts +221 -0
  80. data/frontend/src/stores/uiStore.ts +98 -0
  81. data/frontend/src/styles.css +253 -0
  82. data/frontend/tsconfig.json +24 -0
  83. data/frontend/tsconfig.node.json +11 -0
  84. data/frontend/vite.config.ts +30 -0
  85. data/lib/docbook/cli.rb +123 -0
  86. data/lib/docbook/document.rb +67 -0
  87. data/lib/docbook/elements/abbrev.rb +16 -0
  88. data/lib/docbook/elements/acknowledgements.rb +22 -0
  89. data/lib/docbook/elements/address.rb +18 -0
  90. data/lib/docbook/elements/alt.rb +16 -0
  91. data/lib/docbook/elements/annotation.rb +18 -0
  92. data/lib/docbook/elements/appendix.rb +34 -0
  93. data/lib/docbook/elements/article.rb +31 -0
  94. data/lib/docbook/elements/att.rb +15 -0
  95. data/lib/docbook/elements/attribution.rb +20 -0
  96. data/lib/docbook/elements/audioobject.rb +18 -0
  97. data/lib/docbook/elements/author.rb +18 -0
  98. data/lib/docbook/elements/bibliography.rb +24 -0
  99. data/lib/docbook/elements/bibliomixed.rb +40 -0
  100. data/lib/docbook/elements/biblioref.rb +20 -0
  101. data/lib/docbook/elements/blockquote.rb +26 -0
  102. data/lib/docbook/elements/book.rb +36 -0
  103. data/lib/docbook/elements/buildtarget.rb +16 -0
  104. data/lib/docbook/elements/callout.rb +22 -0
  105. data/lib/docbook/elements/calloutlist.rb +22 -0
  106. data/lib/docbook/elements/caution.rb +30 -0
  107. data/lib/docbook/elements/chapter.rb +62 -0
  108. data/lib/docbook/elements/citation.rb +16 -0
  109. data/lib/docbook/elements/citerefentry.rb +26 -0
  110. data/lib/docbook/elements/citetitle.rb +20 -0
  111. data/lib/docbook/elements/classname.rb +16 -0
  112. data/lib/docbook/elements/code.rb +16 -0
  113. data/lib/docbook/elements/colophon.rb +22 -0
  114. data/lib/docbook/elements/computeroutput.rb +18 -0
  115. data/lib/docbook/elements/copyright.rb +17 -0
  116. data/lib/docbook/elements/danger.rb +28 -0
  117. data/lib/docbook/elements/date.rb +16 -0
  118. data/lib/docbook/elements/dedication.rb +22 -0
  119. data/lib/docbook/elements/dir.rb +16 -0
  120. data/lib/docbook/elements/emphasis.rb +18 -0
  121. data/lib/docbook/elements/entry.rb +30 -0
  122. data/lib/docbook/elements/entrytbl.rb +22 -0
  123. data/lib/docbook/elements/equation.rb +26 -0
  124. data/lib/docbook/elements/example.rb +30 -0
  125. data/lib/docbook/elements/fieldsynopsis.rb +21 -0
  126. data/lib/docbook/elements/figure.rb +28 -0
  127. data/lib/docbook/elements/filename.rb +16 -0
  128. data/lib/docbook/elements/firstname.rb +16 -0
  129. data/lib/docbook/elements/firstterm.rb +18 -0
  130. data/lib/docbook/elements/footnote.rb +22 -0
  131. data/lib/docbook/elements/footnoteref.rb +21 -0
  132. data/lib/docbook/elements/foreignphrase.rb +18 -0
  133. data/lib/docbook/elements/formalpara.rb +20 -0
  134. data/lib/docbook/elements/function.rb +16 -0
  135. data/lib/docbook/elements/glossary.rb +24 -0
  136. data/lib/docbook/elements/glossdef.rb +18 -0
  137. data/lib/docbook/elements/glossentry.rb +26 -0
  138. data/lib/docbook/elements/glosssee.rb +18 -0
  139. data/lib/docbook/elements/glossseealso.rb +18 -0
  140. data/lib/docbook/elements/glossterm.rb +18 -0
  141. data/lib/docbook/elements/holder.rb +16 -0
  142. data/lib/docbook/elements/honorific.rb +16 -0
  143. data/lib/docbook/elements/imagedata.rb +29 -0
  144. data/lib/docbook/elements/imageobject.rb +22 -0
  145. data/lib/docbook/elements/important.rb +30 -0
  146. data/lib/docbook/elements/index.rb +26 -0
  147. data/lib/docbook/elements/indexdiv.rb +22 -0
  148. data/lib/docbook/elements/indexentry.rb +22 -0
  149. data/lib/docbook/elements/indexterm.rb +34 -0
  150. data/lib/docbook/elements/info.rb +25 -0
  151. data/lib/docbook/elements/informalexample.rb +24 -0
  152. data/lib/docbook/elements/informalfigure.rb +20 -0
  153. data/lib/docbook/elements/inlinemediaobject.rb +22 -0
  154. data/lib/docbook/elements/itemizedlist.rb +21 -0
  155. data/lib/docbook/elements/legalnotice.rb +22 -0
  156. data/lib/docbook/elements/link.rb +26 -0
  157. data/lib/docbook/elements/listitem.rb +32 -0
  158. data/lib/docbook/elements/literal.rb +16 -0
  159. data/lib/docbook/elements/literallayout.rb +22 -0
  160. data/lib/docbook/elements/mediaobject.rb +26 -0
  161. data/lib/docbook/elements/msg.rb +20 -0
  162. data/lib/docbook/elements/msgexplan.rb +22 -0
  163. data/lib/docbook/elements/msgset.rb +22 -0
  164. data/lib/docbook/elements/note.rb +30 -0
  165. data/lib/docbook/elements/orderedlist.rb +23 -0
  166. data/lib/docbook/elements/orgname.rb +16 -0
  167. data/lib/docbook/elements/para.rb +61 -0
  168. data/lib/docbook/elements/paragraph_like.rb +18 -0
  169. data/lib/docbook/elements/parameter.rb +16 -0
  170. data/lib/docbook/elements/part.rb +38 -0
  171. data/lib/docbook/elements/personname.rb +22 -0
  172. data/lib/docbook/elements/phrase.rb +20 -0
  173. data/lib/docbook/elements/preface.rb +58 -0
  174. data/lib/docbook/elements/primary.rb +16 -0
  175. data/lib/docbook/elements/procedure.rb +24 -0
  176. data/lib/docbook/elements/productname.rb +18 -0
  177. data/lib/docbook/elements/productnumber.rb +16 -0
  178. data/lib/docbook/elements/programlisting.rb +28 -0
  179. data/lib/docbook/elements/property.rb +16 -0
  180. data/lib/docbook/elements/pubdate.rb +16 -0
  181. data/lib/docbook/elements/publishername.rb +16 -0
  182. data/lib/docbook/elements/quotation.rb +24 -0
  183. data/lib/docbook/elements/quote.rb +18 -0
  184. data/lib/docbook/elements/refentry.rb +32 -0
  185. data/lib/docbook/elements/refentrytitle.rb +16 -0
  186. data/lib/docbook/elements/reference.rb +26 -0
  187. data/lib/docbook/elements/refmeta.rb +29 -0
  188. data/lib/docbook/elements/refmiscinfo.rb +16 -0
  189. data/lib/docbook/elements/refname.rb +16 -0
  190. data/lib/docbook/elements/refnamediv.rb +22 -0
  191. data/lib/docbook/elements/refpurpose.rb +16 -0
  192. data/lib/docbook/elements/refsect1.rb +22 -0
  193. data/lib/docbook/elements/refsect2.rb +22 -0
  194. data/lib/docbook/elements/refsect3.rb +22 -0
  195. data/lib/docbook/elements/refsection.rb +32 -0
  196. data/lib/docbook/elements/releaseinfo.rb +16 -0
  197. data/lib/docbook/elements/remark.rb +20 -0
  198. data/lib/docbook/elements/replaceable.rb +16 -0
  199. data/lib/docbook/elements/row.rb +15 -0
  200. data/lib/docbook/elements/screen.rb +28 -0
  201. data/lib/docbook/elements/secondary.rb +16 -0
  202. data/lib/docbook/elements/sect1.rb +26 -0
  203. data/lib/docbook/elements/sect2.rb +24 -0
  204. data/lib/docbook/elements/sect3.rb +24 -0
  205. data/lib/docbook/elements/sect4.rb +24 -0
  206. data/lib/docbook/elements/sect5.rb +22 -0
  207. data/lib/docbook/elements/section.rb +66 -0
  208. data/lib/docbook/elements/see.rb +16 -0
  209. data/lib/docbook/elements/seealso.rb +18 -0
  210. data/lib/docbook/elements/set.rb +26 -0
  211. data/lib/docbook/elements/setindex.rb +24 -0
  212. data/lib/docbook/elements/sidebar.rb +22 -0
  213. data/lib/docbook/elements/simplesect.rb +32 -0
  214. data/lib/docbook/elements/step.rb +26 -0
  215. data/lib/docbook/elements/substeps.rb +18 -0
  216. data/lib/docbook/elements/subtitle.rb +16 -0
  217. data/lib/docbook/elements/surname.rb +16 -0
  218. data/lib/docbook/elements/table.rb +24 -0
  219. data/lib/docbook/elements/tag.rb +20 -0
  220. data/lib/docbook/elements/tbody.rb +15 -0
  221. data/lib/docbook/elements/term.rb +37 -0
  222. data/lib/docbook/elements/tertiary.rb +16 -0
  223. data/lib/docbook/elements/textobject.rb +18 -0
  224. data/lib/docbook/elements/tfoot.rb +15 -0
  225. data/lib/docbook/elements/tgroup.rb +21 -0
  226. data/lib/docbook/elements/thead.rb +15 -0
  227. data/lib/docbook/elements/tip.rb +30 -0
  228. data/lib/docbook/elements/title.rb +16 -0
  229. data/lib/docbook/elements/toc.rb +24 -0
  230. data/lib/docbook/elements/tocdiv.rb +22 -0
  231. data/lib/docbook/elements/tocentry.rb +20 -0
  232. data/lib/docbook/elements/topic.rb +26 -0
  233. data/lib/docbook/elements/type.rb +16 -0
  234. data/lib/docbook/elements/uri.rb +16 -0
  235. data/lib/docbook/elements/userinput.rb +18 -0
  236. data/lib/docbook/elements/variable.rb +16 -0
  237. data/lib/docbook/elements/variablelist.rb +19 -0
  238. data/lib/docbook/elements/varlistentry.rb +17 -0
  239. data/lib/docbook/elements/version.rb +16 -0
  240. data/lib/docbook/elements/videoobject.rb +18 -0
  241. data/lib/docbook/elements/warning.rb +30 -0
  242. data/lib/docbook/elements/xref.rb +18 -0
  243. data/lib/docbook/elements/year.rb +16 -0
  244. data/lib/docbook/elements.rb +204 -0
  245. data/lib/docbook/models/document_metadata.rb +30 -0
  246. data/lib/docbook/models/document_root.rb +33 -0
  247. data/lib/docbook/models/index_entry.rb +28 -0
  248. data/lib/docbook/models/reading_position.rb +22 -0
  249. data/lib/docbook/models/section_number.rb +18 -0
  250. data/lib/docbook/models/section_root.rb +29 -0
  251. data/lib/docbook/models/toc_node.rb +24 -0
  252. data/lib/docbook/models.rb +16 -0
  253. data/lib/docbook/output/data.rb +196 -0
  254. data/lib/docbook/output/html.rb +1450 -0
  255. data/lib/docbook/output/index_generator.rb +281 -0
  256. data/lib/docbook/output.rb +8 -0
  257. data/lib/docbook/services/document_builder.rb +258 -0
  258. data/lib/docbook/services/element_to_hash.rb +287 -0
  259. data/lib/docbook/services/index_generator.rb +134 -0
  260. data/lib/docbook/services/numbering_service.rb +186 -0
  261. data/lib/docbook/services/toc_generator.rb +138 -0
  262. data/lib/docbook/services.rb +14 -0
  263. data/lib/docbook/templates/document.html.liquid +20 -0
  264. data/lib/docbook/templates/partials/_head.liquid +39 -0
  265. data/lib/docbook/templates/partials/_scripts.liquid +10 -0
  266. data/lib/docbook/version.rb +5 -0
  267. data/lib/docbook/xinclude_resolver.rb +217 -0
  268. data/lib/docbook/xref_resolver.rb +78 -0
  269. data/lib/docbook.rb +17 -0
  270. data/sig/docbook.rbs +4 -0
  271. metadata +385 -0
@@ -0,0 +1,156 @@
1
+ ---
2
+ layout: default
3
+ title: XRef Resolution
4
+ parent: Ruby API
5
+ grand_parent: Interfaces
6
+ nav_order: 4
7
+ ---
8
+
9
+ == XRef Resolution
10
+
11
+ The `Docbook::XrefResolver` class builds an `xml:id` lookup map from a parsed DocBook document and provides methods to resolve cross-references (`xref` elements and `linkend` attributes) to their target titles.
12
+
13
+ === Why Resolve Cross-References
14
+
15
+ DocBook uses `xml:id` attributes to identify elements and `linkend` attributes on `<xref>` elements to reference them. When generating HTML, you typically want to display the target's title text rather than the raw ID. The `XrefResolver` provides an O(1) lookup for resolving these references.
16
+
17
+ === Creating a Resolver
18
+
19
+ [source,ruby]
20
+ ----
21
+ require "docbook"
22
+
23
+ # Parse the document
24
+ xml_string = File.read("book.xml")
25
+ document = Docbook::Document.from_xml(xml_string)
26
+
27
+ # Create and resolve
28
+ xref_resolver = Docbook::XrefResolver.new(document).resolve!
29
+ ----
30
+
31
+ The `resolve!` method traverses the entire document tree, collects all elements with `xml:id` attributes, and builds a hash map. It returns `self` so you can chain calls.
32
+
33
+ === Resolving Cross-Reference Titles
34
+
35
+ Use `title_for(linkend)` to look up the title text for a given `xml:id`:
36
+
37
+ [source,ruby]
38
+ ----
39
+ # Look up the title for a specific xml:id
40
+ title = xref_resolver.title_for("intro")
41
+ # => "Introduction"
42
+
43
+ title = xref_resolver.title_for("chapter-1")
44
+ # => "Getting Started"
45
+
46
+ title = xref_resolver.title_for("nonexistent-id")
47
+ # => nil (no element with this ID)
48
+ ----
49
+
50
+ This is used internally by `Docbook::Output::Html` to resolve `<xref linkend="intro"/>` into the text "Introduction" in the generated HTML.
51
+
52
+ === Retrieving Elements by ID
53
+
54
+ Use the `[]` operator to retrieve the actual element object for a given `xml:id`:
55
+
56
+ [source,ruby]
57
+ ----
58
+ # Get the element with xml:id="intro"
59
+ element = xref_resolver["intro"]
60
+ # => #<Docbook::Elements::Section:0x0000...>
61
+
62
+ element.title.content # => "Introduction"
63
+ element.xml_id # => "intro"
64
+ ----
65
+
66
+ This returns the parsed element object, giving you full access to its attributes and child elements.
67
+
68
+ === How the ID Map Works
69
+
70
+ The `resolve!` method recursively traverses the document tree, visiting each element and recording those that have an `xml:id` attribute. The traversal is type-aware -- it knows which child collections to visit for each element type:
71
+
72
+ [cols="2,5"]
73
+ |===
74
+ | Element Type | Child Collections Traversed
75
+
76
+ | `Book` | `part`, `chapter`, `appendix`, `preface`, `glossary`, `bibliography`, `index`
77
+ | `Article` | `section`
78
+ | `Part` | `chapter`, `appendix`, `reference`, `glossary`, `bibliography`, `index`
79
+ | `Chapter`, `Appendix`, `Section`, `Preface` | `section`
80
+ | `Reference` | `refentry`
81
+ |===
82
+
83
+ === Title Extraction
84
+
85
+ The resolver uses different strategies to extract titles depending on the element type:
86
+
87
+ [cols="2,5"]
88
+ |===
89
+ | Element Type | Title Source
90
+
91
+ | `Article`, `Book` | `info.title.content`
92
+ | `Section`, `Chapter`, `Appendix`, `Preface`, `Part`, `Reference` | `title.content` (or `info.title.content` as fallback)
93
+ | Other elements | `title.content` (best-effort via `rescue nil`)
94
+ |===
95
+
96
+ === Complete Example
97
+
98
+ A full workflow that parses, resolves cross-references, and generates HTML:
99
+
100
+ [source,ruby]
101
+ ----
102
+ require "docbook"
103
+
104
+ # Parse the document
105
+ xml_string = File.read("book.xml")
106
+ document = Docbook::Document.from_xml(xml_string)
107
+
108
+ # Build the cross-reference map
109
+ xref_resolver = Docbook::XrefResolver.new(document).resolve!
110
+
111
+ # Look up specific elements
112
+ chapter_element = xref_resolver["chapter-1"]
113
+ puts "Chapter 1: #{chapter_element.title.content}"
114
+ # => "Chapter 1: Getting Started"
115
+
116
+ # Resolve an xref to its target title
117
+ xref_title = xref_resolver.title_for("chapter-1")
118
+ puts "XRef target: #{xref_title}"
119
+ # => "XRef target: Getting Started"
120
+
121
+ # Now generate HTML with resolved cross-references
122
+ html = Docbook::Output::Html.new(
123
+ document,
124
+ xref_resolver: xref_resolver,
125
+ output_mode: :single_file,
126
+ base_path: File.dirname(File.expand_path("book.xml"))
127
+ ).to_html
128
+
129
+ File.write("output.html", html)
130
+ ----
131
+
132
+ === Integration with HTML Output
133
+
134
+ The `XrefResolver` is designed to work with `Docbook::Output::Html`. Pass the resolver to the HTML generator's constructor, and it will automatically resolve all `<xref>` elements:
135
+
136
+ [source,ruby]
137
+ ----
138
+ # Without xref_resolver: <xref linkend="intro"/> renders as "intro"
139
+ # With xref_resolver: <xref linkend="intro"/> renders as "Introduction"
140
+
141
+ html_with_xrefs = Docbook::Output::Html.new(
142
+ document,
143
+ xref_resolver: xref_resolver,
144
+ output_mode: :single_file
145
+ ).to_html
146
+ ----
147
+
148
+ === Element Lookup Fallback
149
+
150
+ When the `XrefResolver` cannot find an element by ID, the HTML generator falls back to a recursive document search via `find_in_document`. This provides a safety net for elements that may not be captured by the type-aware traversal (for example, deeply nested elements in unusual structures).
151
+
152
+ === See Also
153
+
154
+ * *<<parsing,Parsing Documents>>* -- Parse XML into element models before resolving xrefs
155
+ * *<<html-output,HTML Output>>* -- Use the resolver when generating HTML
156
+ * *<<xinclude,XInclude Resolution>>* -- Resolve XIncludes before parsing (so included elements get their IDs registered)
data/docs/lychee.toml ADDED
@@ -0,0 +1,42 @@
1
+ # Lychee Link Checker Configuration
2
+ # For Metanorma DocBook Documentation
3
+
4
+ cache = true
5
+ max_cache_age = "1d"
6
+ include_verbatim = true
7
+
8
+ include = [
9
+ "_site/**/*.html",
10
+ ".*\\.adoc$",
11
+ ".*\\.md$"
12
+ ]
13
+
14
+ exclude = [
15
+ ".git",
16
+ ".github",
17
+ "node_modules",
18
+ "vendor",
19
+ ".bundle",
20
+ ".sass-cache",
21
+ ".jekyll-cache",
22
+ "_site/.jekyll-cache",
23
+ "Gemfile.lock"
24
+ ]
25
+
26
+ max_redirects = 10
27
+ max_retries = 3
28
+ timeout = 30
29
+
30
+ accept = [
31
+ "100..=103",
32
+ "200..=299",
33
+ "429"
34
+ ]
35
+
36
+ user_agent = "lychee/docbook-docs-link-checker"
37
+ scheme = ["https", "http", "file"]
38
+ include_mail = false
39
+ max_concurrency = 10
40
+ verbose = "warn"
41
+ require_https = false
42
+ index_files = ["index.html"]
@@ -0,0 +1,155 @@
1
+ ---
2
+ layout: default
3
+ title: CLI Options
4
+ parent: Reference
5
+ nav_order: 1
6
+ ---
7
+
8
+ # CLI Options
9
+
10
+ The `docbook` command-line tool is built on Thor. It provides four
11
+ commands: `format`, `validate`, `to-html`, and `roundtrip`.
12
+
13
+ == Global behavior
14
+
15
+ * The executable is `docbook` (installed to `exe/`).
16
+ * All commands that accept `INPUT` take a file path argument.
17
+ * The tool exits with code 0 on success and code 1 on failure.
18
+ * Error messages are written to stderr.
19
+
20
+ == format
21
+
22
+ Formats and prettifies a DocBook XML file.
23
+
24
+ ....
25
+ docbook format INPUT [options]
26
+ ....
27
+
28
+ [cols="1,1,1,1,3"]
29
+ |===
30
+ | Option | Alias | Default | Description
31
+
32
+ | `--output PATH`
33
+ | `-o`
34
+ | stdout
35
+ | Output file path. When omitted, the formatted XML is written to
36
+ standard output.
37
+
38
+ | `--xinclude`
39
+ | _(none)_
40
+ | `false`
41
+ | Resolve XInclude directives before formatting.
42
+ |===
43
+
44
+ The command parses the input XML, then re-serializes it with pretty
45
+ printing (indentation) and an XML declaration with UTF-8 encoding.
46
+
47
+ == validate
48
+
49
+ Checks whether a DocBook XML file is well-formed.
50
+
51
+ ....
52
+ docbook validate INPUT
53
+ ....
54
+
55
+ This command has no options. It reads the file, parses it with
56
+ Nokogiri, and checks for parse errors. If the document is well-formed,
57
+ it prints `INPUT: valid`. If errors are found, each error is printed
58
+ to stderr and the command exits with code 1.
59
+
60
+ Note: this validates XML well-formedness only, not DocBook schema
61
+ conformance.
62
+
63
+ == to-html
64
+
65
+ Converts a DocBook XML file to an interactive HTML page.
66
+
67
+ ....
68
+ docbook to-html INPUT [options]
69
+ ....
70
+
71
+ [cols="1,1,1,1,3"]
72
+ |===
73
+ | Option | Alias | Default | Description
74
+
75
+ | `--output PATH`
76
+ | `-o`
77
+ | stdout
78
+ | Output file path (single-file mode) or output directory path
79
+ (directory mode).
80
+
81
+ | `--xinclude`
82
+ | _(none)_
83
+ | `true`
84
+ | Resolve XInclude directives before processing. Enabled by default
85
+ for the `to-html` command.
86
+
87
+ | `--output-type TYPE`
88
+ | _(none)_
89
+ | `single_file`
90
+ | Output type: `single_file` or `directory`. In single-file mode,
91
+ all data is inlined into one HTML file. In directory mode, JSON
92
+ data and assets are written as separate files.
93
+ |===
94
+
95
+ === Single-file mode
96
+
97
+ ....
98
+ docbook to-html book.xml -o output.html
99
+ ...
100
+
101
+ Produces a single `output.html` file with all JSON data, CSS, and
102
+ JavaScript embedded inline. The file can be opened directly in a
103
+ browser without a web server.
104
+
105
+ === Directory mode
106
+
107
+ ....
108
+ docbook to-html book.xml -o my-book --output-type directory
109
+ ....
110
+
111
+ Creates a `my-book/` directory containing:
112
+
113
+ * `index.html` -- HTML shell with Vue SPA mount point
114
+ * `docbook.data.json` -- Full document data as JSON
115
+ * `assets/app.css` -- Compiled stylesheet
116
+ * `assets/app.iife.js` -- Bundled JavaScript
117
+
118
+ The directory mode requires the `--output` option.
119
+
120
+ == roundtrip
121
+
122
+ Tests that DocBook XML files can be parsed and re-serialized
123
+ successfully.
124
+
125
+ ....
126
+ docbook roundtrip INPUT [INPUT...]
127
+ ....
128
+
129
+ This command has no options. It accepts one or more file paths. For
130
+ each file, it parses the XML, serializes it back, re-parses the output,
131
+ and reports success or failure. At the end, it prints a summary of
132
+ total files and failure count.
133
+
134
+ == Quick reference table
135
+
136
+ [cols="1,1,1"]
137
+ |===
138
+ | Command | Input | Output
139
+
140
+ | `format`
141
+ | File path
142
+ | Pretty-printed XML (file or stdout)
143
+
144
+ | `validate`
145
+ | File path
146
+ | Pass/fail status
147
+
148
+ | `to-html`
149
+ | File path
150
+ | HTML file or directory
151
+
152
+ | `roundtrip`
153
+ | One or more file paths
154
+ | Pass/fail status per file
155
+ |===
@@ -0,0 +1,243 @@
1
+ ---
2
+ layout: default
3
+ title: Content Block Types
4
+ parent: Reference
5
+ nav_order: 3
6
+ ---
7
+
8
+ # Content Block Types
9
+
10
+ The HTML generator produces structured content using `ContentBlock`
11
+ instances. Each block has a `type` field that determines how the Vue
12
+ SPA renders it. This page lists all block types used in the system.
13
+
14
+ == Block-level types
15
+
16
+ These types represent top-level content blocks within a section.
17
+
18
+ [cols="1,3"]
19
+ |===
20
+ | Type | Description
21
+
22
+ | `paragraph`
23
+ | A paragraph of text, potentially containing inline child blocks.
24
+
25
+ | `code`
26
+ | A code listing. The `language` attribute specifies the language for
27
+ syntax highlighting. The `text` attribute holds the source code.
28
+
29
+ | `image`
30
+ | An image block. The `src` attribute holds the image URL (either a
31
+ file path or a base64 data URI). The `alt` attribute provides
32
+ alternative text. The `title` attribute provides an optional caption.
33
+
34
+ | `blockquote`
35
+ | A block quotation. The `text` attribute holds the attribution.
36
+ Children contain the quoted paragraphs.
37
+
38
+ | `ordered_list`
39
+ | A numbered list. Children are `list_item` blocks.
40
+
41
+ | `itemized_list`
42
+ | A bulleted list. Children are `list_item` blocks.
43
+
44
+ | `list_item`
45
+ | A single list item. Children contain the item's content blocks.
46
+
47
+ | `definition_list`
48
+ | A definition list (variable list in DocBook). Children alternate
49
+ between `definition_term` and `definition_description` blocks.
50
+
51
+ | `definition_term`
52
+ | The term being defined. Children contain inline content.
53
+
54
+ | `definition_description`
55
+ | The definition body. Children contain block-level content.
56
+
57
+ | `note`
58
+ | An informational note admonition. Children contain the note body.
59
+ The `text` attribute holds an optional title.
60
+
61
+ | `warning`
62
+ | A warning admonition about potential problems.
63
+
64
+ | `caution`
65
+ | A caution admonition about unexpected behavior.
66
+
67
+ | `important`
68
+ | An important information admonition.
69
+
70
+ | `tip`
71
+ | A helpful suggestion admonition.
72
+
73
+ | `danger`
74
+ | A danger admonition about risk of harm.
75
+
76
+ | `example`
77
+ | A formal example. The `text` attribute holds the example title.
78
+ Children contain the example content (code blocks, paragraphs, etc.).
79
+
80
+ | `example_output`
81
+ | An informal example output block. Children contain the content.
82
+
83
+ | `section`
84
+ | A nested section within a parent block. Children contain the
85
+ section's content blocks, typically starting with a `heading`.
86
+
87
+ | `heading`
88
+ | A section heading. The `text` attribute holds the heading text.
89
+ |===
90
+
91
+ == Inline types
92
+
93
+ These types appear as children of `paragraph` and other block-level
94
+ types. They represent inline formatting and links.
95
+
96
+ [cols="1,3"]
97
+ |===
98
+ | Type | Description
99
+
100
+ | `text`
101
+ | Plain text content.
102
+
103
+ | `strong`
104
+ | Bold text. Rendered from `<emphasis role="bold">`.
105
+
106
+ | `italic`
107
+ | Italic text. Rendered from `<emphasis role="italic">`.
108
+
109
+ | `emphasis`
110
+ | Emphasized text (default rendering from `<emphasis>` with no role).
111
+
112
+ | `codetext`
113
+ | Inline monospace code. Rendered from `<code>`, `<literal>`,
114
+ `<filename>`, `<classname>`, `<function>`, `<parameter>`, and
115
+ other technical inline elements.
116
+
117
+ | `link`
118
+ | A hyperlink. The `src` attribute holds the URL. The `text` attribute
119
+ holds the display text. Rendered from `<link>` and `<citetitle>`
120
+ with an `href` attribute.
121
+
122
+ | `biblioref`
123
+ | A bibliographic reference. The `src` attribute holds a fragment
124
+ link to the bibliography entry. Rendered from `<biblioref>`.
125
+
126
+ | `citation`
127
+ | A bibliographic citation without a link. Rendered from `<citetitle>`
128
+ without an `href`.
129
+
130
+ | `citation_link`
131
+ | A citable title with a hyperlink. Rendered from `<citetitle>` with
132
+ an `href` attribute.
133
+
134
+ | `xref`
135
+ | An internal cross-reference. The `src` attribute holds the fragment
136
+ link (`#id`). The `text` attribute holds the resolved title of the
137
+ target element. Rendered from `<xref>`.
138
+
139
+ | `inline_image`
140
+ | An inline image within text flow. The `src` attribute holds the
141
+ image URL. Rendered from `<inlinemediaobject>`.
142
+ |===
143
+
144
+ == Bibliography types
145
+
146
+ These types represent structured bibliography entries.
147
+
148
+ [cols="1,3"]
149
+ |===
150
+ | Type | Description
151
+
152
+ | `bibliography_entry`
153
+ | A single bibliography entry. Children contain the entry's parts.
154
+
155
+ | `biblio_abbrev`
156
+ | The abbreviation or citation key for the entry.
157
+
158
+ | `biblio_citetitle`
159
+ | The title of the cited work (without a link).
160
+
161
+ | `biblio_personname`
162
+ | A person's name (first + surname) from `<personname>`.
163
+
164
+ | `biblio_firstname`
165
+ | A person's first name.
166
+
167
+ | `biblio_surname`
168
+ | A person's surname.
169
+
170
+ | `biblio_orgname`
171
+ | An organization name.
172
+
173
+ | `biblio_publishername`
174
+ | A publisher's name.
175
+
176
+ | `biblio_pubdate`
177
+ | The publication date.
178
+
179
+ | `biblio_bibliosource`
180
+ | A bibliographic source reference.
181
+ |===
182
+
183
+ == Index types
184
+
185
+ These types represent the generated index content.
186
+
187
+ [cols="1,3"]
188
+ |===
189
+ | Type | Description
190
+
191
+ | `index_section`
192
+ | The top-level index section. The `text` attribute holds the index
193
+ title. Children contain `index_letter` blocks.
194
+
195
+ | `index_letter`
196
+ | A letter group in the index. The `text` attribute holds the letter.
197
+ Children contain `index_entry` blocks.
198
+
199
+ | `index_entry`
200
+ | A single index entry. Children contain the term text and
201
+ cross-references.
202
+
203
+ | `index_reference`
204
+ | A link from an index entry to the section where the term appears.
205
+ The `src` attribute holds the section fragment link. The `text`
206
+ attribute holds the section title.
207
+
208
+ | `index_see`
209
+ | A "see" cross-reference to another index term.
210
+
211
+ | `index_see_also`
212
+ | A "see also" cross-reference to a related term.
213
+ |===
214
+
215
+ == Reference entry types
216
+
217
+ These types represent `<refentry>` (man-page style) content.
218
+
219
+ [cols="1,3"]
220
+ |===
221
+ | Type | Description
222
+
223
+ | `reference_entry`
224
+ | A complete reference entry. Children contain the entry's parts.
225
+
226
+ | `reference_meta`
227
+ | Metadata for the reference entry (e.g., manual volume number).
228
+
229
+ | `reference_badge`
230
+ | A category badge (e.g., "pi" for processing instructions, "param"
231
+ for parameters). Displayed prominently at the top of the entry.
232
+
233
+ | `reference_name`
234
+ | The headword or name of the reference entry. This is the primary
235
+ identifier, derived from `<refname>` or `<refentrytitle>`.
236
+
237
+ | `reference_definition`
238
+ | The one-line definition from `<refpurpose>`.
239
+
240
+ | `description_section`
241
+ | A content section within the reference entry, corresponding to a
242
+ `<refsection>`. Children contain the section's blocks.
243
+ |===
@@ -0,0 +1,119 @@
1
+ ---
2
+ layout: default
3
+ title: Glossary
4
+ parent: Reference
5
+ nav_order: 4
6
+ ---
7
+
8
+ # Glossary
9
+
10
+ This glossary defines key terms used throughout the Metanorma DocBook
11
+ gem documentation.
12
+
13
+ DocBook 5::
14
+ An OASIS standard XML vocabulary for marking up technical documents.
15
+ DocBook 5 uses namespaces (`http://docbook.org/ns/docbook`) and
16
+ supports structural elements like books, articles, chapters, sections,
17
+ and a rich set of inline and block elements.
18
+
19
+ XInclude::
20
+ A W3C standard for including external XML or text files into an XML
21
+ document using `<xi:include>` elements. The gem's `XIncludeResolver`
22
+ handles resolution before model parsing, supporting both XML and text
23
+ parse modes.
24
+
25
+ fragid::
26
+ A fragment identifier extension used with XInclude text includes.
27
+ Supports `line=` (RFC 5147 line ranges), `char=` (character ranges),
28
+ and `search=` (pattern-based extraction) schemes for pulling specific
29
+ portions of included text files.
30
+
31
+ xml:id::
32
+ The standard XML attribute for assigning a unique identifier to an
33
+ element. In DocBook, `xml:id` values serve as anchors for
34
+ cross-references (`<xref linkend="...">`) and TOC navigation.
35
+
36
+ linkend::
37
+ An attribute used by `<xref>` and other referencing elements to point
38
+ to the `xml:id` of a target element. The `XrefResolver` builds an O(1)
39
+ lookup map from `xml:id` values to element objects for efficient
40
+ resolution.
41
+
42
+ lutaml-model::
43
+ A Ruby library (`Lutaml::Model::Serializable`) that provides a
44
+ declarative DSL for mapping between XML, JSON, and Ruby objects.
45
+ The DocBook gem uses it as the base class for all element and data
46
+ model classes, providing automatic serialization and deserialization.
47
+
48
+ ContentBlock::
49
+ A data model class (`Docbook::Output::ContentBlock`) representing a
50
+ single unit of content in the HTML output. Each block has a `type`
51
+ (paragraph, code, image, etc.), optional text content, and optional
52
+ children forming a recursive tree. The Vue SPA renders blocks
53
+ using the `BlockRenderer` component.
54
+
55
+ SectionData::
56
+ A data model class representing a section in the table of contents
57
+ tree. Each entry has an ID, title, type (part, chapter, section, etc.),
58
+ and nested children. The tree is built by the HTML generator and
59
+ serialized as part of the TOC data.
60
+
61
+ NumberingBuilder::
62
+ A stateful Ruby class that assigns section numbers using different
63
+ schemes: Roman numerals for parts (I, II, III), Arabic numerals for
64
+ chapters (1, 2, 3), hierarchical dotted numbers for sections (1.1,
65
+ 1.2.3), and uppercase letters for appendices (A, B, C).
66
+
67
+ TOC::
68
+ Table of contents. The gem generates a recursive `SectionData` tree
69
+ that represents the document's logical structure. The Vue SPA renders
70
+ this as a collapsible sidebar with expand/collapse navigation.
71
+
72
+ RefEntry::
73
+ A DocBook element type (`<refentry>`) used for man-page style reference
74
+ documentation. It contains a `refmeta` (metadata), `refnamediv` (name
75
+ and purpose), and `refsection` elements (description content). The gem
76
+ renders RefEntry with specialized content block types.
77
+
78
+ mixed content::
79
+ An XML concept where an element can contain both text nodes and child
80
+ elements interspersed. For example, `<para>Hello <emphasis>world</emphasis>
81
+ !</para>` has mixed content. The lutaml-model `mixed_content` declaration
82
+ and `each_mixed_content` method handle traversal of these nodes in
83
+ document order.
84
+
85
+ Vue SPA::
86
+ A Vue 3 single-page application embedded in the generated HTML. It
87
+ provides an interactive ebook reader with a table of contents sidebar,
88
+ search, theme switching, and reading mode selection. The SPA reads
89
+ document data from inline JSON or an external JSON file.
90
+
91
+ single file mode::
92
+ An output mode where all document data, CSS, and JavaScript are
93
+ embedded into a single HTML file. The resulting file is self-contained
94
+ and can be opened directly in a browser without a web server. JSON data
95
+ is stored in `window.DOCBOOK_DATA`.
96
+
97
+ directory mode::
98
+ An output mode where the HTML, JSON data, and assets are written as
99
+ separate files in an output directory. The HTML file loads CSS and JS
100
+ from `assets/` and fetches document data from `docbook.data.json` at
101
+ runtime. Requires a web server or local file access.
102
+
103
+ Liquid template::
104
+ The template engine (Liquid) used to generate the HTML shell. Templates
105
+ are stored in `lib/docbook/templates/` and use partials for the document
106
+ head and scripts. Template variables control asset inlining, and
107
+ placeholder tokens are replaced with JSON data after rendering.
108
+
109
+ FlexSearch::
110
+ A JavaScript full-text search library used in the Vue SPA for
111
+ client-side search. The search index is built over TOC titles and
112
+ persisted in IndexedDB to avoid rebuilding on each page load. The
113
+ `useSearch` composable manages the search lifecycle.
114
+
115
+ Prism.js::
116
+ A lightweight syntax highlighting library loaded from cdnjs. It
117
+ provides language-aware code highlighting for `<programlisting>`
118
+ blocks based on the `language` attribute. The autoloader plugin
119
+ loads additional language grammars on demand.