blitz-pdf 0.1.0 → 0.1.2

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 (114) hide show
  1. package/README.md +300 -10
  2. package/THIRD_PARTY_NOTICES.md +4 -2
  3. package/dist/browser.d.ts +1 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/document-options.d.ts +36 -0
  6. package/dist/document-options.d.ts.map +1 -0
  7. package/dist/document-options.js +236 -0
  8. package/dist/document-options.js.map +1 -0
  9. package/dist/node.d.ts +1 -1
  10. package/dist/node.d.ts.map +1 -1
  11. package/dist/options.d.ts +35 -1
  12. package/dist/options.d.ts.map +1 -1
  13. package/dist/options.js +21 -14
  14. package/dist/options.js.map +1 -1
  15. package/dist/types.d.ts +71 -1
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/validation.d.ts +2 -0
  18. package/dist/validation.d.ts.map +1 -0
  19. package/dist/validation.js +7 -0
  20. package/dist/validation.js.map +1 -0
  21. package/examples/zugferd.mjs +41 -0
  22. package/licenses/RUST_DEPENDENCIES.txt +27 -0
  23. package/package.json +3 -2
  24. package/src/browser.ts +1 -1
  25. package/src/document-options.ts +218 -0
  26. package/src/node.ts +1 -1
  27. package/src/options.ts +18 -13
  28. package/src/types.ts +76 -1
  29. package/src/validation.ts +6 -0
  30. package/vendor/README.md +27 -2
  31. package/vendor/krilla/.cargo-ok +1 -0
  32. package/vendor/krilla/.cargo_vcs_info.json +6 -0
  33. package/vendor/krilla/Cargo.lock +1357 -0
  34. package/vendor/krilla/Cargo.toml +165 -0
  35. package/vendor/krilla/LICENSE_APACHE +202 -0
  36. package/vendor/krilla/LICENSE_MIT +21 -0
  37. package/vendor/krilla/README.md +156 -0
  38. package/vendor/krilla/examples/basic.rs +117 -0
  39. package/vendor/krilla/examples/empty_document.rs +25 -0
  40. package/vendor/krilla/examples/parley.rs +174 -0
  41. package/vendor/krilla/examples/simple_text.rs +118 -0
  42. package/vendor/krilla/examples/stream_builder.rs +93 -0
  43. package/vendor/krilla/icc/LICENSE +116 -0
  44. package/vendor/krilla/icc/README.md +1 -0
  45. package/vendor/krilla/icc/sGrey-v2-magic.icc +0 -0
  46. package/vendor/krilla/icc/sGrey-v4.icc +0 -0
  47. package/vendor/krilla/icc/sRGB-v2-magic.icc +0 -0
  48. package/vendor/krilla/icc/sRGB-v4.icc +0 -0
  49. package/vendor/krilla/src/chunk_container.rs +503 -0
  50. package/vendor/krilla/src/configure/PDF_A1.md +227 -0
  51. package/vendor/krilla/src/configure/PDF_A2.md +269 -0
  52. package/vendor/krilla/src/configure/PDF_A3.md +31 -0
  53. package/vendor/krilla/src/configure/PDF_A4.md +211 -0
  54. package/vendor/krilla/src/configure/PDF_UA1.md +202 -0
  55. package/vendor/krilla/src/configure/README.md +23 -0
  56. package/vendor/krilla/src/configure/mod.rs +197 -0
  57. package/vendor/krilla/src/configure/validate.rs +1244 -0
  58. package/vendor/krilla/src/configure/version.rs +134 -0
  59. package/vendor/krilla/src/content.rs +1352 -0
  60. package/vendor/krilla/src/data.rs +49 -0
  61. package/vendor/krilla/src/document.rs +156 -0
  62. package/vendor/krilla/src/error.rs +170 -0
  63. package/vendor/krilla/src/geom.rs +341 -0
  64. package/vendor/krilla/src/graphics/blend.rs +46 -0
  65. package/vendor/krilla/src/graphics/color.rs +552 -0
  66. package/vendor/krilla/src/graphics/graphic.rs +30 -0
  67. package/vendor/krilla/src/graphics/graphics_state.rs +251 -0
  68. package/vendor/krilla/src/graphics/icc.rs +218 -0
  69. package/vendor/krilla/src/graphics/image.rs +835 -0
  70. package/vendor/krilla/src/graphics/mask.rs +128 -0
  71. package/vendor/krilla/src/graphics/mod.rs +14 -0
  72. package/vendor/krilla/src/graphics/paint.rs +434 -0
  73. package/vendor/krilla/src/graphics/separation.rs +86 -0
  74. package/vendor/krilla/src/graphics/shading_function.rs +865 -0
  75. package/vendor/krilla/src/graphics/shading_pattern.rs +60 -0
  76. package/vendor/krilla/src/graphics/tiling_pattern.rs +119 -0
  77. package/vendor/krilla/src/graphics/xobject.rs +150 -0
  78. package/vendor/krilla/src/interactive/action.rs +68 -0
  79. package/vendor/krilla/src/interactive/annotation.rs +283 -0
  80. package/vendor/krilla/src/interactive/destination.rs +289 -0
  81. package/vendor/krilla/src/interactive/mod.rs +3 -0
  82. package/vendor/krilla/src/interchange/embed.rs +240 -0
  83. package/vendor/krilla/src/interchange/metadata.rs +564 -0
  84. package/vendor/krilla/src/interchange/mod.rs +4 -0
  85. package/vendor/krilla/src/interchange/outline.rs +263 -0
  86. package/vendor/krilla/src/interchange/tagging/fmt.rs +733 -0
  87. package/vendor/krilla/src/interchange/tagging/generate.toml +474 -0
  88. package/vendor/krilla/src/interchange/tagging/generated.rs +4754 -0
  89. package/vendor/krilla/src/interchange/tagging/mod.rs +1324 -0
  90. package/vendor/krilla/src/interchange/tagging/tag.rs +686 -0
  91. package/vendor/krilla/src/lib.rs +179 -0
  92. package/vendor/krilla/src/num.rs +26 -0
  93. package/vendor/krilla/src/page.rs +612 -0
  94. package/vendor/krilla/src/pdf.rs +313 -0
  95. package/vendor/krilla/src/resource.rs +436 -0
  96. package/vendor/krilla/src/serialize.rs +1101 -0
  97. package/vendor/krilla/src/stream.rs +368 -0
  98. package/vendor/krilla/src/surface.rs +664 -0
  99. package/vendor/krilla/src/text/cid.rs +488 -0
  100. package/vendor/krilla/src/text/font.rs +351 -0
  101. package/vendor/krilla/src/text/glyph/bitmap.rs +81 -0
  102. package/vendor/krilla/src/text/glyph/colr.rs +581 -0
  103. package/vendor/krilla/src/text/glyph/mod.rs +205 -0
  104. package/vendor/krilla/src/text/glyph/outline.rs +72 -0
  105. package/vendor/krilla/src/text/glyph/svg.rs +34 -0
  106. package/vendor/krilla/src/text/group.rs +463 -0
  107. package/vendor/krilla/src/text/mod.rs +232 -0
  108. package/vendor/krilla/src/text/shape.rs +102 -0
  109. package/vendor/krilla/src/text/type3.rs +514 -0
  110. package/vendor/krilla/src/util.rs +286 -0
  111. package/vendor/stylo/properties/longhands.toml +0 -1
  112. package/vendor/stylo/stylesheets/rule_parser.rs +1 -1
  113. package/wasm/blitz_pdf.js +10 -5
  114. package/wasm/blitz_pdf_bg.wasm +0 -0
@@ -0,0 +1,4754 @@
1
+ // This file is automatically generated!
2
+ //
3
+ // To update it:
4
+ // 1. Edit the `generate.toml` file inside of this directory
5
+ // 2. Run `cargo run --bin=codegen` from the repository root
6
+
7
+ /// A tag for group nodes.
8
+ #[derive(Clone, Debug, PartialEq)]
9
+ pub enum TagKind {
10
+ /// A part of a document that may contain multiple articles or sections.
11
+ Part(Tag<kind::Part>),
12
+ /// An article with largely self-contained content.
13
+ Article(Tag<kind::Article>),
14
+ /// Section of a larger document.
15
+ Section(Tag<kind::Section>),
16
+ /// A generic block-level grouping element.
17
+ Div(Tag<kind::Div>),
18
+ /// A paragraph-level quote.
19
+ BlockQuote(Tag<kind::BlockQuote>),
20
+ /// An image or figure caption.
21
+ ///
22
+ /// **Best Practice**: In the tag tree, this should appear
23
+ /// as a sibling after the image (or other) content it describes.
24
+ Caption(Tag<kind::Caption>),
25
+ /// Table of contents.
26
+ ///
27
+ /// **Best Practice**: Should consist of TOCIs or other nested TOCs.
28
+ TOC(Tag<kind::TOC>),
29
+ /// Item in the table of contents.
30
+ ///
31
+ /// **Best Practice**: Should only appear within a TOC. Should only consist of
32
+ /// labels, references, paragraphs and TOCs.
33
+ TOCI(Tag<kind::TOCI>),
34
+ /// Index of the key terms in the document.
35
+ ///
36
+ /// **Best Practice**: Should contain a sequence of text accompanied by
37
+ /// reference elements pointing to their occurrence in the text.
38
+ Index(Tag<kind::Index>),
39
+ /// A paragraph.
40
+ P(Tag<kind::P>),
41
+ /// Heading level `n`, including an optional title of the heading.
42
+ ///
43
+ /// The title is required for some export modes, like for example PDF/UA.
44
+ Hn(Tag<kind::Hn>),
45
+ /// A list.
46
+ ///
47
+ /// **Best practice**: Should consist of an optional caption followed by
48
+ /// list items.
49
+ /// List numbering is only required for PDF/UA, but we just enforce it for always.
50
+ L(Tag<kind::L>),
51
+ /// A list item.
52
+ ///
53
+ /// **Best practice**: Should consist of one or more list labels and/or list bodies.
54
+ LI(Tag<kind::LI>),
55
+ /// Label for a list item.
56
+ Lbl(Tag<kind::Lbl>),
57
+ /// Description of the list item.
58
+ LBody(Tag<kind::LBody>),
59
+ /// A table, with an optional summary describing the purpose and structure.
60
+ ///
61
+ /// **Best practice**: Should consist of an optional table header row,
62
+ /// one or more table body elements and an optional table footer. Can have
63
+ /// caption as the first or last child.
64
+ Table(Tag<kind::Table>),
65
+ /// A table row.
66
+ ///
67
+ /// **Best practice**: May contain table headers cells and table data cells.
68
+ TR(Tag<kind::TR>),
69
+ /// A table header cell.
70
+ TH(Tag<kind::TH>),
71
+ /// A table data cell.
72
+ TD(Tag<kind::TD>),
73
+ /// A table header row group.
74
+ THead(Tag<kind::THead>),
75
+ /// A table data row group.
76
+ TBody(Tag<kind::TBody>),
77
+ /// A table footer row group.
78
+ TFoot(Tag<kind::TFoot>),
79
+ /// An inline-level element that does not have a specific meaning.
80
+ Span(Tag<kind::Span>),
81
+ /// An inline quotation.
82
+ InlineQuote(Tag<kind::InlineQuote>),
83
+ /// A foot- or endnote, potentially referred to from within the text.
84
+ ///
85
+ /// **Best practice**: It may have a label as a child.
86
+ Note(Tag<kind::Note>),
87
+ /// A reference to elsewhere in the document.
88
+ ///
89
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
90
+ /// linking to a destination in the document, and the second child should consist of
91
+ /// the children that should be associated with that reference.
92
+ Reference(Tag<kind::Reference>),
93
+ /// A reference to the external source of some cited document.
94
+ ///
95
+ /// **Best practice**: It may have a label as a child.
96
+ BibEntry(Tag<kind::BibEntry>),
97
+ /// Computer code.
98
+ Code(Tag<kind::Code>),
99
+ /// A link.
100
+ ///
101
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
102
+ /// linking to an URL, and the second child should consist of the children that should
103
+ /// be associated with that link.
104
+ Link(Tag<kind::Link>),
105
+ /// An association between an annotation and the content it belongs to. PDF
106
+ ///
107
+ /// **Best practice**: Should be used for all annotations, except for link annotations and
108
+ /// widget annotations. The first child should be the identifier of a non-link annotation,
109
+ /// and all other subsequent children should be content identifiers associated with that
110
+ /// annotation.
111
+ Annot(Tag<kind::Annot>),
112
+ /// Item of graphical content.
113
+ ///
114
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
115
+ Figure(Tag<kind::Figure>),
116
+ /// A mathematical formula.
117
+ ///
118
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
119
+ Formula(Tag<kind::Formula>),
120
+ /// An interactive form field.
121
+ Form(Tag<kind::Form>),
122
+ /// Non-structural element. A grouping element having no inherent structural significance;
123
+ /// it serves solely for grouping purposes.
124
+ NonStruct(Tag<kind::NonStruct>),
125
+ /// A date or time.
126
+ Datetime(Tag<kind::Datetime>),
127
+ /// A list of terms.
128
+ Terms(Tag<kind::Terms>),
129
+ /// A title.
130
+ Title(Tag<kind::Title>),
131
+ /// Encloses content with strong importance, most commonly **bold** text.
132
+ Strong(Tag<kind::Strong>),
133
+ /// Encloses content that is emphasized, most commonly *italic* text.
134
+ Em(Tag<kind::Em>),
135
+ }
136
+
137
+ impl TagKind {
138
+ /// A type erased tag, which allows reading all attributes.
139
+ pub fn as_any(&self) -> &AnyTag {
140
+ match self {
141
+ Self::Part(tag) => tag.as_any(),
142
+ Self::Article(tag) => tag.as_any(),
143
+ Self::Section(tag) => tag.as_any(),
144
+ Self::Div(tag) => tag.as_any(),
145
+ Self::BlockQuote(tag) => tag.as_any(),
146
+ Self::Caption(tag) => tag.as_any(),
147
+ Self::TOC(tag) => tag.as_any(),
148
+ Self::TOCI(tag) => tag.as_any(),
149
+ Self::Index(tag) => tag.as_any(),
150
+ Self::P(tag) => tag.as_any(),
151
+ Self::Hn(tag) => tag.as_any(),
152
+ Self::L(tag) => tag.as_any(),
153
+ Self::LI(tag) => tag.as_any(),
154
+ Self::Lbl(tag) => tag.as_any(),
155
+ Self::LBody(tag) => tag.as_any(),
156
+ Self::Table(tag) => tag.as_any(),
157
+ Self::TR(tag) => tag.as_any(),
158
+ Self::TH(tag) => tag.as_any(),
159
+ Self::TD(tag) => tag.as_any(),
160
+ Self::THead(tag) => tag.as_any(),
161
+ Self::TBody(tag) => tag.as_any(),
162
+ Self::TFoot(tag) => tag.as_any(),
163
+ Self::Span(tag) => tag.as_any(),
164
+ Self::InlineQuote(tag) => tag.as_any(),
165
+ Self::Note(tag) => tag.as_any(),
166
+ Self::Reference(tag) => tag.as_any(),
167
+ Self::BibEntry(tag) => tag.as_any(),
168
+ Self::Code(tag) => tag.as_any(),
169
+ Self::Link(tag) => tag.as_any(),
170
+ Self::Annot(tag) => tag.as_any(),
171
+ Self::Figure(tag) => tag.as_any(),
172
+ Self::Formula(tag) => tag.as_any(),
173
+ Self::Form(tag) => tag.as_any(),
174
+ Self::NonStruct(tag) => tag.as_any(),
175
+ Self::Datetime(tag) => tag.as_any(),
176
+ Self::Terms(tag) => tag.as_any(),
177
+ Self::Title(tag) => tag.as_any(),
178
+ Self::Strong(tag) => tag.as_any(),
179
+ Self::Em(tag) => tag.as_any(),
180
+ }
181
+ }
182
+
183
+ /// A type erased tag, which allows reading all attributes and additionally
184
+ /// writing all global attributes.
185
+ pub fn as_any_mut(&mut self) -> &mut AnyTag {
186
+ match self {
187
+ Self::Part(tag) => tag.as_any_mut(),
188
+ Self::Article(tag) => tag.as_any_mut(),
189
+ Self::Section(tag) => tag.as_any_mut(),
190
+ Self::Div(tag) => tag.as_any_mut(),
191
+ Self::BlockQuote(tag) => tag.as_any_mut(),
192
+ Self::Caption(tag) => tag.as_any_mut(),
193
+ Self::TOC(tag) => tag.as_any_mut(),
194
+ Self::TOCI(tag) => tag.as_any_mut(),
195
+ Self::Index(tag) => tag.as_any_mut(),
196
+ Self::P(tag) => tag.as_any_mut(),
197
+ Self::Hn(tag) => tag.as_any_mut(),
198
+ Self::L(tag) => tag.as_any_mut(),
199
+ Self::LI(tag) => tag.as_any_mut(),
200
+ Self::Lbl(tag) => tag.as_any_mut(),
201
+ Self::LBody(tag) => tag.as_any_mut(),
202
+ Self::Table(tag) => tag.as_any_mut(),
203
+ Self::TR(tag) => tag.as_any_mut(),
204
+ Self::TH(tag) => tag.as_any_mut(),
205
+ Self::TD(tag) => tag.as_any_mut(),
206
+ Self::THead(tag) => tag.as_any_mut(),
207
+ Self::TBody(tag) => tag.as_any_mut(),
208
+ Self::TFoot(tag) => tag.as_any_mut(),
209
+ Self::Span(tag) => tag.as_any_mut(),
210
+ Self::InlineQuote(tag) => tag.as_any_mut(),
211
+ Self::Note(tag) => tag.as_any_mut(),
212
+ Self::Reference(tag) => tag.as_any_mut(),
213
+ Self::BibEntry(tag) => tag.as_any_mut(),
214
+ Self::Code(tag) => tag.as_any_mut(),
215
+ Self::Link(tag) => tag.as_any_mut(),
216
+ Self::Annot(tag) => tag.as_any_mut(),
217
+ Self::Figure(tag) => tag.as_any_mut(),
218
+ Self::Formula(tag) => tag.as_any_mut(),
219
+ Self::Form(tag) => tag.as_any_mut(),
220
+ Self::NonStruct(tag) => tag.as_any_mut(),
221
+ Self::Datetime(tag) => tag.as_any_mut(),
222
+ Self::Terms(tag) => tag.as_any_mut(),
223
+ Self::Title(tag) => tag.as_any_mut(),
224
+ Self::Strong(tag) => tag.as_any_mut(),
225
+ Self::Em(tag) => tag.as_any_mut(),
226
+ }
227
+ }
228
+
229
+ /// The tag id.
230
+ pub fn id(&self) -> Option<&TagId> {
231
+ self.as_any().id()
232
+ }
233
+
234
+ /// Set the tag id.
235
+ pub fn set_id(&mut self, id: Option<TagId>) {
236
+ self.as_any_mut().set_id(id);
237
+ }
238
+
239
+ /// Set the tag id.
240
+ pub fn with_id(mut self, id: Option<TagId>) -> Self {
241
+ self.set_id(id);
242
+ self
243
+ }
244
+
245
+ /// The language of this tag.
246
+ pub fn lang(&self) -> Option<&str> {
247
+ self.as_any().lang()
248
+ }
249
+
250
+ /// Set the language of this tag.
251
+ pub fn set_lang(&mut self, lang: Option<String>) {
252
+ self.as_any_mut().set_lang(lang);
253
+ }
254
+
255
+ /// Set the language of this tag.
256
+ pub fn with_lang(mut self, lang: Option<String>) -> Self {
257
+ self.set_lang(lang);
258
+ self
259
+ }
260
+
261
+ /// The optional alternate text that describes the text (for example, if the text
262
+ /// consists of a star symbol, the alt text should describe that in natural language).
263
+ pub fn alt_text(&self) -> Option<&str> {
264
+ self.as_any().alt_text()
265
+ }
266
+
267
+ /// Set the optional alternate text that describes the text (for example, if the text
268
+ /// consists of a star symbol, the alt text should describe that in natural language).
269
+ pub fn set_alt_text(&mut self, alt_text: Option<String>) {
270
+ self.as_any_mut().set_alt_text(alt_text);
271
+ }
272
+
273
+ /// Set the optional alternate text that describes the text (for example, if the text
274
+ /// consists of a star symbol, the alt text should describe that in natural language).
275
+ pub fn with_alt_text(mut self, alt_text: Option<String>) -> Self {
276
+ self.set_alt_text(alt_text);
277
+ self
278
+ }
279
+
280
+ /// The expanded form of an abbreviation.
281
+ /// Only applicable if the content of the tag is an abbreviation.
282
+ pub fn expanded(&self) -> Option<&str> {
283
+ self.as_any().expanded()
284
+ }
285
+
286
+ /// Set the expanded form of an abbreviation.
287
+ /// Only applicable if the content of the tag is an abbreviation.
288
+ pub fn set_expanded(&mut self, expanded: Option<String>) {
289
+ self.as_any_mut().set_expanded(expanded);
290
+ }
291
+
292
+ /// Set the expanded form of an abbreviation.
293
+ /// Only applicable if the content of the tag is an abbreviation.
294
+ pub fn with_expanded(mut self, expanded: Option<String>) -> Self {
295
+ self.set_expanded(expanded);
296
+ self
297
+ }
298
+
299
+ /// The actual text represented by the content of this tag, i.e. if it contained
300
+ /// some curves that artistically represent some word. This should be the exact
301
+ /// replacement text of the word.
302
+ pub fn actual_text(&self) -> Option<&str> {
303
+ self.as_any().actual_text()
304
+ }
305
+
306
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
307
+ /// some curves that artistically represent some word. This should be the exact
308
+ /// replacement text of the word.
309
+ pub fn set_actual_text(&mut self, actual_text: Option<String>) {
310
+ self.as_any_mut().set_actual_text(actual_text);
311
+ }
312
+
313
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
314
+ /// some curves that artistically represent some word. This should be the exact
315
+ /// replacement text of the word.
316
+ pub fn with_actual_text(mut self, actual_text: Option<String>) -> Self {
317
+ self.set_actual_text(actual_text);
318
+ self
319
+ }
320
+
321
+ /// The title, characterizing a specific tag such as `"Chapter 1"`.
322
+ pub fn title(&self) -> Option<&str> {
323
+ self.as_any().title()
324
+ }
325
+
326
+ /// The heading level
327
+ pub fn level(&self) -> Option<NonZeroU16> {
328
+ self.as_any().level()
329
+ }
330
+
331
+ /// The list numbering.
332
+ pub fn numbering(&self) -> Option<ListNumbering> {
333
+ self.as_any().numbering()
334
+ }
335
+
336
+ /// The table summary.
337
+ pub fn summary(&self) -> Option<&str> {
338
+ self.as_any().summary()
339
+ }
340
+
341
+ /// The table header scope.
342
+ pub fn scope(&self) -> Option<TableHeaderScope> {
343
+ self.as_any().scope()
344
+ }
345
+
346
+ /// The list of headers associated with a table cell.
347
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
348
+ /// which can also specify a list of parent header cells (`TH`), and so on.
349
+ /// To determine the list of associated headers this list is recursively
350
+ /// evaluated.
351
+ ///
352
+ /// This allows specifying header hierarchies inside tables.
353
+ pub fn headers(&self) -> Option<&[TagId]> {
354
+ self.as_any().headers()
355
+ }
356
+
357
+ /// The row span of this table cell.
358
+ pub fn row_span(&self) -> Option<NonZeroU32> {
359
+ self.as_any().row_span()
360
+ }
361
+
362
+ /// The column span of this table cell.
363
+ pub fn col_span(&self) -> Option<NonZeroU32> {
364
+ self.as_any().col_span()
365
+ }
366
+
367
+ /// The placement.
368
+ pub fn placement(&self) -> Option<Placement> {
369
+ self.as_any().placement()
370
+ }
371
+
372
+ /// Set the placement.
373
+ pub fn set_placement(&mut self, placement: Option<Placement>) {
374
+ self.as_any_mut().set_placement(placement);
375
+ }
376
+
377
+ /// Set the placement.
378
+ pub fn with_placement(mut self, placement: Option<Placement>) -> Self {
379
+ self.set_placement(placement);
380
+ self
381
+ }
382
+
383
+ /// The writing mode.
384
+ pub fn writing_mode(&self) -> Option<WritingMode> {
385
+ self.as_any().writing_mode()
386
+ }
387
+
388
+ /// Set the writing mode.
389
+ pub fn set_writing_mode(&mut self, writing_mode: Option<WritingMode>) {
390
+ self.as_any_mut().set_writing_mode(writing_mode);
391
+ }
392
+
393
+ /// Set the writing mode.
394
+ pub fn with_writing_mode(mut self, writing_mode: Option<WritingMode>) -> Self {
395
+ self.set_writing_mode(writing_mode);
396
+ self
397
+ }
398
+
399
+ /// The bounding box of a tag that encloses its visible content.
400
+ /// If the content spans multiple pages, this should be omitted.
401
+ pub fn bbox(&self) -> Option<BBox> {
402
+ self.as_any().bbox()
403
+ }
404
+
405
+ /// The width.
406
+ pub fn width(&self) -> Option<f32> {
407
+ self.as_any().width()
408
+ }
409
+
410
+ /// The height.
411
+ pub fn height(&self) -> Option<f32> {
412
+ self.as_any().height()
413
+ }
414
+
415
+ /// The background color.
416
+ pub fn background_color(&self) -> Option<NaiveRgbColor> {
417
+ self.as_any().background_color()
418
+ }
419
+
420
+ /// Set the background color.
421
+ pub fn set_background_color(&mut self, background_color: Option<NaiveRgbColor>) {
422
+ self.as_any_mut().set_background_color(background_color);
423
+ }
424
+
425
+ /// Set the background color.
426
+ pub fn with_background_color(mut self, background_color: Option<NaiveRgbColor>) -> Self {
427
+ self.set_background_color(background_color);
428
+ self
429
+ }
430
+
431
+ /// The border color.
432
+ pub fn border_color(&self) -> Option<Sides<NaiveRgbColor>> {
433
+ self.as_any().border_color()
434
+ }
435
+
436
+ /// Set the border color.
437
+ pub fn set_border_color(&mut self, border_color: Option<Sides<NaiveRgbColor>>) {
438
+ self.as_any_mut().set_border_color(border_color);
439
+ }
440
+
441
+ /// Set the border color.
442
+ pub fn with_border_color(mut self, border_color: Option<Sides<NaiveRgbColor>>) -> Self {
443
+ self.set_border_color(border_color);
444
+ self
445
+ }
446
+
447
+ /// The way the border is drawn.
448
+ pub fn border_style(&self) -> Option<Sides<BorderStyle>> {
449
+ self.as_any().border_style()
450
+ }
451
+
452
+ /// Set the way the border is drawn.
453
+ pub fn set_border_style(&mut self, border_style: Option<Sides<BorderStyle>>) {
454
+ self.as_any_mut().set_border_style(border_style);
455
+ }
456
+
457
+ /// Set the way the border is drawn.
458
+ pub fn with_border_style(mut self, border_style: Option<Sides<BorderStyle>>) -> Self {
459
+ self.set_border_style(border_style);
460
+ self
461
+ }
462
+
463
+ /// The border width.
464
+ pub fn border_thickness(&self) -> Option<Sides<f32>> {
465
+ self.as_any().border_thickness()
466
+ }
467
+
468
+ /// Set the border width.
469
+ pub fn set_border_thickness(&mut self, border_thickness: Option<Sides<f32>>) {
470
+ self.as_any_mut().set_border_thickness(border_thickness);
471
+ }
472
+
473
+ /// Set the border width.
474
+ pub fn with_border_thickness(mut self, border_thickness: Option<Sides<f32>>) -> Self {
475
+ self.set_border_thickness(border_thickness);
476
+ self
477
+ }
478
+
479
+ /// The padding inside of an element.
480
+ pub fn padding(&self) -> Option<Sides<f32>> {
481
+ self.as_any().padding()
482
+ }
483
+
484
+ /// Set the padding inside of an element.
485
+ pub fn set_padding(&mut self, padding: Option<Sides<f32>>) {
486
+ self.as_any_mut().set_padding(padding);
487
+ }
488
+
489
+ /// Set the padding inside of an element.
490
+ pub fn with_padding(mut self, padding: Option<Sides<f32>>) -> Self {
491
+ self.set_padding(padding);
492
+ self
493
+ }
494
+
495
+ /// The color of text, borders, and text decorations.
496
+ pub fn color(&self) -> Option<NaiveRgbColor> {
497
+ self.as_any().color()
498
+ }
499
+
500
+ /// Set the color of text, borders, and text decorations.
501
+ pub fn set_color(&mut self, color: Option<NaiveRgbColor>) {
502
+ self.as_any_mut().set_color(color);
503
+ }
504
+
505
+ /// Set the color of text, borders, and text decorations.
506
+ pub fn with_color(mut self, color: Option<NaiveRgbColor>) -> Self {
507
+ self.set_color(color);
508
+ self
509
+ }
510
+
511
+ /// The spacing before the block-level element.
512
+ pub fn space_before(&self) -> Option<f32> {
513
+ self.as_any().space_before()
514
+ }
515
+
516
+ /// The spacing after the block-level element.
517
+ pub fn space_after(&self) -> Option<f32> {
518
+ self.as_any().space_after()
519
+ }
520
+
521
+ /// The spacing between the start inline edge of the element and the parent.
522
+ pub fn start_indent(&self) -> Option<f32> {
523
+ self.as_any().start_indent()
524
+ }
525
+
526
+ /// The spacing between the end inline edge of the element and the parent.
527
+ pub fn end_indent(&self) -> Option<f32> {
528
+ self.as_any().end_indent()
529
+ }
530
+
531
+ /// The amount the first line of text in a block-level element is indented. Only
532
+ /// applicable to paragraph-like elements with non-block-level elements.
533
+ pub fn text_indent(&self) -> Option<f32> {
534
+ self.as_any().text_indent()
535
+ }
536
+
537
+ /// The text alignment.
538
+ pub fn text_align(&self) -> Option<TextAlign> {
539
+ self.as_any().text_align()
540
+ }
541
+
542
+ /// The alignment of block-level elements inside of this block-level element.
543
+ pub fn block_align(&self) -> Option<BlockAlign> {
544
+ self.as_any().block_align()
545
+ }
546
+
547
+ /// The alignment of inline-level elements inside of this block-level element.
548
+ pub fn inline_align(&self) -> Option<InlineAlign> {
549
+ self.as_any().inline_align()
550
+ }
551
+
552
+ /// The border style of table cells, overriding `BorderStyle`.
553
+ pub fn table_border_style(&self) -> Option<Sides<BorderStyle>> {
554
+ self.as_any().table_border_style()
555
+ }
556
+
557
+ /// The padding inside of table cells, overriding `Padding`.
558
+ pub fn table_padding(&self) -> Option<Sides<f32>> {
559
+ self.as_any().table_padding()
560
+ }
561
+
562
+ /// The distance by which the baseline shall be shifted from the default position.
563
+ pub fn baseline_shift(&self) -> Option<f32> {
564
+ self.as_any().baseline_shift()
565
+ }
566
+
567
+ /// Set the distance by which the baseline shall be shifted from the default position.
568
+ pub fn set_baseline_shift(&mut self, baseline_shift: Option<f32>) {
569
+ self.as_any_mut().set_baseline_shift(baseline_shift);
570
+ }
571
+
572
+ /// Set the distance by which the baseline shall be shifted from the default position.
573
+ pub fn with_baseline_shift(mut self, baseline_shift: Option<f32>) -> Self {
574
+ self.set_baseline_shift(baseline_shift);
575
+ self
576
+ }
577
+
578
+ /// The height of each line in an element on the block axis.
579
+ pub fn line_height(&self) -> Option<LineHeight> {
580
+ self.as_any().line_height()
581
+ }
582
+
583
+ /// Set the height of each line in an element on the block axis.
584
+ pub fn set_line_height(&mut self, line_height: Option<LineHeight>) {
585
+ self.as_any_mut().set_line_height(line_height);
586
+ }
587
+
588
+ /// Set the height of each line in an element on the block axis.
589
+ pub fn with_line_height(mut self, line_height: Option<LineHeight>) -> Self {
590
+ self.set_line_height(line_height);
591
+ self
592
+ }
593
+
594
+ /// The color of the text decoration, overriding the fill color.
595
+ pub fn text_decoration_color(&self) -> Option<NaiveRgbColor> {
596
+ self.as_any().text_decoration_color()
597
+ }
598
+
599
+ /// Set the color of the text decoration, overriding the fill color.
600
+ pub fn set_text_decoration_color(&mut self, text_decoration_color: Option<NaiveRgbColor>) {
601
+ self.as_any_mut().set_text_decoration_color(text_decoration_color);
602
+ }
603
+
604
+ /// Set the color of the text decoration, overriding the fill color.
605
+ pub fn with_text_decoration_color(mut self, text_decoration_color: Option<NaiveRgbColor>) -> Self {
606
+ self.set_text_decoration_color(text_decoration_color);
607
+ self
608
+ }
609
+
610
+ /// The width of the text decoration line.
611
+ pub fn text_decoration_thickness(&self) -> Option<f32> {
612
+ self.as_any().text_decoration_thickness()
613
+ }
614
+
615
+ /// Set the width of the text decoration line.
616
+ pub fn set_text_decoration_thickness(&mut self, text_decoration_thickness: Option<f32>) {
617
+ self.as_any_mut().set_text_decoration_thickness(text_decoration_thickness);
618
+ }
619
+
620
+ /// Set the width of the text decoration line.
621
+ pub fn with_text_decoration_thickness(mut self, text_decoration_thickness: Option<f32>) -> Self {
622
+ self.set_text_decoration_thickness(text_decoration_thickness);
623
+ self
624
+ }
625
+
626
+ /// The kind of text decoration.
627
+ pub fn text_decoration_type(&self) -> Option<TextDecorationType> {
628
+ self.as_any().text_decoration_type()
629
+ }
630
+
631
+ /// Set the kind of text decoration.
632
+ pub fn set_text_decoration_type(&mut self, text_decoration_type: Option<TextDecorationType>) {
633
+ self.as_any_mut().set_text_decoration_type(text_decoration_type);
634
+ }
635
+
636
+ /// Set the kind of text decoration.
637
+ pub fn with_text_decoration_type(mut self, text_decoration_type: Option<TextDecorationType>) -> Self {
638
+ self.set_text_decoration_type(text_decoration_type);
639
+ self
640
+ }
641
+
642
+ /// How the glyphs are rotated in a vertical writing mode.
643
+ pub fn glyph_orientation_vertical(&self) -> Option<GlyphOrientationVertical> {
644
+ self.as_any().glyph_orientation_vertical()
645
+ }
646
+
647
+ /// Set how the glyphs are rotated in a vertical writing mode.
648
+ pub fn set_glyph_orientation_vertical(&mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) {
649
+ self.as_any_mut().set_glyph_orientation_vertical(glyph_orientation_vertical);
650
+ }
651
+
652
+ /// Set how the glyphs are rotated in a vertical writing mode.
653
+ pub fn with_glyph_orientation_vertical(mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) -> Self {
654
+ self.set_glyph_orientation_vertical(glyph_orientation_vertical);
655
+ self
656
+ }
657
+
658
+ /// The number of columns in the grouping element.
659
+ pub fn column_count(&self) -> Option<NonZeroU32> {
660
+ self.as_any().column_count()
661
+ }
662
+
663
+ /// The width of the gaps between columns in the grouping element.
664
+ pub fn column_gap(&self) -> Option<&ColumnDimensions> {
665
+ self.as_any().column_gap()
666
+ }
667
+
668
+ /// The width of the columns in the grouping element.
669
+ pub fn column_widths(&self) -> Option<&ColumnDimensions> {
670
+ self.as_any().column_widths()
671
+ }
672
+ }
673
+
674
+ // Read accessors for all attributes and write accessors for global ones.
675
+ impl AnyTag {
676
+ #[inline(always)]
677
+ fn get_struct(&self, ordinal: usize) -> Option<&StructAttr> {
678
+ self.attrs.get(ordinal).map(Attr::unwrap_struct)
679
+ }
680
+
681
+ #[allow(unused)]
682
+ #[inline(always)]
683
+ fn set_struct(&mut self, attr: StructAttr) {
684
+ self.attrs.set(Attr::Struct(attr));
685
+ }
686
+
687
+ #[allow(unused)]
688
+ #[inline(always)]
689
+ fn set_or_remove_struct(&mut self, ordinal: usize, attr: Option<StructAttr>) {
690
+ self.attrs.set_or_remove(ordinal, attr.map(Attr::Struct));
691
+ }
692
+
693
+ #[inline(always)]
694
+ fn get_list(&self, ordinal: usize) -> Option<&ListAttr> {
695
+ self.attrs.get(ordinal).map(Attr::unwrap_list)
696
+ }
697
+
698
+ #[allow(unused)]
699
+ #[inline(always)]
700
+ fn set_list(&mut self, attr: ListAttr) {
701
+ self.attrs.set(Attr::List(attr));
702
+ }
703
+
704
+ #[allow(unused)]
705
+ #[inline(always)]
706
+ fn set_or_remove_list(&mut self, ordinal: usize, attr: Option<ListAttr>) {
707
+ self.attrs.set_or_remove(ordinal, attr.map(Attr::List));
708
+ }
709
+
710
+ #[inline(always)]
711
+ fn get_table(&self, ordinal: usize) -> Option<&TableAttr> {
712
+ self.attrs.get(ordinal).map(Attr::unwrap_table)
713
+ }
714
+
715
+ #[allow(unused)]
716
+ #[inline(always)]
717
+ fn set_table(&mut self, attr: TableAttr) {
718
+ self.attrs.set(Attr::Table(attr));
719
+ }
720
+
721
+ #[allow(unused)]
722
+ #[inline(always)]
723
+ fn set_or_remove_table(&mut self, ordinal: usize, attr: Option<TableAttr>) {
724
+ self.attrs.set_or_remove(ordinal, attr.map(Attr::Table));
725
+ }
726
+
727
+ #[inline(always)]
728
+ fn get_layout(&self, ordinal: usize) -> Option<&LayoutAttr> {
729
+ self.attrs.get(ordinal).map(Attr::unwrap_layout)
730
+ }
731
+
732
+ #[allow(unused)]
733
+ #[inline(always)]
734
+ fn set_layout(&mut self, attr: LayoutAttr) {
735
+ self.attrs.set(Attr::Layout(attr));
736
+ }
737
+
738
+ #[allow(unused)]
739
+ #[inline(always)]
740
+ fn set_or_remove_layout(&mut self, ordinal: usize, attr: Option<LayoutAttr>) {
741
+ self.attrs.set_or_remove(ordinal, attr.map(Attr::Layout));
742
+ }
743
+
744
+
745
+ /// The tag id.
746
+ pub fn id(&self) -> Option<&TagId> {
747
+ self.get_struct(StructAttr::ID).map(StructAttr::unwrap_id)
748
+ }
749
+
750
+ /// Set the tag id.
751
+ pub fn set_id(&mut self, id: Option<TagId>) {
752
+ self.set_or_remove_struct(StructAttr::ID, id.map(StructAttr::Id));
753
+ }
754
+
755
+ /// Set the tag id.
756
+ pub fn with_id(mut self, id: Option<TagId>) -> Self {
757
+ self.set_id(id);
758
+ self
759
+ }
760
+
761
+ /// The language of this tag.
762
+ pub fn lang(&self) -> Option<&str> {
763
+ self.get_struct(StructAttr::LANG).map(StructAttr::unwrap_lang)
764
+ }
765
+
766
+ /// Set the language of this tag.
767
+ pub fn set_lang(&mut self, lang: Option<String>) {
768
+ self.set_or_remove_struct(StructAttr::LANG, lang.map(StructAttr::Lang));
769
+ }
770
+
771
+ /// Set the language of this tag.
772
+ pub fn with_lang(mut self, lang: Option<String>) -> Self {
773
+ self.set_lang(lang);
774
+ self
775
+ }
776
+
777
+ /// The optional alternate text that describes the text (for example, if the text
778
+ /// consists of a star symbol, the alt text should describe that in natural language).
779
+ pub fn alt_text(&self) -> Option<&str> {
780
+ self.get_struct(StructAttr::ALT_TEXT).map(StructAttr::unwrap_alt_text)
781
+ }
782
+
783
+ /// Set the optional alternate text that describes the text (for example, if the text
784
+ /// consists of a star symbol, the alt text should describe that in natural language).
785
+ pub fn set_alt_text(&mut self, alt_text: Option<String>) {
786
+ self.set_or_remove_struct(StructAttr::ALT_TEXT, alt_text.map(StructAttr::AltText));
787
+ }
788
+
789
+ /// Set the optional alternate text that describes the text (for example, if the text
790
+ /// consists of a star symbol, the alt text should describe that in natural language).
791
+ pub fn with_alt_text(mut self, alt_text: Option<String>) -> Self {
792
+ self.set_alt_text(alt_text);
793
+ self
794
+ }
795
+
796
+ /// The expanded form of an abbreviation.
797
+ /// Only applicable if the content of the tag is an abbreviation.
798
+ pub fn expanded(&self) -> Option<&str> {
799
+ self.get_struct(StructAttr::EXPANDED).map(StructAttr::unwrap_expanded)
800
+ }
801
+
802
+ /// Set the expanded form of an abbreviation.
803
+ /// Only applicable if the content of the tag is an abbreviation.
804
+ pub fn set_expanded(&mut self, expanded: Option<String>) {
805
+ self.set_or_remove_struct(StructAttr::EXPANDED, expanded.map(StructAttr::Expanded));
806
+ }
807
+
808
+ /// Set the expanded form of an abbreviation.
809
+ /// Only applicable if the content of the tag is an abbreviation.
810
+ pub fn with_expanded(mut self, expanded: Option<String>) -> Self {
811
+ self.set_expanded(expanded);
812
+ self
813
+ }
814
+
815
+ /// The actual text represented by the content of this tag, i.e. if it contained
816
+ /// some curves that artistically represent some word. This should be the exact
817
+ /// replacement text of the word.
818
+ pub fn actual_text(&self) -> Option<&str> {
819
+ self.get_struct(StructAttr::ACTUAL_TEXT).map(StructAttr::unwrap_actual_text)
820
+ }
821
+
822
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
823
+ /// some curves that artistically represent some word. This should be the exact
824
+ /// replacement text of the word.
825
+ pub fn set_actual_text(&mut self, actual_text: Option<String>) {
826
+ self.set_or_remove_struct(StructAttr::ACTUAL_TEXT, actual_text.map(StructAttr::ActualText));
827
+ }
828
+
829
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
830
+ /// some curves that artistically represent some word. This should be the exact
831
+ /// replacement text of the word.
832
+ pub fn with_actual_text(mut self, actual_text: Option<String>) -> Self {
833
+ self.set_actual_text(actual_text);
834
+ self
835
+ }
836
+
837
+ /// The title, characterizing a specific tag such as `"Chapter 1"`.
838
+ pub fn title(&self) -> Option<&str> {
839
+ self.get_struct(StructAttr::TITLE).map(StructAttr::unwrap_title)
840
+ }
841
+
842
+ /// The heading level
843
+ pub fn level(&self) -> Option<NonZeroU16> {
844
+ self.get_struct(StructAttr::HEADING_LEVEL).map(StructAttr::unwrap_level)
845
+ }
846
+
847
+ /// The list numbering.
848
+ pub fn numbering(&self) -> Option<ListNumbering> {
849
+ self.get_list(ListAttr::NUMBERING).map(ListAttr::unwrap_numbering)
850
+ }
851
+
852
+ /// The table summary.
853
+ pub fn summary(&self) -> Option<&str> {
854
+ self.get_table(TableAttr::SUMMARY).map(TableAttr::unwrap_summary)
855
+ }
856
+
857
+ /// The table header scope.
858
+ pub fn scope(&self) -> Option<TableHeaderScope> {
859
+ self.get_table(TableAttr::HEADER_SCOPE).map(TableAttr::unwrap_scope)
860
+ }
861
+
862
+ /// The list of headers associated with a table cell.
863
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
864
+ /// which can also specify a list of parent header cells (`TH`), and so on.
865
+ /// To determine the list of associated headers this list is recursively
866
+ /// evaluated.
867
+ ///
868
+ /// This allows specifying header hierarchies inside tables.
869
+ pub fn headers(&self) -> Option<&[TagId]> {
870
+ self.get_table(TableAttr::CELL_HEADERS).map(TableAttr::unwrap_headers)
871
+ }
872
+
873
+ /// The row span of this table cell.
874
+ pub fn row_span(&self) -> Option<NonZeroU32> {
875
+ self.get_table(TableAttr::ROW_SPAN).map(TableAttr::unwrap_row_span)
876
+ }
877
+
878
+ /// The column span of this table cell.
879
+ pub fn col_span(&self) -> Option<NonZeroU32> {
880
+ self.get_table(TableAttr::COL_SPAN).map(TableAttr::unwrap_col_span)
881
+ }
882
+
883
+ /// The placement.
884
+ pub fn placement(&self) -> Option<Placement> {
885
+ self.get_layout(LayoutAttr::PLACEMENT).map(LayoutAttr::unwrap_placement)
886
+ }
887
+
888
+ /// Set the placement.
889
+ pub fn set_placement(&mut self, placement: Option<Placement>) {
890
+ self.set_or_remove_layout(LayoutAttr::PLACEMENT, placement.map(LayoutAttr::Placement));
891
+ }
892
+
893
+ /// Set the placement.
894
+ pub fn with_placement(mut self, placement: Option<Placement>) -> Self {
895
+ self.set_placement(placement);
896
+ self
897
+ }
898
+
899
+ /// The writing mode.
900
+ pub fn writing_mode(&self) -> Option<WritingMode> {
901
+ self.get_layout(LayoutAttr::WRITING_MODE).map(LayoutAttr::unwrap_writing_mode)
902
+ }
903
+
904
+ /// Set the writing mode.
905
+ pub fn set_writing_mode(&mut self, writing_mode: Option<WritingMode>) {
906
+ self.set_or_remove_layout(LayoutAttr::WRITING_MODE, writing_mode.map(LayoutAttr::WritingMode));
907
+ }
908
+
909
+ /// Set the writing mode.
910
+ pub fn with_writing_mode(mut self, writing_mode: Option<WritingMode>) -> Self {
911
+ self.set_writing_mode(writing_mode);
912
+ self
913
+ }
914
+
915
+ /// The bounding box of a tag that encloses its visible content.
916
+ /// If the content spans multiple pages, this should be omitted.
917
+ pub fn bbox(&self) -> Option<BBox> {
918
+ self.get_layout(LayoutAttr::B_BOX).map(LayoutAttr::unwrap_bbox)
919
+ }
920
+
921
+ /// The width.
922
+ pub fn width(&self) -> Option<f32> {
923
+ self.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
924
+ }
925
+
926
+ /// The height.
927
+ pub fn height(&self) -> Option<f32> {
928
+ self.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
929
+ }
930
+
931
+ /// The background color.
932
+ pub fn background_color(&self) -> Option<NaiveRgbColor> {
933
+ self.get_layout(LayoutAttr::BACKGROUND_COLOR).map(LayoutAttr::unwrap_background_color)
934
+ }
935
+
936
+ /// Set the background color.
937
+ pub fn set_background_color(&mut self, background_color: Option<NaiveRgbColor>) {
938
+ self.set_or_remove_layout(LayoutAttr::BACKGROUND_COLOR, background_color.map(LayoutAttr::BackgroundColor));
939
+ }
940
+
941
+ /// Set the background color.
942
+ pub fn with_background_color(mut self, background_color: Option<NaiveRgbColor>) -> Self {
943
+ self.set_background_color(background_color);
944
+ self
945
+ }
946
+
947
+ /// The border color.
948
+ pub fn border_color(&self) -> Option<Sides<NaiveRgbColor>> {
949
+ self.get_layout(LayoutAttr::BORDER_COLOR).map(LayoutAttr::unwrap_border_color)
950
+ }
951
+
952
+ /// Set the border color.
953
+ pub fn set_border_color(&mut self, border_color: Option<Sides<NaiveRgbColor>>) {
954
+ self.set_or_remove_layout(LayoutAttr::BORDER_COLOR, border_color.map(LayoutAttr::BorderColor));
955
+ }
956
+
957
+ /// Set the border color.
958
+ pub fn with_border_color(mut self, border_color: Option<Sides<NaiveRgbColor>>) -> Self {
959
+ self.set_border_color(border_color);
960
+ self
961
+ }
962
+
963
+ /// The way the border is drawn.
964
+ pub fn border_style(&self) -> Option<Sides<BorderStyle>> {
965
+ self.get_layout(LayoutAttr::BORDER_STYLE).map(LayoutAttr::unwrap_border_style)
966
+ }
967
+
968
+ /// Set the way the border is drawn.
969
+ pub fn set_border_style(&mut self, border_style: Option<Sides<BorderStyle>>) {
970
+ self.set_or_remove_layout(LayoutAttr::BORDER_STYLE, border_style.map(LayoutAttr::BorderStyle));
971
+ }
972
+
973
+ /// Set the way the border is drawn.
974
+ pub fn with_border_style(mut self, border_style: Option<Sides<BorderStyle>>) -> Self {
975
+ self.set_border_style(border_style);
976
+ self
977
+ }
978
+
979
+ /// The border width.
980
+ pub fn border_thickness(&self) -> Option<Sides<f32>> {
981
+ self.get_layout(LayoutAttr::BORDER_THICKNESS).map(LayoutAttr::unwrap_border_thickness)
982
+ }
983
+
984
+ /// Set the border width.
985
+ pub fn set_border_thickness(&mut self, border_thickness: Option<Sides<f32>>) {
986
+ self.set_or_remove_layout(LayoutAttr::BORDER_THICKNESS, border_thickness.map(LayoutAttr::BorderThickness));
987
+ }
988
+
989
+ /// Set the border width.
990
+ pub fn with_border_thickness(mut self, border_thickness: Option<Sides<f32>>) -> Self {
991
+ self.set_border_thickness(border_thickness);
992
+ self
993
+ }
994
+
995
+ /// The padding inside of an element.
996
+ pub fn padding(&self) -> Option<Sides<f32>> {
997
+ self.get_layout(LayoutAttr::PADDING).map(LayoutAttr::unwrap_padding)
998
+ }
999
+
1000
+ /// Set the padding inside of an element.
1001
+ pub fn set_padding(&mut self, padding: Option<Sides<f32>>) {
1002
+ self.set_or_remove_layout(LayoutAttr::PADDING, padding.map(LayoutAttr::Padding));
1003
+ }
1004
+
1005
+ /// Set the padding inside of an element.
1006
+ pub fn with_padding(mut self, padding: Option<Sides<f32>>) -> Self {
1007
+ self.set_padding(padding);
1008
+ self
1009
+ }
1010
+
1011
+ /// The color of text, borders, and text decorations.
1012
+ pub fn color(&self) -> Option<NaiveRgbColor> {
1013
+ self.get_layout(LayoutAttr::COLOR).map(LayoutAttr::unwrap_color)
1014
+ }
1015
+
1016
+ /// Set the color of text, borders, and text decorations.
1017
+ pub fn set_color(&mut self, color: Option<NaiveRgbColor>) {
1018
+ self.set_or_remove_layout(LayoutAttr::COLOR, color.map(LayoutAttr::Color));
1019
+ }
1020
+
1021
+ /// Set the color of text, borders, and text decorations.
1022
+ pub fn with_color(mut self, color: Option<NaiveRgbColor>) -> Self {
1023
+ self.set_color(color);
1024
+ self
1025
+ }
1026
+
1027
+ /// The spacing before the block-level element.
1028
+ pub fn space_before(&self) -> Option<f32> {
1029
+ self.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
1030
+ }
1031
+
1032
+ /// The spacing after the block-level element.
1033
+ pub fn space_after(&self) -> Option<f32> {
1034
+ self.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
1035
+ }
1036
+
1037
+ /// The spacing between the start inline edge of the element and the parent.
1038
+ pub fn start_indent(&self) -> Option<f32> {
1039
+ self.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
1040
+ }
1041
+
1042
+ /// The spacing between the end inline edge of the element and the parent.
1043
+ pub fn end_indent(&self) -> Option<f32> {
1044
+ self.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
1045
+ }
1046
+
1047
+ /// The amount the first line of text in a block-level element is indented. Only
1048
+ /// applicable to paragraph-like elements with non-block-level elements.
1049
+ pub fn text_indent(&self) -> Option<f32> {
1050
+ self.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
1051
+ }
1052
+
1053
+ /// The text alignment.
1054
+ pub fn text_align(&self) -> Option<TextAlign> {
1055
+ self.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
1056
+ }
1057
+
1058
+ /// The alignment of block-level elements inside of this block-level element.
1059
+ pub fn block_align(&self) -> Option<BlockAlign> {
1060
+ self.get_layout(LayoutAttr::BLOCK_ALIGN).map(LayoutAttr::unwrap_block_align)
1061
+ }
1062
+
1063
+ /// The alignment of inline-level elements inside of this block-level element.
1064
+ pub fn inline_align(&self) -> Option<InlineAlign> {
1065
+ self.get_layout(LayoutAttr::INLINE_ALIGN).map(LayoutAttr::unwrap_inline_align)
1066
+ }
1067
+
1068
+ /// The border style of table cells, overriding `BorderStyle`.
1069
+ pub fn table_border_style(&self) -> Option<Sides<BorderStyle>> {
1070
+ self.get_layout(LayoutAttr::TABLE_BORDER_STYLE).map(LayoutAttr::unwrap_table_border_style)
1071
+ }
1072
+
1073
+ /// The padding inside of table cells, overriding `Padding`.
1074
+ pub fn table_padding(&self) -> Option<Sides<f32>> {
1075
+ self.get_layout(LayoutAttr::TABLE_PADDING).map(LayoutAttr::unwrap_table_padding)
1076
+ }
1077
+
1078
+ /// The distance by which the baseline shall be shifted from the default position.
1079
+ pub fn baseline_shift(&self) -> Option<f32> {
1080
+ self.get_layout(LayoutAttr::BASELINE_SHIFT).map(LayoutAttr::unwrap_baseline_shift)
1081
+ }
1082
+
1083
+ /// Set the distance by which the baseline shall be shifted from the default position.
1084
+ pub fn set_baseline_shift(&mut self, baseline_shift: Option<f32>) {
1085
+ self.set_or_remove_layout(LayoutAttr::BASELINE_SHIFT, baseline_shift.map(LayoutAttr::BaselineShift));
1086
+ }
1087
+
1088
+ /// Set the distance by which the baseline shall be shifted from the default position.
1089
+ pub fn with_baseline_shift(mut self, baseline_shift: Option<f32>) -> Self {
1090
+ self.set_baseline_shift(baseline_shift);
1091
+ self
1092
+ }
1093
+
1094
+ /// The height of each line in an element on the block axis.
1095
+ pub fn line_height(&self) -> Option<LineHeight> {
1096
+ self.get_layout(LayoutAttr::LINE_HEIGHT).map(LayoutAttr::unwrap_line_height)
1097
+ }
1098
+
1099
+ /// Set the height of each line in an element on the block axis.
1100
+ pub fn set_line_height(&mut self, line_height: Option<LineHeight>) {
1101
+ self.set_or_remove_layout(LayoutAttr::LINE_HEIGHT, line_height.map(LayoutAttr::LineHeight));
1102
+ }
1103
+
1104
+ /// Set the height of each line in an element on the block axis.
1105
+ pub fn with_line_height(mut self, line_height: Option<LineHeight>) -> Self {
1106
+ self.set_line_height(line_height);
1107
+ self
1108
+ }
1109
+
1110
+ /// The color of the text decoration, overriding the fill color.
1111
+ pub fn text_decoration_color(&self) -> Option<NaiveRgbColor> {
1112
+ self.get_layout(LayoutAttr::TEXT_DECORATION_COLOR).map(LayoutAttr::unwrap_text_decoration_color)
1113
+ }
1114
+
1115
+ /// Set the color of the text decoration, overriding the fill color.
1116
+ pub fn set_text_decoration_color(&mut self, text_decoration_color: Option<NaiveRgbColor>) {
1117
+ self.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_COLOR, text_decoration_color.map(LayoutAttr::TextDecorationColor));
1118
+ }
1119
+
1120
+ /// Set the color of the text decoration, overriding the fill color.
1121
+ pub fn with_text_decoration_color(mut self, text_decoration_color: Option<NaiveRgbColor>) -> Self {
1122
+ self.set_text_decoration_color(text_decoration_color);
1123
+ self
1124
+ }
1125
+
1126
+ /// The width of the text decoration line.
1127
+ pub fn text_decoration_thickness(&self) -> Option<f32> {
1128
+ self.get_layout(LayoutAttr::TEXT_DECORATION_THICKNESS).map(LayoutAttr::unwrap_text_decoration_thickness)
1129
+ }
1130
+
1131
+ /// Set the width of the text decoration line.
1132
+ pub fn set_text_decoration_thickness(&mut self, text_decoration_thickness: Option<f32>) {
1133
+ self.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_THICKNESS, text_decoration_thickness.map(LayoutAttr::TextDecorationThickness));
1134
+ }
1135
+
1136
+ /// Set the width of the text decoration line.
1137
+ pub fn with_text_decoration_thickness(mut self, text_decoration_thickness: Option<f32>) -> Self {
1138
+ self.set_text_decoration_thickness(text_decoration_thickness);
1139
+ self
1140
+ }
1141
+
1142
+ /// The kind of text decoration.
1143
+ pub fn text_decoration_type(&self) -> Option<TextDecorationType> {
1144
+ self.get_layout(LayoutAttr::TEXT_DECORATION_TYPE).map(LayoutAttr::unwrap_text_decoration_type)
1145
+ }
1146
+
1147
+ /// Set the kind of text decoration.
1148
+ pub fn set_text_decoration_type(&mut self, text_decoration_type: Option<TextDecorationType>) {
1149
+ self.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_TYPE, text_decoration_type.map(LayoutAttr::TextDecorationType));
1150
+ }
1151
+
1152
+ /// Set the kind of text decoration.
1153
+ pub fn with_text_decoration_type(mut self, text_decoration_type: Option<TextDecorationType>) -> Self {
1154
+ self.set_text_decoration_type(text_decoration_type);
1155
+ self
1156
+ }
1157
+
1158
+ /// How the glyphs are rotated in a vertical writing mode.
1159
+ pub fn glyph_orientation_vertical(&self) -> Option<GlyphOrientationVertical> {
1160
+ self.get_layout(LayoutAttr::GLYPH_ORIENTATION_VERTICAL).map(LayoutAttr::unwrap_glyph_orientation_vertical)
1161
+ }
1162
+
1163
+ /// Set how the glyphs are rotated in a vertical writing mode.
1164
+ pub fn set_glyph_orientation_vertical(&mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) {
1165
+ self.set_or_remove_layout(LayoutAttr::GLYPH_ORIENTATION_VERTICAL, glyph_orientation_vertical.map(LayoutAttr::GlyphOrientationVertical));
1166
+ }
1167
+
1168
+ /// Set how the glyphs are rotated in a vertical writing mode.
1169
+ pub fn with_glyph_orientation_vertical(mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) -> Self {
1170
+ self.set_glyph_orientation_vertical(glyph_orientation_vertical);
1171
+ self
1172
+ }
1173
+
1174
+ /// The number of columns in the grouping element.
1175
+ pub fn column_count(&self) -> Option<NonZeroU32> {
1176
+ self.get_layout(LayoutAttr::COLUMN_COUNT).map(LayoutAttr::unwrap_column_count)
1177
+ }
1178
+
1179
+ /// The width of the gaps between columns in the grouping element.
1180
+ pub fn column_gap(&self) -> Option<&ColumnDimensions> {
1181
+ self.get_layout(LayoutAttr::COLUMN_GAP).map(LayoutAttr::unwrap_column_gap)
1182
+ }
1183
+
1184
+ /// The width of the columns in the grouping element.
1185
+ pub fn column_widths(&self) -> Option<&ColumnDimensions> {
1186
+ self.get_layout(LayoutAttr::COLUMN_WIDTHS).map(LayoutAttr::unwrap_column_widths)
1187
+ }
1188
+ }
1189
+
1190
+ impl<T> Tag<T> {
1191
+
1192
+ /// The tag id.
1193
+ pub fn id(&self) -> Option<&TagId> {
1194
+ self.inner.get_struct(StructAttr::ID).map(StructAttr::unwrap_id)
1195
+ }
1196
+
1197
+ /// Set the tag id.
1198
+ pub fn set_id(&mut self, id: Option<TagId>) {
1199
+ self.inner.set_or_remove_struct(StructAttr::ID, id.map(StructAttr::Id));
1200
+ }
1201
+
1202
+ /// Set the tag id.
1203
+ pub fn with_id(mut self, id: Option<TagId>) -> Self {
1204
+ self.set_id(id);
1205
+ self
1206
+ }
1207
+
1208
+ /// The language of this tag.
1209
+ pub fn lang(&self) -> Option<&str> {
1210
+ self.inner.get_struct(StructAttr::LANG).map(StructAttr::unwrap_lang)
1211
+ }
1212
+
1213
+ /// Set the language of this tag.
1214
+ pub fn set_lang(&mut self, lang: Option<String>) {
1215
+ self.inner.set_or_remove_struct(StructAttr::LANG, lang.map(StructAttr::Lang));
1216
+ }
1217
+
1218
+ /// Set the language of this tag.
1219
+ pub fn with_lang(mut self, lang: Option<String>) -> Self {
1220
+ self.set_lang(lang);
1221
+ self
1222
+ }
1223
+
1224
+ /// The optional alternate text that describes the text (for example, if the text
1225
+ /// consists of a star symbol, the alt text should describe that in natural language).
1226
+ pub fn alt_text(&self) -> Option<&str> {
1227
+ self.inner.get_struct(StructAttr::ALT_TEXT).map(StructAttr::unwrap_alt_text)
1228
+ }
1229
+
1230
+ /// Set the optional alternate text that describes the text (for example, if the text
1231
+ /// consists of a star symbol, the alt text should describe that in natural language).
1232
+ pub fn set_alt_text(&mut self, alt_text: Option<String>) {
1233
+ self.inner.set_or_remove_struct(StructAttr::ALT_TEXT, alt_text.map(StructAttr::AltText));
1234
+ }
1235
+
1236
+ /// Set the optional alternate text that describes the text (for example, if the text
1237
+ /// consists of a star symbol, the alt text should describe that in natural language).
1238
+ pub fn with_alt_text(mut self, alt_text: Option<String>) -> Self {
1239
+ self.set_alt_text(alt_text);
1240
+ self
1241
+ }
1242
+
1243
+ /// The expanded form of an abbreviation.
1244
+ /// Only applicable if the content of the tag is an abbreviation.
1245
+ pub fn expanded(&self) -> Option<&str> {
1246
+ self.inner.get_struct(StructAttr::EXPANDED).map(StructAttr::unwrap_expanded)
1247
+ }
1248
+
1249
+ /// Set the expanded form of an abbreviation.
1250
+ /// Only applicable if the content of the tag is an abbreviation.
1251
+ pub fn set_expanded(&mut self, expanded: Option<String>) {
1252
+ self.inner.set_or_remove_struct(StructAttr::EXPANDED, expanded.map(StructAttr::Expanded));
1253
+ }
1254
+
1255
+ /// Set the expanded form of an abbreviation.
1256
+ /// Only applicable if the content of the tag is an abbreviation.
1257
+ pub fn with_expanded(mut self, expanded: Option<String>) -> Self {
1258
+ self.set_expanded(expanded);
1259
+ self
1260
+ }
1261
+
1262
+ /// The actual text represented by the content of this tag, i.e. if it contained
1263
+ /// some curves that artistically represent some word. This should be the exact
1264
+ /// replacement text of the word.
1265
+ pub fn actual_text(&self) -> Option<&str> {
1266
+ self.inner.get_struct(StructAttr::ACTUAL_TEXT).map(StructAttr::unwrap_actual_text)
1267
+ }
1268
+
1269
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
1270
+ /// some curves that artistically represent some word. This should be the exact
1271
+ /// replacement text of the word.
1272
+ pub fn set_actual_text(&mut self, actual_text: Option<String>) {
1273
+ self.inner.set_or_remove_struct(StructAttr::ACTUAL_TEXT, actual_text.map(StructAttr::ActualText));
1274
+ }
1275
+
1276
+ /// Set the actual text represented by the content of this tag, i.e. if it contained
1277
+ /// some curves that artistically represent some word. This should be the exact
1278
+ /// replacement text of the word.
1279
+ pub fn with_actual_text(mut self, actual_text: Option<String>) -> Self {
1280
+ self.set_actual_text(actual_text);
1281
+ self
1282
+ }
1283
+
1284
+ /// The placement.
1285
+ pub fn placement(&self) -> Option<Placement> {
1286
+ self.inner.get_layout(LayoutAttr::PLACEMENT).map(LayoutAttr::unwrap_placement)
1287
+ }
1288
+
1289
+ /// Set the placement.
1290
+ pub fn set_placement(&mut self, placement: Option<Placement>) {
1291
+ self.inner.set_or_remove_layout(LayoutAttr::PLACEMENT, placement.map(LayoutAttr::Placement));
1292
+ }
1293
+
1294
+ /// Set the placement.
1295
+ pub fn with_placement(mut self, placement: Option<Placement>) -> Self {
1296
+ self.set_placement(placement);
1297
+ self
1298
+ }
1299
+
1300
+ /// The writing mode.
1301
+ pub fn writing_mode(&self) -> Option<WritingMode> {
1302
+ self.inner.get_layout(LayoutAttr::WRITING_MODE).map(LayoutAttr::unwrap_writing_mode)
1303
+ }
1304
+
1305
+ /// Set the writing mode.
1306
+ pub fn set_writing_mode(&mut self, writing_mode: Option<WritingMode>) {
1307
+ self.inner.set_or_remove_layout(LayoutAttr::WRITING_MODE, writing_mode.map(LayoutAttr::WritingMode));
1308
+ }
1309
+
1310
+ /// Set the writing mode.
1311
+ pub fn with_writing_mode(mut self, writing_mode: Option<WritingMode>) -> Self {
1312
+ self.set_writing_mode(writing_mode);
1313
+ self
1314
+ }
1315
+
1316
+ /// The background color.
1317
+ pub fn background_color(&self) -> Option<NaiveRgbColor> {
1318
+ self.inner.get_layout(LayoutAttr::BACKGROUND_COLOR).map(LayoutAttr::unwrap_background_color)
1319
+ }
1320
+
1321
+ /// Set the background color.
1322
+ pub fn set_background_color(&mut self, background_color: Option<NaiveRgbColor>) {
1323
+ self.inner.set_or_remove_layout(LayoutAttr::BACKGROUND_COLOR, background_color.map(LayoutAttr::BackgroundColor));
1324
+ }
1325
+
1326
+ /// Set the background color.
1327
+ pub fn with_background_color(mut self, background_color: Option<NaiveRgbColor>) -> Self {
1328
+ self.set_background_color(background_color);
1329
+ self
1330
+ }
1331
+
1332
+ /// The border color.
1333
+ pub fn border_color(&self) -> Option<Sides<NaiveRgbColor>> {
1334
+ self.inner.get_layout(LayoutAttr::BORDER_COLOR).map(LayoutAttr::unwrap_border_color)
1335
+ }
1336
+
1337
+ /// Set the border color.
1338
+ pub fn set_border_color(&mut self, border_color: Option<Sides<NaiveRgbColor>>) {
1339
+ self.inner.set_or_remove_layout(LayoutAttr::BORDER_COLOR, border_color.map(LayoutAttr::BorderColor));
1340
+ }
1341
+
1342
+ /// Set the border color.
1343
+ pub fn with_border_color(mut self, border_color: Option<Sides<NaiveRgbColor>>) -> Self {
1344
+ self.set_border_color(border_color);
1345
+ self
1346
+ }
1347
+
1348
+ /// The way the border is drawn.
1349
+ pub fn border_style(&self) -> Option<Sides<BorderStyle>> {
1350
+ self.inner.get_layout(LayoutAttr::BORDER_STYLE).map(LayoutAttr::unwrap_border_style)
1351
+ }
1352
+
1353
+ /// Set the way the border is drawn.
1354
+ pub fn set_border_style(&mut self, border_style: Option<Sides<BorderStyle>>) {
1355
+ self.inner.set_or_remove_layout(LayoutAttr::BORDER_STYLE, border_style.map(LayoutAttr::BorderStyle));
1356
+ }
1357
+
1358
+ /// Set the way the border is drawn.
1359
+ pub fn with_border_style(mut self, border_style: Option<Sides<BorderStyle>>) -> Self {
1360
+ self.set_border_style(border_style);
1361
+ self
1362
+ }
1363
+
1364
+ /// The border width.
1365
+ pub fn border_thickness(&self) -> Option<Sides<f32>> {
1366
+ self.inner.get_layout(LayoutAttr::BORDER_THICKNESS).map(LayoutAttr::unwrap_border_thickness)
1367
+ }
1368
+
1369
+ /// Set the border width.
1370
+ pub fn set_border_thickness(&mut self, border_thickness: Option<Sides<f32>>) {
1371
+ self.inner.set_or_remove_layout(LayoutAttr::BORDER_THICKNESS, border_thickness.map(LayoutAttr::BorderThickness));
1372
+ }
1373
+
1374
+ /// Set the border width.
1375
+ pub fn with_border_thickness(mut self, border_thickness: Option<Sides<f32>>) -> Self {
1376
+ self.set_border_thickness(border_thickness);
1377
+ self
1378
+ }
1379
+
1380
+ /// The padding inside of an element.
1381
+ pub fn padding(&self) -> Option<Sides<f32>> {
1382
+ self.inner.get_layout(LayoutAttr::PADDING).map(LayoutAttr::unwrap_padding)
1383
+ }
1384
+
1385
+ /// Set the padding inside of an element.
1386
+ pub fn set_padding(&mut self, padding: Option<Sides<f32>>) {
1387
+ self.inner.set_or_remove_layout(LayoutAttr::PADDING, padding.map(LayoutAttr::Padding));
1388
+ }
1389
+
1390
+ /// Set the padding inside of an element.
1391
+ pub fn with_padding(mut self, padding: Option<Sides<f32>>) -> Self {
1392
+ self.set_padding(padding);
1393
+ self
1394
+ }
1395
+
1396
+ /// The color of text, borders, and text decorations.
1397
+ pub fn color(&self) -> Option<NaiveRgbColor> {
1398
+ self.inner.get_layout(LayoutAttr::COLOR).map(LayoutAttr::unwrap_color)
1399
+ }
1400
+
1401
+ /// Set the color of text, borders, and text decorations.
1402
+ pub fn set_color(&mut self, color: Option<NaiveRgbColor>) {
1403
+ self.inner.set_or_remove_layout(LayoutAttr::COLOR, color.map(LayoutAttr::Color));
1404
+ }
1405
+
1406
+ /// Set the color of text, borders, and text decorations.
1407
+ pub fn with_color(mut self, color: Option<NaiveRgbColor>) -> Self {
1408
+ self.set_color(color);
1409
+ self
1410
+ }
1411
+
1412
+ /// The distance by which the baseline shall be shifted from the default position.
1413
+ pub fn baseline_shift(&self) -> Option<f32> {
1414
+ self.inner.get_layout(LayoutAttr::BASELINE_SHIFT).map(LayoutAttr::unwrap_baseline_shift)
1415
+ }
1416
+
1417
+ /// Set the distance by which the baseline shall be shifted from the default position.
1418
+ pub fn set_baseline_shift(&mut self, baseline_shift: Option<f32>) {
1419
+ self.inner.set_or_remove_layout(LayoutAttr::BASELINE_SHIFT, baseline_shift.map(LayoutAttr::BaselineShift));
1420
+ }
1421
+
1422
+ /// Set the distance by which the baseline shall be shifted from the default position.
1423
+ pub fn with_baseline_shift(mut self, baseline_shift: Option<f32>) -> Self {
1424
+ self.set_baseline_shift(baseline_shift);
1425
+ self
1426
+ }
1427
+
1428
+ /// The height of each line in an element on the block axis.
1429
+ pub fn line_height(&self) -> Option<LineHeight> {
1430
+ self.inner.get_layout(LayoutAttr::LINE_HEIGHT).map(LayoutAttr::unwrap_line_height)
1431
+ }
1432
+
1433
+ /// Set the height of each line in an element on the block axis.
1434
+ pub fn set_line_height(&mut self, line_height: Option<LineHeight>) {
1435
+ self.inner.set_or_remove_layout(LayoutAttr::LINE_HEIGHT, line_height.map(LayoutAttr::LineHeight));
1436
+ }
1437
+
1438
+ /// Set the height of each line in an element on the block axis.
1439
+ pub fn with_line_height(mut self, line_height: Option<LineHeight>) -> Self {
1440
+ self.set_line_height(line_height);
1441
+ self
1442
+ }
1443
+
1444
+ /// The color of the text decoration, overriding the fill color.
1445
+ pub fn text_decoration_color(&self) -> Option<NaiveRgbColor> {
1446
+ self.inner.get_layout(LayoutAttr::TEXT_DECORATION_COLOR).map(LayoutAttr::unwrap_text_decoration_color)
1447
+ }
1448
+
1449
+ /// Set the color of the text decoration, overriding the fill color.
1450
+ pub fn set_text_decoration_color(&mut self, text_decoration_color: Option<NaiveRgbColor>) {
1451
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_COLOR, text_decoration_color.map(LayoutAttr::TextDecorationColor));
1452
+ }
1453
+
1454
+ /// Set the color of the text decoration, overriding the fill color.
1455
+ pub fn with_text_decoration_color(mut self, text_decoration_color: Option<NaiveRgbColor>) -> Self {
1456
+ self.set_text_decoration_color(text_decoration_color);
1457
+ self
1458
+ }
1459
+
1460
+ /// The width of the text decoration line.
1461
+ pub fn text_decoration_thickness(&self) -> Option<f32> {
1462
+ self.inner.get_layout(LayoutAttr::TEXT_DECORATION_THICKNESS).map(LayoutAttr::unwrap_text_decoration_thickness)
1463
+ }
1464
+
1465
+ /// Set the width of the text decoration line.
1466
+ pub fn set_text_decoration_thickness(&mut self, text_decoration_thickness: Option<f32>) {
1467
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_THICKNESS, text_decoration_thickness.map(LayoutAttr::TextDecorationThickness));
1468
+ }
1469
+
1470
+ /// Set the width of the text decoration line.
1471
+ pub fn with_text_decoration_thickness(mut self, text_decoration_thickness: Option<f32>) -> Self {
1472
+ self.set_text_decoration_thickness(text_decoration_thickness);
1473
+ self
1474
+ }
1475
+
1476
+ /// The kind of text decoration.
1477
+ pub fn text_decoration_type(&self) -> Option<TextDecorationType> {
1478
+ self.inner.get_layout(LayoutAttr::TEXT_DECORATION_TYPE).map(LayoutAttr::unwrap_text_decoration_type)
1479
+ }
1480
+
1481
+ /// Set the kind of text decoration.
1482
+ pub fn set_text_decoration_type(&mut self, text_decoration_type: Option<TextDecorationType>) {
1483
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_DECORATION_TYPE, text_decoration_type.map(LayoutAttr::TextDecorationType));
1484
+ }
1485
+
1486
+ /// Set the kind of text decoration.
1487
+ pub fn with_text_decoration_type(mut self, text_decoration_type: Option<TextDecorationType>) -> Self {
1488
+ self.set_text_decoration_type(text_decoration_type);
1489
+ self
1490
+ }
1491
+
1492
+ /// How the glyphs are rotated in a vertical writing mode.
1493
+ pub fn glyph_orientation_vertical(&self) -> Option<GlyphOrientationVertical> {
1494
+ self.inner.get_layout(LayoutAttr::GLYPH_ORIENTATION_VERTICAL).map(LayoutAttr::unwrap_glyph_orientation_vertical)
1495
+ }
1496
+
1497
+ /// Set how the glyphs are rotated in a vertical writing mode.
1498
+ pub fn set_glyph_orientation_vertical(&mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) {
1499
+ self.inner.set_or_remove_layout(LayoutAttr::GLYPH_ORIENTATION_VERTICAL, glyph_orientation_vertical.map(LayoutAttr::GlyphOrientationVertical));
1500
+ }
1501
+
1502
+ /// Set how the glyphs are rotated in a vertical writing mode.
1503
+ pub fn with_glyph_orientation_vertical(mut self, glyph_orientation_vertical: Option<GlyphOrientationVertical>) -> Self {
1504
+ self.set_glyph_orientation_vertical(glyph_orientation_vertical);
1505
+ self
1506
+ }
1507
+ }
1508
+
1509
+ /// Tag kind structs.
1510
+ pub mod kind {
1511
+ /// A part of a document that may contain multiple articles or sections.
1512
+ #[derive(Clone, Debug, PartialEq)]
1513
+ pub struct Part;
1514
+
1515
+ /// An article with largely self-contained content.
1516
+ #[derive(Clone, Debug, PartialEq)]
1517
+ pub struct Article;
1518
+
1519
+ /// Section of a larger document.
1520
+ #[derive(Clone, Debug, PartialEq)]
1521
+ pub struct Section;
1522
+
1523
+ /// A generic block-level grouping element.
1524
+ #[derive(Clone, Debug, PartialEq)]
1525
+ pub struct Div;
1526
+
1527
+ /// A paragraph-level quote.
1528
+ #[derive(Clone, Debug, PartialEq)]
1529
+ pub struct BlockQuote;
1530
+
1531
+ /// An image or figure caption.
1532
+ ///
1533
+ /// **Best Practice**: In the tag tree, this should appear
1534
+ /// as a sibling after the image (or other) content it describes.
1535
+ #[derive(Clone, Debug, PartialEq)]
1536
+ pub struct Caption;
1537
+
1538
+ /// Table of contents.
1539
+ ///
1540
+ /// **Best Practice**: Should consist of TOCIs or other nested TOCs.
1541
+ #[derive(Clone, Debug, PartialEq)]
1542
+ pub struct TOC;
1543
+
1544
+ /// Item in the table of contents.
1545
+ ///
1546
+ /// **Best Practice**: Should only appear within a TOC. Should only consist of
1547
+ /// labels, references, paragraphs and TOCs.
1548
+ #[derive(Clone, Debug, PartialEq)]
1549
+ pub struct TOCI;
1550
+
1551
+ /// Index of the key terms in the document.
1552
+ ///
1553
+ /// **Best Practice**: Should contain a sequence of text accompanied by
1554
+ /// reference elements pointing to their occurrence in the text.
1555
+ #[derive(Clone, Debug, PartialEq)]
1556
+ pub struct Index;
1557
+
1558
+ /// A paragraph.
1559
+ #[derive(Clone, Debug, PartialEq)]
1560
+ pub struct P;
1561
+
1562
+ /// Heading level `n`, including an optional title of the heading.
1563
+ ///
1564
+ /// The title is required for some export modes, like for example PDF/UA.
1565
+ #[derive(Clone, Debug, PartialEq)]
1566
+ pub struct Hn;
1567
+
1568
+ /// A list.
1569
+ ///
1570
+ /// **Best practice**: Should consist of an optional caption followed by
1571
+ /// list items.
1572
+ /// List numbering is only required for PDF/UA, but we just enforce it for always.
1573
+ #[derive(Clone, Debug, PartialEq)]
1574
+ pub struct L;
1575
+
1576
+ /// A list item.
1577
+ ///
1578
+ /// **Best practice**: Should consist of one or more list labels and/or list bodies.
1579
+ #[derive(Clone, Debug, PartialEq)]
1580
+ pub struct LI;
1581
+
1582
+ /// Label for a list item.
1583
+ #[derive(Clone, Debug, PartialEq)]
1584
+ pub struct Lbl;
1585
+
1586
+ /// Description of the list item.
1587
+ #[derive(Clone, Debug, PartialEq)]
1588
+ pub struct LBody;
1589
+
1590
+ /// A table, with an optional summary describing the purpose and structure.
1591
+ ///
1592
+ /// **Best practice**: Should consist of an optional table header row,
1593
+ /// one or more table body elements and an optional table footer. Can have
1594
+ /// caption as the first or last child.
1595
+ #[derive(Clone, Debug, PartialEq)]
1596
+ pub struct Table;
1597
+
1598
+ /// A table row.
1599
+ ///
1600
+ /// **Best practice**: May contain table headers cells and table data cells.
1601
+ #[derive(Clone, Debug, PartialEq)]
1602
+ pub struct TR;
1603
+
1604
+ /// A table header cell.
1605
+ #[derive(Clone, Debug, PartialEq)]
1606
+ pub struct TH;
1607
+
1608
+ /// A table data cell.
1609
+ #[derive(Clone, Debug, PartialEq)]
1610
+ pub struct TD;
1611
+
1612
+ /// A table header row group.
1613
+ #[derive(Clone, Debug, PartialEq)]
1614
+ pub struct THead;
1615
+
1616
+ /// A table data row group.
1617
+ #[derive(Clone, Debug, PartialEq)]
1618
+ pub struct TBody;
1619
+
1620
+ /// A table footer row group.
1621
+ #[derive(Clone, Debug, PartialEq)]
1622
+ pub struct TFoot;
1623
+
1624
+ /// An inline-level element that does not have a specific meaning.
1625
+ #[derive(Clone, Debug, PartialEq)]
1626
+ pub struct Span;
1627
+
1628
+ /// An inline quotation.
1629
+ #[derive(Clone, Debug, PartialEq)]
1630
+ pub struct InlineQuote;
1631
+
1632
+ /// A foot- or endnote, potentially referred to from within the text.
1633
+ ///
1634
+ /// **Best practice**: It may have a label as a child.
1635
+ #[derive(Clone, Debug, PartialEq)]
1636
+ pub struct Note;
1637
+
1638
+ /// A reference to elsewhere in the document.
1639
+ ///
1640
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
1641
+ /// linking to a destination in the document, and the second child should consist of
1642
+ /// the children that should be associated with that reference.
1643
+ #[derive(Clone, Debug, PartialEq)]
1644
+ pub struct Reference;
1645
+
1646
+ /// A reference to the external source of some cited document.
1647
+ ///
1648
+ /// **Best practice**: It may have a label as a child.
1649
+ #[derive(Clone, Debug, PartialEq)]
1650
+ pub struct BibEntry;
1651
+
1652
+ /// Computer code.
1653
+ #[derive(Clone, Debug, PartialEq)]
1654
+ pub struct Code;
1655
+
1656
+ /// A link.
1657
+ ///
1658
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
1659
+ /// linking to an URL, and the second child should consist of the children that should
1660
+ /// be associated with that link.
1661
+ #[derive(Clone, Debug, PartialEq)]
1662
+ pub struct Link;
1663
+
1664
+ /// An association between an annotation and the content it belongs to. PDF
1665
+ ///
1666
+ /// **Best practice**: Should be used for all annotations, except for link annotations and
1667
+ /// widget annotations. The first child should be the identifier of a non-link annotation,
1668
+ /// and all other subsequent children should be content identifiers associated with that
1669
+ /// annotation.
1670
+ #[derive(Clone, Debug, PartialEq)]
1671
+ pub struct Annot;
1672
+
1673
+ /// Item of graphical content.
1674
+ ///
1675
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
1676
+ #[derive(Clone, Debug, PartialEq)]
1677
+ pub struct Figure;
1678
+
1679
+ /// A mathematical formula.
1680
+ ///
1681
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
1682
+ #[derive(Clone, Debug, PartialEq)]
1683
+ pub struct Formula;
1684
+
1685
+ /// An interactive form field.
1686
+ #[derive(Clone, Debug, PartialEq)]
1687
+ pub struct Form;
1688
+
1689
+ /// Non-structural element. A grouping element having no inherent structural significance;
1690
+ /// it serves solely for grouping purposes.
1691
+ #[derive(Clone, Debug, PartialEq)]
1692
+ pub struct NonStruct;
1693
+
1694
+ /// A date or time.
1695
+ #[derive(Clone, Debug, PartialEq)]
1696
+ pub struct Datetime;
1697
+
1698
+ /// A list of terms.
1699
+ #[derive(Clone, Debug, PartialEq)]
1700
+ pub struct Terms;
1701
+
1702
+ /// A title.
1703
+ #[derive(Clone, Debug, PartialEq)]
1704
+ pub struct Title;
1705
+
1706
+ /// Encloses content with strong importance, most commonly **bold** text.
1707
+ #[derive(Clone, Debug, PartialEq)]
1708
+ pub struct Strong;
1709
+
1710
+ /// Encloses content that is emphasized, most commonly *italic* text.
1711
+ #[derive(Clone, Debug, PartialEq)]
1712
+ pub struct Em;
1713
+
1714
+ }
1715
+
1716
+ impl From<Tag<kind::Part>> for TagKind {
1717
+ fn from(value: Tag<kind::Part>) -> Self {
1718
+ Self::Part(value)
1719
+ }
1720
+ }
1721
+ impl Tag<kind::Part> {
1722
+ /// A part of a document that may contain multiple articles or sections.
1723
+ #[allow(non_upper_case_globals)]
1724
+ pub const Part: Tag<kind::Part> = Tag::new();
1725
+ }
1726
+
1727
+ impl From<Tag<kind::Article>> for TagKind {
1728
+ fn from(value: Tag<kind::Article>) -> Self {
1729
+ Self::Article(value)
1730
+ }
1731
+ }
1732
+ impl Tag<kind::Article> {
1733
+ /// An article with largely self-contained content.
1734
+ #[allow(non_upper_case_globals)]
1735
+ pub const Article: Tag<kind::Article> = Tag::new();
1736
+
1737
+ /// The number of columns in the grouping element.
1738
+ pub fn column_count(&self) -> Option<NonZeroU32> {
1739
+ self.inner.get_layout(LayoutAttr::COLUMN_COUNT).map(LayoutAttr::unwrap_column_count)
1740
+ }
1741
+
1742
+ /// Set the number of columns in the grouping element.
1743
+ pub fn set_column_count(&mut self, column_count: Option<NonZeroU32>) {
1744
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_COUNT, column_count.map(LayoutAttr::ColumnCount));
1745
+ }
1746
+
1747
+ /// Set the number of columns in the grouping element.
1748
+ pub fn with_column_count(mut self, column_count: Option<NonZeroU32>) -> Self {
1749
+ self.set_column_count(column_count);
1750
+ self
1751
+ }
1752
+
1753
+ /// The width of the gaps between columns in the grouping element.
1754
+ pub fn column_gap(&self) -> Option<&ColumnDimensions> {
1755
+ self.inner.get_layout(LayoutAttr::COLUMN_GAP).map(LayoutAttr::unwrap_column_gap)
1756
+ }
1757
+
1758
+ /// Set the width of the gaps between columns in the grouping element.
1759
+ pub fn set_column_gap(&mut self, column_gap: Option<ColumnDimensions>) {
1760
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_GAP, column_gap.map(LayoutAttr::ColumnGap));
1761
+ }
1762
+
1763
+ /// Set the width of the gaps between columns in the grouping element.
1764
+ pub fn with_column_gap(mut self, column_gap: Option<ColumnDimensions>) -> Self {
1765
+ self.set_column_gap(column_gap);
1766
+ self
1767
+ }
1768
+
1769
+ /// The width of the columns in the grouping element.
1770
+ pub fn column_widths(&self) -> Option<&ColumnDimensions> {
1771
+ self.inner.get_layout(LayoutAttr::COLUMN_WIDTHS).map(LayoutAttr::unwrap_column_widths)
1772
+ }
1773
+
1774
+ /// Set the width of the columns in the grouping element.
1775
+ pub fn set_column_widths(&mut self, column_widths: Option<ColumnDimensions>) {
1776
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_WIDTHS, column_widths.map(LayoutAttr::ColumnWidths));
1777
+ }
1778
+
1779
+ /// Set the width of the columns in the grouping element.
1780
+ pub fn with_column_widths(mut self, column_widths: Option<ColumnDimensions>) -> Self {
1781
+ self.set_column_widths(column_widths);
1782
+ self
1783
+ }
1784
+ }
1785
+
1786
+ impl From<Tag<kind::Section>> for TagKind {
1787
+ fn from(value: Tag<kind::Section>) -> Self {
1788
+ Self::Section(value)
1789
+ }
1790
+ }
1791
+ impl Tag<kind::Section> {
1792
+ /// Section of a larger document.
1793
+ #[allow(non_upper_case_globals)]
1794
+ pub const Section: Tag<kind::Section> = Tag::new();
1795
+
1796
+ /// The number of columns in the grouping element.
1797
+ pub fn column_count(&self) -> Option<NonZeroU32> {
1798
+ self.inner.get_layout(LayoutAttr::COLUMN_COUNT).map(LayoutAttr::unwrap_column_count)
1799
+ }
1800
+
1801
+ /// Set the number of columns in the grouping element.
1802
+ pub fn set_column_count(&mut self, column_count: Option<NonZeroU32>) {
1803
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_COUNT, column_count.map(LayoutAttr::ColumnCount));
1804
+ }
1805
+
1806
+ /// Set the number of columns in the grouping element.
1807
+ pub fn with_column_count(mut self, column_count: Option<NonZeroU32>) -> Self {
1808
+ self.set_column_count(column_count);
1809
+ self
1810
+ }
1811
+
1812
+ /// The width of the gaps between columns in the grouping element.
1813
+ pub fn column_gap(&self) -> Option<&ColumnDimensions> {
1814
+ self.inner.get_layout(LayoutAttr::COLUMN_GAP).map(LayoutAttr::unwrap_column_gap)
1815
+ }
1816
+
1817
+ /// Set the width of the gaps between columns in the grouping element.
1818
+ pub fn set_column_gap(&mut self, column_gap: Option<ColumnDimensions>) {
1819
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_GAP, column_gap.map(LayoutAttr::ColumnGap));
1820
+ }
1821
+
1822
+ /// Set the width of the gaps between columns in the grouping element.
1823
+ pub fn with_column_gap(mut self, column_gap: Option<ColumnDimensions>) -> Self {
1824
+ self.set_column_gap(column_gap);
1825
+ self
1826
+ }
1827
+
1828
+ /// The width of the columns in the grouping element.
1829
+ pub fn column_widths(&self) -> Option<&ColumnDimensions> {
1830
+ self.inner.get_layout(LayoutAttr::COLUMN_WIDTHS).map(LayoutAttr::unwrap_column_widths)
1831
+ }
1832
+
1833
+ /// Set the width of the columns in the grouping element.
1834
+ pub fn set_column_widths(&mut self, column_widths: Option<ColumnDimensions>) {
1835
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_WIDTHS, column_widths.map(LayoutAttr::ColumnWidths));
1836
+ }
1837
+
1838
+ /// Set the width of the columns in the grouping element.
1839
+ pub fn with_column_widths(mut self, column_widths: Option<ColumnDimensions>) -> Self {
1840
+ self.set_column_widths(column_widths);
1841
+ self
1842
+ }
1843
+ }
1844
+
1845
+ impl From<Tag<kind::Div>> for TagKind {
1846
+ fn from(value: Tag<kind::Div>) -> Self {
1847
+ Self::Div(value)
1848
+ }
1849
+ }
1850
+ impl Tag<kind::Div> {
1851
+ /// A generic block-level grouping element.
1852
+ #[allow(non_upper_case_globals)]
1853
+ pub const Div: Tag<kind::Div> = Tag::new();
1854
+
1855
+ /// The number of columns in the grouping element.
1856
+ pub fn column_count(&self) -> Option<NonZeroU32> {
1857
+ self.inner.get_layout(LayoutAttr::COLUMN_COUNT).map(LayoutAttr::unwrap_column_count)
1858
+ }
1859
+
1860
+ /// Set the number of columns in the grouping element.
1861
+ pub fn set_column_count(&mut self, column_count: Option<NonZeroU32>) {
1862
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_COUNT, column_count.map(LayoutAttr::ColumnCount));
1863
+ }
1864
+
1865
+ /// Set the number of columns in the grouping element.
1866
+ pub fn with_column_count(mut self, column_count: Option<NonZeroU32>) -> Self {
1867
+ self.set_column_count(column_count);
1868
+ self
1869
+ }
1870
+
1871
+ /// The width of the gaps between columns in the grouping element.
1872
+ pub fn column_gap(&self) -> Option<&ColumnDimensions> {
1873
+ self.inner.get_layout(LayoutAttr::COLUMN_GAP).map(LayoutAttr::unwrap_column_gap)
1874
+ }
1875
+
1876
+ /// Set the width of the gaps between columns in the grouping element.
1877
+ pub fn set_column_gap(&mut self, column_gap: Option<ColumnDimensions>) {
1878
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_GAP, column_gap.map(LayoutAttr::ColumnGap));
1879
+ }
1880
+
1881
+ /// Set the width of the gaps between columns in the grouping element.
1882
+ pub fn with_column_gap(mut self, column_gap: Option<ColumnDimensions>) -> Self {
1883
+ self.set_column_gap(column_gap);
1884
+ self
1885
+ }
1886
+
1887
+ /// The width of the columns in the grouping element.
1888
+ pub fn column_widths(&self) -> Option<&ColumnDimensions> {
1889
+ self.inner.get_layout(LayoutAttr::COLUMN_WIDTHS).map(LayoutAttr::unwrap_column_widths)
1890
+ }
1891
+
1892
+ /// Set the width of the columns in the grouping element.
1893
+ pub fn set_column_widths(&mut self, column_widths: Option<ColumnDimensions>) {
1894
+ self.inner.set_or_remove_layout(LayoutAttr::COLUMN_WIDTHS, column_widths.map(LayoutAttr::ColumnWidths));
1895
+ }
1896
+
1897
+ /// Set the width of the columns in the grouping element.
1898
+ pub fn with_column_widths(mut self, column_widths: Option<ColumnDimensions>) -> Self {
1899
+ self.set_column_widths(column_widths);
1900
+ self
1901
+ }
1902
+ }
1903
+
1904
+ impl From<Tag<kind::BlockQuote>> for TagKind {
1905
+ fn from(value: Tag<kind::BlockQuote>) -> Self {
1906
+ Self::BlockQuote(value)
1907
+ }
1908
+ }
1909
+ impl Tag<kind::BlockQuote> {
1910
+ /// A paragraph-level quote.
1911
+ #[allow(non_upper_case_globals)]
1912
+ pub const BlockQuote: Tag<kind::BlockQuote> = Tag::new();
1913
+ }
1914
+
1915
+ impl From<Tag<kind::Caption>> for TagKind {
1916
+ fn from(value: Tag<kind::Caption>) -> Self {
1917
+ Self::Caption(value)
1918
+ }
1919
+ }
1920
+ impl Tag<kind::Caption> {
1921
+ /// An image or figure caption.
1922
+ ///
1923
+ /// **Best Practice**: In the tag tree, this should appear
1924
+ /// as a sibling after the image (or other) content it describes.
1925
+ #[allow(non_upper_case_globals)]
1926
+ pub const Caption: Tag<kind::Caption> = Tag::new();
1927
+ }
1928
+
1929
+ impl From<Tag<kind::TOC>> for TagKind {
1930
+ fn from(value: Tag<kind::TOC>) -> Self {
1931
+ Self::TOC(value)
1932
+ }
1933
+ }
1934
+ impl Tag<kind::TOC> {
1935
+ /// Table of contents.
1936
+ ///
1937
+ /// **Best Practice**: Should consist of TOCIs or other nested TOCs.
1938
+ #[allow(non_upper_case_globals)]
1939
+ pub const TOC: Tag<kind::TOC> = Tag::new();
1940
+ }
1941
+
1942
+ impl From<Tag<kind::TOCI>> for TagKind {
1943
+ fn from(value: Tag<kind::TOCI>) -> Self {
1944
+ Self::TOCI(value)
1945
+ }
1946
+ }
1947
+ impl Tag<kind::TOCI> {
1948
+ /// Item in the table of contents.
1949
+ ///
1950
+ /// **Best Practice**: Should only appear within a TOC. Should only consist of
1951
+ /// labels, references, paragraphs and TOCs.
1952
+ #[allow(non_upper_case_globals)]
1953
+ pub const TOCI: Tag<kind::TOCI> = Tag::new();
1954
+ }
1955
+
1956
+ impl From<Tag<kind::Index>> for TagKind {
1957
+ fn from(value: Tag<kind::Index>) -> Self {
1958
+ Self::Index(value)
1959
+ }
1960
+ }
1961
+ impl Tag<kind::Index> {
1962
+ /// Index of the key terms in the document.
1963
+ ///
1964
+ /// **Best Practice**: Should contain a sequence of text accompanied by
1965
+ /// reference elements pointing to their occurrence in the text.
1966
+ #[allow(non_upper_case_globals)]
1967
+ pub const Index: Tag<kind::Index> = Tag::new();
1968
+ }
1969
+
1970
+ impl From<Tag<kind::P>> for TagKind {
1971
+ fn from(value: Tag<kind::P>) -> Self {
1972
+ Self::P(value)
1973
+ }
1974
+ }
1975
+ impl Tag<kind::P> {
1976
+ /// A paragraph.
1977
+ #[allow(non_upper_case_globals)]
1978
+ pub const P: Tag<kind::P> = Tag::new();
1979
+
1980
+ /// The spacing before the block-level element.
1981
+ pub fn space_before(&self) -> Option<f32> {
1982
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
1983
+ }
1984
+
1985
+ /// Set the spacing before the block-level element.
1986
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
1987
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
1988
+ }
1989
+
1990
+ /// Set the spacing before the block-level element.
1991
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
1992
+ self.set_space_before(space_before);
1993
+ self
1994
+ }
1995
+
1996
+ /// The spacing after the block-level element.
1997
+ pub fn space_after(&self) -> Option<f32> {
1998
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
1999
+ }
2000
+
2001
+ /// Set the spacing after the block-level element.
2002
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2003
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2004
+ }
2005
+
2006
+ /// Set the spacing after the block-level element.
2007
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2008
+ self.set_space_after(space_after);
2009
+ self
2010
+ }
2011
+
2012
+ /// The spacing between the start inline edge of the element and the parent.
2013
+ pub fn start_indent(&self) -> Option<f32> {
2014
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2015
+ }
2016
+
2017
+ /// Set the spacing between the start inline edge of the element and the parent.
2018
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2019
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2020
+ }
2021
+
2022
+ /// Set the spacing between the start inline edge of the element and the parent.
2023
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2024
+ self.set_start_indent(start_indent);
2025
+ self
2026
+ }
2027
+
2028
+ /// The spacing between the end inline edge of the element and the parent.
2029
+ pub fn end_indent(&self) -> Option<f32> {
2030
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2031
+ }
2032
+
2033
+ /// Set the spacing between the end inline edge of the element and the parent.
2034
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2035
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2036
+ }
2037
+
2038
+ /// Set the spacing between the end inline edge of the element and the parent.
2039
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2040
+ self.set_end_indent(end_indent);
2041
+ self
2042
+ }
2043
+
2044
+ /// The amount the first line of text in a block-level element is indented. Only
2045
+ /// applicable to paragraph-like elements with non-block-level elements.
2046
+ pub fn text_indent(&self) -> Option<f32> {
2047
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2048
+ }
2049
+
2050
+ /// Set the amount the first line of text in a block-level element is indented. Only
2051
+ /// applicable to paragraph-like elements with non-block-level elements.
2052
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2053
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2054
+ }
2055
+
2056
+ /// Set the amount the first line of text in a block-level element is indented. Only
2057
+ /// applicable to paragraph-like elements with non-block-level elements.
2058
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2059
+ self.set_text_indent(text_indent);
2060
+ self
2061
+ }
2062
+
2063
+ /// The text alignment.
2064
+ pub fn text_align(&self) -> Option<TextAlign> {
2065
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2066
+ }
2067
+
2068
+ /// Set the text alignment.
2069
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2070
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2071
+ }
2072
+
2073
+ /// Set the text alignment.
2074
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2075
+ self.set_text_align(text_align);
2076
+ self
2077
+ }
2078
+ }
2079
+
2080
+ impl From<Tag<kind::Hn>> for TagKind {
2081
+ fn from(value: Tag<kind::Hn>) -> Self {
2082
+ Self::Hn(value)
2083
+ }
2084
+ }
2085
+ impl Tag<kind::Hn> {
2086
+ /// Heading level `n`, including an optional title of the heading.
2087
+ ///
2088
+ /// The title is required for some export modes, like for example PDF/UA.
2089
+ #[allow(non_snake_case)]
2090
+ pub fn Hn(level: NonZeroU16, title: Option<String>) -> Tag<kind::Hn> {
2091
+ let mut tag = Tag::new();
2092
+ tag.set_level(level);
2093
+ tag.set_title(title);
2094
+ tag
2095
+ }
2096
+
2097
+ /// The heading level
2098
+ pub fn level(&self) -> NonZeroU16 {
2099
+ self.inner.get_struct(StructAttr::HEADING_LEVEL).unwrap().unwrap_level()
2100
+ }
2101
+
2102
+ /// Set the heading level
2103
+ pub fn set_level(&mut self, level: NonZeroU16) {
2104
+ self.inner.set_struct(StructAttr::HeadingLevel(level));
2105
+ }
2106
+
2107
+ /// Set the heading level
2108
+ pub fn with_level(mut self, level: NonZeroU16) -> Self {
2109
+ self.set_level(level);
2110
+ self
2111
+ }
2112
+
2113
+ /// The title, characterizing a specific tag such as `"Chapter 1"`.
2114
+ pub fn title(&self) -> Option<&str> {
2115
+ self.inner.get_struct(StructAttr::TITLE).map(StructAttr::unwrap_title)
2116
+ }
2117
+
2118
+ /// Set the title, characterizing a specific tag such as `"Chapter 1"`.
2119
+ pub fn set_title(&mut self, title: Option<String>) {
2120
+ self.inner.set_or_remove_struct(StructAttr::TITLE, title.map(StructAttr::Title));
2121
+ }
2122
+
2123
+ /// Set the title, characterizing a specific tag such as `"Chapter 1"`.
2124
+ pub fn with_title(mut self, title: Option<String>) -> Self {
2125
+ self.set_title(title);
2126
+ self
2127
+ }
2128
+
2129
+ /// The spacing before the block-level element.
2130
+ pub fn space_before(&self) -> Option<f32> {
2131
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2132
+ }
2133
+
2134
+ /// Set the spacing before the block-level element.
2135
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2136
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2137
+ }
2138
+
2139
+ /// Set the spacing before the block-level element.
2140
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2141
+ self.set_space_before(space_before);
2142
+ self
2143
+ }
2144
+
2145
+ /// The spacing after the block-level element.
2146
+ pub fn space_after(&self) -> Option<f32> {
2147
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2148
+ }
2149
+
2150
+ /// Set the spacing after the block-level element.
2151
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2152
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2153
+ }
2154
+
2155
+ /// Set the spacing after the block-level element.
2156
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2157
+ self.set_space_after(space_after);
2158
+ self
2159
+ }
2160
+
2161
+ /// The spacing between the start inline edge of the element and the parent.
2162
+ pub fn start_indent(&self) -> Option<f32> {
2163
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2164
+ }
2165
+
2166
+ /// Set the spacing between the start inline edge of the element and the parent.
2167
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2168
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2169
+ }
2170
+
2171
+ /// Set the spacing between the start inline edge of the element and the parent.
2172
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2173
+ self.set_start_indent(start_indent);
2174
+ self
2175
+ }
2176
+
2177
+ /// The spacing between the end inline edge of the element and the parent.
2178
+ pub fn end_indent(&self) -> Option<f32> {
2179
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2180
+ }
2181
+
2182
+ /// Set the spacing between the end inline edge of the element and the parent.
2183
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2184
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2185
+ }
2186
+
2187
+ /// Set the spacing between the end inline edge of the element and the parent.
2188
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2189
+ self.set_end_indent(end_indent);
2190
+ self
2191
+ }
2192
+
2193
+ /// The amount the first line of text in a block-level element is indented. Only
2194
+ /// applicable to paragraph-like elements with non-block-level elements.
2195
+ pub fn text_indent(&self) -> Option<f32> {
2196
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2197
+ }
2198
+
2199
+ /// Set the amount the first line of text in a block-level element is indented. Only
2200
+ /// applicable to paragraph-like elements with non-block-level elements.
2201
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2202
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2203
+ }
2204
+
2205
+ /// Set the amount the first line of text in a block-level element is indented. Only
2206
+ /// applicable to paragraph-like elements with non-block-level elements.
2207
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2208
+ self.set_text_indent(text_indent);
2209
+ self
2210
+ }
2211
+
2212
+ /// The text alignment.
2213
+ pub fn text_align(&self) -> Option<TextAlign> {
2214
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2215
+ }
2216
+
2217
+ /// Set the text alignment.
2218
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2219
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2220
+ }
2221
+
2222
+ /// Set the text alignment.
2223
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2224
+ self.set_text_align(text_align);
2225
+ self
2226
+ }
2227
+ }
2228
+
2229
+ impl From<Tag<kind::L>> for TagKind {
2230
+ fn from(value: Tag<kind::L>) -> Self {
2231
+ Self::L(value)
2232
+ }
2233
+ }
2234
+ impl Tag<kind::L> {
2235
+ /// A list.
2236
+ ///
2237
+ /// **Best practice**: Should consist of an optional caption followed by
2238
+ /// list items.
2239
+ /// List numbering is only required for PDF/UA, but we just enforce it for always.
2240
+ #[allow(non_snake_case)]
2241
+ pub fn L(numbering: ListNumbering) -> Tag<kind::L> {
2242
+ let mut tag = Tag::new();
2243
+ tag.set_numbering(numbering);
2244
+ tag
2245
+ }
2246
+
2247
+ /// The list numbering.
2248
+ pub fn numbering(&self) -> ListNumbering {
2249
+ self.inner.get_list(ListAttr::NUMBERING).unwrap().unwrap_numbering()
2250
+ }
2251
+
2252
+ /// Set the list numbering.
2253
+ pub fn set_numbering(&mut self, numbering: ListNumbering) {
2254
+ self.inner.set_list(ListAttr::Numbering(numbering));
2255
+ }
2256
+
2257
+ /// Set the list numbering.
2258
+ pub fn with_numbering(mut self, numbering: ListNumbering) -> Self {
2259
+ self.set_numbering(numbering);
2260
+ self
2261
+ }
2262
+
2263
+ /// The spacing before the block-level element.
2264
+ pub fn space_before(&self) -> Option<f32> {
2265
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2266
+ }
2267
+
2268
+ /// Set the spacing before the block-level element.
2269
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2270
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2271
+ }
2272
+
2273
+ /// Set the spacing before the block-level element.
2274
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2275
+ self.set_space_before(space_before);
2276
+ self
2277
+ }
2278
+
2279
+ /// The spacing after the block-level element.
2280
+ pub fn space_after(&self) -> Option<f32> {
2281
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2282
+ }
2283
+
2284
+ /// Set the spacing after the block-level element.
2285
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2286
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2287
+ }
2288
+
2289
+ /// Set the spacing after the block-level element.
2290
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2291
+ self.set_space_after(space_after);
2292
+ self
2293
+ }
2294
+
2295
+ /// The spacing between the start inline edge of the element and the parent.
2296
+ pub fn start_indent(&self) -> Option<f32> {
2297
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2298
+ }
2299
+
2300
+ /// Set the spacing between the start inline edge of the element and the parent.
2301
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2302
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2303
+ }
2304
+
2305
+ /// Set the spacing between the start inline edge of the element and the parent.
2306
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2307
+ self.set_start_indent(start_indent);
2308
+ self
2309
+ }
2310
+
2311
+ /// The spacing between the end inline edge of the element and the parent.
2312
+ pub fn end_indent(&self) -> Option<f32> {
2313
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2314
+ }
2315
+
2316
+ /// Set the spacing between the end inline edge of the element and the parent.
2317
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2318
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2319
+ }
2320
+
2321
+ /// Set the spacing between the end inline edge of the element and the parent.
2322
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2323
+ self.set_end_indent(end_indent);
2324
+ self
2325
+ }
2326
+
2327
+ /// The amount the first line of text in a block-level element is indented. Only
2328
+ /// applicable to paragraph-like elements with non-block-level elements.
2329
+ pub fn text_indent(&self) -> Option<f32> {
2330
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2331
+ }
2332
+
2333
+ /// Set the amount the first line of text in a block-level element is indented. Only
2334
+ /// applicable to paragraph-like elements with non-block-level elements.
2335
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2336
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2337
+ }
2338
+
2339
+ /// Set the amount the first line of text in a block-level element is indented. Only
2340
+ /// applicable to paragraph-like elements with non-block-level elements.
2341
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2342
+ self.set_text_indent(text_indent);
2343
+ self
2344
+ }
2345
+
2346
+ /// The text alignment.
2347
+ pub fn text_align(&self) -> Option<TextAlign> {
2348
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2349
+ }
2350
+
2351
+ /// Set the text alignment.
2352
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2353
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2354
+ }
2355
+
2356
+ /// Set the text alignment.
2357
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2358
+ self.set_text_align(text_align);
2359
+ self
2360
+ }
2361
+ }
2362
+
2363
+ impl From<Tag<kind::LI>> for TagKind {
2364
+ fn from(value: Tag<kind::LI>) -> Self {
2365
+ Self::LI(value)
2366
+ }
2367
+ }
2368
+ impl Tag<kind::LI> {
2369
+ /// A list item.
2370
+ ///
2371
+ /// **Best practice**: Should consist of one or more list labels and/or list bodies.
2372
+ #[allow(non_upper_case_globals)]
2373
+ pub const LI: Tag<kind::LI> = Tag::new();
2374
+
2375
+ /// The spacing before the block-level element.
2376
+ pub fn space_before(&self) -> Option<f32> {
2377
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2378
+ }
2379
+
2380
+ /// Set the spacing before the block-level element.
2381
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2382
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2383
+ }
2384
+
2385
+ /// Set the spacing before the block-level element.
2386
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2387
+ self.set_space_before(space_before);
2388
+ self
2389
+ }
2390
+
2391
+ /// The spacing after the block-level element.
2392
+ pub fn space_after(&self) -> Option<f32> {
2393
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2394
+ }
2395
+
2396
+ /// Set the spacing after the block-level element.
2397
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2398
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2399
+ }
2400
+
2401
+ /// Set the spacing after the block-level element.
2402
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2403
+ self.set_space_after(space_after);
2404
+ self
2405
+ }
2406
+
2407
+ /// The spacing between the start inline edge of the element and the parent.
2408
+ pub fn start_indent(&self) -> Option<f32> {
2409
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2410
+ }
2411
+
2412
+ /// Set the spacing between the start inline edge of the element and the parent.
2413
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2414
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2415
+ }
2416
+
2417
+ /// Set the spacing between the start inline edge of the element and the parent.
2418
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2419
+ self.set_start_indent(start_indent);
2420
+ self
2421
+ }
2422
+
2423
+ /// The spacing between the end inline edge of the element and the parent.
2424
+ pub fn end_indent(&self) -> Option<f32> {
2425
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2426
+ }
2427
+
2428
+ /// Set the spacing between the end inline edge of the element and the parent.
2429
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2430
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2431
+ }
2432
+
2433
+ /// Set the spacing between the end inline edge of the element and the parent.
2434
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2435
+ self.set_end_indent(end_indent);
2436
+ self
2437
+ }
2438
+
2439
+ /// The amount the first line of text in a block-level element is indented. Only
2440
+ /// applicable to paragraph-like elements with non-block-level elements.
2441
+ pub fn text_indent(&self) -> Option<f32> {
2442
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2443
+ }
2444
+
2445
+ /// Set the amount the first line of text in a block-level element is indented. Only
2446
+ /// applicable to paragraph-like elements with non-block-level elements.
2447
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2448
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2449
+ }
2450
+
2451
+ /// Set the amount the first line of text in a block-level element is indented. Only
2452
+ /// applicable to paragraph-like elements with non-block-level elements.
2453
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2454
+ self.set_text_indent(text_indent);
2455
+ self
2456
+ }
2457
+
2458
+ /// The text alignment.
2459
+ pub fn text_align(&self) -> Option<TextAlign> {
2460
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2461
+ }
2462
+
2463
+ /// Set the text alignment.
2464
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2465
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2466
+ }
2467
+
2468
+ /// Set the text alignment.
2469
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2470
+ self.set_text_align(text_align);
2471
+ self
2472
+ }
2473
+ }
2474
+
2475
+ impl From<Tag<kind::Lbl>> for TagKind {
2476
+ fn from(value: Tag<kind::Lbl>) -> Self {
2477
+ Self::Lbl(value)
2478
+ }
2479
+ }
2480
+ impl Tag<kind::Lbl> {
2481
+ /// Label for a list item.
2482
+ #[allow(non_upper_case_globals)]
2483
+ pub const Lbl: Tag<kind::Lbl> = Tag::new();
2484
+
2485
+ /// The spacing before the block-level element.
2486
+ pub fn space_before(&self) -> Option<f32> {
2487
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2488
+ }
2489
+
2490
+ /// Set the spacing before the block-level element.
2491
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2492
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2493
+ }
2494
+
2495
+ /// Set the spacing before the block-level element.
2496
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2497
+ self.set_space_before(space_before);
2498
+ self
2499
+ }
2500
+
2501
+ /// The spacing after the block-level element.
2502
+ pub fn space_after(&self) -> Option<f32> {
2503
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2504
+ }
2505
+
2506
+ /// Set the spacing after the block-level element.
2507
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2508
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2509
+ }
2510
+
2511
+ /// Set the spacing after the block-level element.
2512
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2513
+ self.set_space_after(space_after);
2514
+ self
2515
+ }
2516
+
2517
+ /// The spacing between the start inline edge of the element and the parent.
2518
+ pub fn start_indent(&self) -> Option<f32> {
2519
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2520
+ }
2521
+
2522
+ /// Set the spacing between the start inline edge of the element and the parent.
2523
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2524
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2525
+ }
2526
+
2527
+ /// Set the spacing between the start inline edge of the element and the parent.
2528
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2529
+ self.set_start_indent(start_indent);
2530
+ self
2531
+ }
2532
+
2533
+ /// The spacing between the end inline edge of the element and the parent.
2534
+ pub fn end_indent(&self) -> Option<f32> {
2535
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2536
+ }
2537
+
2538
+ /// Set the spacing between the end inline edge of the element and the parent.
2539
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2540
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2541
+ }
2542
+
2543
+ /// Set the spacing between the end inline edge of the element and the parent.
2544
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2545
+ self.set_end_indent(end_indent);
2546
+ self
2547
+ }
2548
+
2549
+ /// The amount the first line of text in a block-level element is indented. Only
2550
+ /// applicable to paragraph-like elements with non-block-level elements.
2551
+ pub fn text_indent(&self) -> Option<f32> {
2552
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2553
+ }
2554
+
2555
+ /// Set the amount the first line of text in a block-level element is indented. Only
2556
+ /// applicable to paragraph-like elements with non-block-level elements.
2557
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2558
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2559
+ }
2560
+
2561
+ /// Set the amount the first line of text in a block-level element is indented. Only
2562
+ /// applicable to paragraph-like elements with non-block-level elements.
2563
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2564
+ self.set_text_indent(text_indent);
2565
+ self
2566
+ }
2567
+
2568
+ /// The text alignment.
2569
+ pub fn text_align(&self) -> Option<TextAlign> {
2570
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2571
+ }
2572
+
2573
+ /// Set the text alignment.
2574
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2575
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2576
+ }
2577
+
2578
+ /// Set the text alignment.
2579
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2580
+ self.set_text_align(text_align);
2581
+ self
2582
+ }
2583
+ }
2584
+
2585
+ impl From<Tag<kind::LBody>> for TagKind {
2586
+ fn from(value: Tag<kind::LBody>) -> Self {
2587
+ Self::LBody(value)
2588
+ }
2589
+ }
2590
+ impl Tag<kind::LBody> {
2591
+ /// Description of the list item.
2592
+ #[allow(non_upper_case_globals)]
2593
+ pub const LBody: Tag<kind::LBody> = Tag::new();
2594
+
2595
+ /// The spacing before the block-level element.
2596
+ pub fn space_before(&self) -> Option<f32> {
2597
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2598
+ }
2599
+
2600
+ /// Set the spacing before the block-level element.
2601
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2602
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2603
+ }
2604
+
2605
+ /// Set the spacing before the block-level element.
2606
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2607
+ self.set_space_before(space_before);
2608
+ self
2609
+ }
2610
+
2611
+ /// The spacing after the block-level element.
2612
+ pub fn space_after(&self) -> Option<f32> {
2613
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2614
+ }
2615
+
2616
+ /// Set the spacing after the block-level element.
2617
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2618
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2619
+ }
2620
+
2621
+ /// Set the spacing after the block-level element.
2622
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2623
+ self.set_space_after(space_after);
2624
+ self
2625
+ }
2626
+
2627
+ /// The spacing between the start inline edge of the element and the parent.
2628
+ pub fn start_indent(&self) -> Option<f32> {
2629
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2630
+ }
2631
+
2632
+ /// Set the spacing between the start inline edge of the element and the parent.
2633
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2634
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2635
+ }
2636
+
2637
+ /// Set the spacing between the start inline edge of the element and the parent.
2638
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2639
+ self.set_start_indent(start_indent);
2640
+ self
2641
+ }
2642
+
2643
+ /// The spacing between the end inline edge of the element and the parent.
2644
+ pub fn end_indent(&self) -> Option<f32> {
2645
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2646
+ }
2647
+
2648
+ /// Set the spacing between the end inline edge of the element and the parent.
2649
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2650
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2651
+ }
2652
+
2653
+ /// Set the spacing between the end inline edge of the element and the parent.
2654
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2655
+ self.set_end_indent(end_indent);
2656
+ self
2657
+ }
2658
+
2659
+ /// The amount the first line of text in a block-level element is indented. Only
2660
+ /// applicable to paragraph-like elements with non-block-level elements.
2661
+ pub fn text_indent(&self) -> Option<f32> {
2662
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2663
+ }
2664
+
2665
+ /// Set the amount the first line of text in a block-level element is indented. Only
2666
+ /// applicable to paragraph-like elements with non-block-level elements.
2667
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2668
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2669
+ }
2670
+
2671
+ /// Set the amount the first line of text in a block-level element is indented. Only
2672
+ /// applicable to paragraph-like elements with non-block-level elements.
2673
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2674
+ self.set_text_indent(text_indent);
2675
+ self
2676
+ }
2677
+
2678
+ /// The text alignment.
2679
+ pub fn text_align(&self) -> Option<TextAlign> {
2680
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2681
+ }
2682
+
2683
+ /// Set the text alignment.
2684
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2685
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2686
+ }
2687
+
2688
+ /// Set the text alignment.
2689
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2690
+ self.set_text_align(text_align);
2691
+ self
2692
+ }
2693
+ }
2694
+
2695
+ impl From<Tag<kind::Table>> for TagKind {
2696
+ fn from(value: Tag<kind::Table>) -> Self {
2697
+ Self::Table(value)
2698
+ }
2699
+ }
2700
+ impl Tag<kind::Table> {
2701
+ /// A table, with an optional summary describing the purpose and structure.
2702
+ ///
2703
+ /// **Best practice**: Should consist of an optional table header row,
2704
+ /// one or more table body elements and an optional table footer. Can have
2705
+ /// caption as the first or last child.
2706
+ #[allow(non_upper_case_globals)]
2707
+ pub const Table: Tag<kind::Table> = Tag::new();
2708
+
2709
+ /// The table summary.
2710
+ pub fn summary(&self) -> Option<&str> {
2711
+ self.inner.get_table(TableAttr::SUMMARY).map(TableAttr::unwrap_summary)
2712
+ }
2713
+
2714
+ /// Set the table summary.
2715
+ pub fn set_summary(&mut self, summary: Option<String>) {
2716
+ self.inner.set_or_remove_table(TableAttr::SUMMARY, summary.map(TableAttr::Summary));
2717
+ }
2718
+
2719
+ /// Set the table summary.
2720
+ pub fn with_summary(mut self, summary: Option<String>) -> Self {
2721
+ self.set_summary(summary);
2722
+ self
2723
+ }
2724
+
2725
+ /// The bounding box of a tag that encloses its visible content.
2726
+ /// If the content spans multiple pages, this should be omitted.
2727
+ pub fn bbox(&self) -> Option<BBox> {
2728
+ self.inner.get_layout(LayoutAttr::B_BOX).map(LayoutAttr::unwrap_bbox)
2729
+ }
2730
+
2731
+ /// Set the bounding box of a tag that encloses its visible content.
2732
+ /// If the content spans multiple pages, this should be omitted.
2733
+ pub fn set_bbox(&mut self, bbox: Option<BBox>) {
2734
+ self.inner.set_or_remove_layout(LayoutAttr::B_BOX, bbox.map(LayoutAttr::BBox));
2735
+ }
2736
+
2737
+ /// Set the bounding box of a tag that encloses its visible content.
2738
+ /// If the content spans multiple pages, this should be omitted.
2739
+ pub fn with_bbox(mut self, bbox: Option<BBox>) -> Self {
2740
+ self.set_bbox(bbox);
2741
+ self
2742
+ }
2743
+
2744
+ /// The width.
2745
+ pub fn width(&self) -> Option<f32> {
2746
+ self.inner.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
2747
+ }
2748
+
2749
+ /// Set the width.
2750
+ pub fn set_width(&mut self, width: Option<f32>) {
2751
+ self.inner.set_or_remove_layout(LayoutAttr::WIDTH, width.map(LayoutAttr::Width));
2752
+ }
2753
+
2754
+ /// Set the width.
2755
+ pub fn with_width(mut self, width: Option<f32>) -> Self {
2756
+ self.set_width(width);
2757
+ self
2758
+ }
2759
+
2760
+ /// The height.
2761
+ pub fn height(&self) -> Option<f32> {
2762
+ self.inner.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
2763
+ }
2764
+
2765
+ /// Set the height.
2766
+ pub fn set_height(&mut self, height: Option<f32>) {
2767
+ self.inner.set_or_remove_layout(LayoutAttr::HEIGHT, height.map(LayoutAttr::Height));
2768
+ }
2769
+
2770
+ /// Set the height.
2771
+ pub fn with_height(mut self, height: Option<f32>) -> Self {
2772
+ self.set_height(height);
2773
+ self
2774
+ }
2775
+
2776
+ /// The spacing before the block-level element.
2777
+ pub fn space_before(&self) -> Option<f32> {
2778
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
2779
+ }
2780
+
2781
+ /// Set the spacing before the block-level element.
2782
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
2783
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
2784
+ }
2785
+
2786
+ /// Set the spacing before the block-level element.
2787
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
2788
+ self.set_space_before(space_before);
2789
+ self
2790
+ }
2791
+
2792
+ /// The spacing after the block-level element.
2793
+ pub fn space_after(&self) -> Option<f32> {
2794
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
2795
+ }
2796
+
2797
+ /// Set the spacing after the block-level element.
2798
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
2799
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
2800
+ }
2801
+
2802
+ /// Set the spacing after the block-level element.
2803
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
2804
+ self.set_space_after(space_after);
2805
+ self
2806
+ }
2807
+
2808
+ /// The spacing between the start inline edge of the element and the parent.
2809
+ pub fn start_indent(&self) -> Option<f32> {
2810
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
2811
+ }
2812
+
2813
+ /// Set the spacing between the start inline edge of the element and the parent.
2814
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
2815
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
2816
+ }
2817
+
2818
+ /// Set the spacing between the start inline edge of the element and the parent.
2819
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
2820
+ self.set_start_indent(start_indent);
2821
+ self
2822
+ }
2823
+
2824
+ /// The spacing between the end inline edge of the element and the parent.
2825
+ pub fn end_indent(&self) -> Option<f32> {
2826
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
2827
+ }
2828
+
2829
+ /// Set the spacing between the end inline edge of the element and the parent.
2830
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
2831
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
2832
+ }
2833
+
2834
+ /// Set the spacing between the end inline edge of the element and the parent.
2835
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
2836
+ self.set_end_indent(end_indent);
2837
+ self
2838
+ }
2839
+
2840
+ /// The amount the first line of text in a block-level element is indented. Only
2841
+ /// applicable to paragraph-like elements with non-block-level elements.
2842
+ pub fn text_indent(&self) -> Option<f32> {
2843
+ self.inner.get_layout(LayoutAttr::TEXT_INDENT).map(LayoutAttr::unwrap_text_indent)
2844
+ }
2845
+
2846
+ /// Set the amount the first line of text in a block-level element is indented. Only
2847
+ /// applicable to paragraph-like elements with non-block-level elements.
2848
+ pub fn set_text_indent(&mut self, text_indent: Option<f32>) {
2849
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_INDENT, text_indent.map(LayoutAttr::TextIndent));
2850
+ }
2851
+
2852
+ /// Set the amount the first line of text in a block-level element is indented. Only
2853
+ /// applicable to paragraph-like elements with non-block-level elements.
2854
+ pub fn with_text_indent(mut self, text_indent: Option<f32>) -> Self {
2855
+ self.set_text_indent(text_indent);
2856
+ self
2857
+ }
2858
+
2859
+ /// The text alignment.
2860
+ pub fn text_align(&self) -> Option<TextAlign> {
2861
+ self.inner.get_layout(LayoutAttr::TEXT_ALIGN).map(LayoutAttr::unwrap_text_align)
2862
+ }
2863
+
2864
+ /// Set the text alignment.
2865
+ pub fn set_text_align(&mut self, text_align: Option<TextAlign>) {
2866
+ self.inner.set_or_remove_layout(LayoutAttr::TEXT_ALIGN, text_align.map(LayoutAttr::TextAlign));
2867
+ }
2868
+
2869
+ /// Set the text alignment.
2870
+ pub fn with_text_align(mut self, text_align: Option<TextAlign>) -> Self {
2871
+ self.set_text_align(text_align);
2872
+ self
2873
+ }
2874
+ }
2875
+
2876
+ impl From<Tag<kind::TR>> for TagKind {
2877
+ fn from(value: Tag<kind::TR>) -> Self {
2878
+ Self::TR(value)
2879
+ }
2880
+ }
2881
+ impl Tag<kind::TR> {
2882
+ /// A table row.
2883
+ ///
2884
+ /// **Best practice**: May contain table headers cells and table data cells.
2885
+ #[allow(non_upper_case_globals)]
2886
+ pub const TR: Tag<kind::TR> = Tag::new();
2887
+ }
2888
+
2889
+ impl From<Tag<kind::TH>> for TagKind {
2890
+ fn from(value: Tag<kind::TH>) -> Self {
2891
+ Self::TH(value)
2892
+ }
2893
+ }
2894
+ impl Tag<kind::TH> {
2895
+ /// A table header cell.
2896
+ #[allow(non_snake_case)]
2897
+ pub fn TH(scope: TableHeaderScope) -> Tag<kind::TH> {
2898
+ let mut tag = Tag::new();
2899
+ tag.set_scope(scope);
2900
+ tag
2901
+ }
2902
+
2903
+ /// The table header scope.
2904
+ pub fn scope(&self) -> TableHeaderScope {
2905
+ self.inner.get_table(TableAttr::HEADER_SCOPE).unwrap().unwrap_scope()
2906
+ }
2907
+
2908
+ /// Set the table header scope.
2909
+ pub fn set_scope(&mut self, scope: TableHeaderScope) {
2910
+ self.inner.set_table(TableAttr::HeaderScope(scope));
2911
+ }
2912
+
2913
+ /// Set the table header scope.
2914
+ pub fn with_scope(mut self, scope: TableHeaderScope) -> Self {
2915
+ self.set_scope(scope);
2916
+ self
2917
+ }
2918
+
2919
+ /// The list of headers associated with a table cell.
2920
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
2921
+ /// which can also specify a list of parent header cells (`TH`), and so on.
2922
+ /// To determine the list of associated headers this list is recursively
2923
+ /// evaluated.
2924
+ ///
2925
+ /// This allows specifying header hierarchies inside tables.
2926
+ pub fn headers(&self) -> Option<&[TagId]> {
2927
+ self.inner.get_table(TableAttr::CELL_HEADERS).map(TableAttr::unwrap_headers)
2928
+ }
2929
+
2930
+ /// Set the list of headers associated with a table cell.
2931
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
2932
+ /// which can also specify a list of parent header cells (`TH`), and so on.
2933
+ /// To determine the list of associated headers this list is recursively
2934
+ /// evaluated.
2935
+ ///
2936
+ /// This allows specifying header hierarchies inside tables.
2937
+ pub fn set_headers(&mut self, headers: Option<impl IntoIterator<Item = TagId>>) {
2938
+ self.inner.set_or_remove_table(TableAttr::CELL_HEADERS, headers.map(|ids| ids.into_iter().collect()).map(TableAttr::CellHeaders));
2939
+ }
2940
+
2941
+ /// Set the list of headers associated with a table cell.
2942
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
2943
+ /// which can also specify a list of parent header cells (`TH`), and so on.
2944
+ /// To determine the list of associated headers this list is recursively
2945
+ /// evaluated.
2946
+ ///
2947
+ /// This allows specifying header hierarchies inside tables.
2948
+ pub fn with_headers(mut self, headers: Option<impl IntoIterator<Item = TagId>>) -> Self {
2949
+ self.set_headers(headers);
2950
+ self
2951
+ }
2952
+
2953
+ /// The row span of this table cell.
2954
+ pub fn row_span(&self) -> Option<NonZeroU32> {
2955
+ self.inner.get_table(TableAttr::ROW_SPAN).map(TableAttr::unwrap_row_span)
2956
+ }
2957
+
2958
+ /// Set the row span of this table cell.
2959
+ pub fn set_row_span(&mut self, row_span: Option<NonZeroU32>) {
2960
+ self.inner.set_or_remove_table(TableAttr::ROW_SPAN, row_span.map(TableAttr::RowSpan));
2961
+ }
2962
+
2963
+ /// Set the row span of this table cell.
2964
+ pub fn with_row_span(mut self, row_span: Option<NonZeroU32>) -> Self {
2965
+ self.set_row_span(row_span);
2966
+ self
2967
+ }
2968
+
2969
+ /// The column span of this table cell.
2970
+ pub fn col_span(&self) -> Option<NonZeroU32> {
2971
+ self.inner.get_table(TableAttr::COL_SPAN).map(TableAttr::unwrap_col_span)
2972
+ }
2973
+
2974
+ /// Set the column span of this table cell.
2975
+ pub fn set_col_span(&mut self, col_span: Option<NonZeroU32>) {
2976
+ self.inner.set_or_remove_table(TableAttr::COL_SPAN, col_span.map(TableAttr::ColSpan));
2977
+ }
2978
+
2979
+ /// Set the column span of this table cell.
2980
+ pub fn with_col_span(mut self, col_span: Option<NonZeroU32>) -> Self {
2981
+ self.set_col_span(col_span);
2982
+ self
2983
+ }
2984
+
2985
+ /// The width.
2986
+ pub fn width(&self) -> Option<f32> {
2987
+ self.inner.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
2988
+ }
2989
+
2990
+ /// Set the width.
2991
+ pub fn set_width(&mut self, width: Option<f32>) {
2992
+ self.inner.set_or_remove_layout(LayoutAttr::WIDTH, width.map(LayoutAttr::Width));
2993
+ }
2994
+
2995
+ /// Set the width.
2996
+ pub fn with_width(mut self, width: Option<f32>) -> Self {
2997
+ self.set_width(width);
2998
+ self
2999
+ }
3000
+
3001
+ /// The height.
3002
+ pub fn height(&self) -> Option<f32> {
3003
+ self.inner.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
3004
+ }
3005
+
3006
+ /// Set the height.
3007
+ pub fn set_height(&mut self, height: Option<f32>) {
3008
+ self.inner.set_or_remove_layout(LayoutAttr::HEIGHT, height.map(LayoutAttr::Height));
3009
+ }
3010
+
3011
+ /// Set the height.
3012
+ pub fn with_height(mut self, height: Option<f32>) -> Self {
3013
+ self.set_height(height);
3014
+ self
3015
+ }
3016
+
3017
+ /// The border style of table cells, overriding `BorderStyle`.
3018
+ pub fn table_border_style(&self) -> Option<Sides<BorderStyle>> {
3019
+ self.inner.get_layout(LayoutAttr::TABLE_BORDER_STYLE).map(LayoutAttr::unwrap_table_border_style)
3020
+ }
3021
+
3022
+ /// Set the border style of table cells, overriding `BorderStyle`.
3023
+ pub fn set_table_border_style(&mut self, table_border_style: Option<Sides<BorderStyle>>) {
3024
+ self.inner.set_or_remove_layout(LayoutAttr::TABLE_BORDER_STYLE, table_border_style.map(LayoutAttr::TableBorderStyle));
3025
+ }
3026
+
3027
+ /// Set the border style of table cells, overriding `BorderStyle`.
3028
+ pub fn with_table_border_style(mut self, table_border_style: Option<Sides<BorderStyle>>) -> Self {
3029
+ self.set_table_border_style(table_border_style);
3030
+ self
3031
+ }
3032
+
3033
+ /// The padding inside of table cells, overriding `Padding`.
3034
+ pub fn table_padding(&self) -> Option<Sides<f32>> {
3035
+ self.inner.get_layout(LayoutAttr::TABLE_PADDING).map(LayoutAttr::unwrap_table_padding)
3036
+ }
3037
+
3038
+ /// Set the padding inside of table cells, overriding `Padding`.
3039
+ pub fn set_table_padding(&mut self, table_padding: Option<Sides<f32>>) {
3040
+ self.inner.set_or_remove_layout(LayoutAttr::TABLE_PADDING, table_padding.map(LayoutAttr::TablePadding));
3041
+ }
3042
+
3043
+ /// Set the padding inside of table cells, overriding `Padding`.
3044
+ pub fn with_table_padding(mut self, table_padding: Option<Sides<f32>>) -> Self {
3045
+ self.set_table_padding(table_padding);
3046
+ self
3047
+ }
3048
+
3049
+ /// The alignment of block-level elements inside of this block-level element.
3050
+ pub fn block_align(&self) -> Option<BlockAlign> {
3051
+ self.inner.get_layout(LayoutAttr::BLOCK_ALIGN).map(LayoutAttr::unwrap_block_align)
3052
+ }
3053
+
3054
+ /// Set the alignment of block-level elements inside of this block-level element.
3055
+ pub fn set_block_align(&mut self, block_align: Option<BlockAlign>) {
3056
+ self.inner.set_or_remove_layout(LayoutAttr::BLOCK_ALIGN, block_align.map(LayoutAttr::BlockAlign));
3057
+ }
3058
+
3059
+ /// Set the alignment of block-level elements inside of this block-level element.
3060
+ pub fn with_block_align(mut self, block_align: Option<BlockAlign>) -> Self {
3061
+ self.set_block_align(block_align);
3062
+ self
3063
+ }
3064
+
3065
+ /// The alignment of inline-level elements inside of this block-level element.
3066
+ pub fn inline_align(&self) -> Option<InlineAlign> {
3067
+ self.inner.get_layout(LayoutAttr::INLINE_ALIGN).map(LayoutAttr::unwrap_inline_align)
3068
+ }
3069
+
3070
+ /// Set the alignment of inline-level elements inside of this block-level element.
3071
+ pub fn set_inline_align(&mut self, inline_align: Option<InlineAlign>) {
3072
+ self.inner.set_or_remove_layout(LayoutAttr::INLINE_ALIGN, inline_align.map(LayoutAttr::InlineAlign));
3073
+ }
3074
+
3075
+ /// Set the alignment of inline-level elements inside of this block-level element.
3076
+ pub fn with_inline_align(mut self, inline_align: Option<InlineAlign>) -> Self {
3077
+ self.set_inline_align(inline_align);
3078
+ self
3079
+ }
3080
+ }
3081
+
3082
+ impl From<Tag<kind::TD>> for TagKind {
3083
+ fn from(value: Tag<kind::TD>) -> Self {
3084
+ Self::TD(value)
3085
+ }
3086
+ }
3087
+ impl Tag<kind::TD> {
3088
+ /// A table data cell.
3089
+ #[allow(non_upper_case_globals)]
3090
+ pub const TD: Tag<kind::TD> = Tag::new();
3091
+
3092
+ /// The list of headers associated with a table cell.
3093
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
3094
+ /// which can also specify a list of parent header cells (`TH`), and so on.
3095
+ /// To determine the list of associated headers this list is recursively
3096
+ /// evaluated.
3097
+ ///
3098
+ /// This allows specifying header hierarchies inside tables.
3099
+ pub fn headers(&self) -> Option<&[TagId]> {
3100
+ self.inner.get_table(TableAttr::CELL_HEADERS).map(TableAttr::unwrap_headers)
3101
+ }
3102
+
3103
+ /// Set the list of headers associated with a table cell.
3104
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
3105
+ /// which can also specify a list of parent header cells (`TH`), and so on.
3106
+ /// To determine the list of associated headers this list is recursively
3107
+ /// evaluated.
3108
+ ///
3109
+ /// This allows specifying header hierarchies inside tables.
3110
+ pub fn set_headers(&mut self, headers: Option<impl IntoIterator<Item = TagId>>) {
3111
+ self.inner.set_or_remove_table(TableAttr::CELL_HEADERS, headers.map(|ids| ids.into_iter().collect()).map(TableAttr::CellHeaders));
3112
+ }
3113
+
3114
+ /// Set the list of headers associated with a table cell.
3115
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
3116
+ /// which can also specify a list of parent header cells (`TH`), and so on.
3117
+ /// To determine the list of associated headers this list is recursively
3118
+ /// evaluated.
3119
+ ///
3120
+ /// This allows specifying header hierarchies inside tables.
3121
+ pub fn with_headers(mut self, headers: Option<impl IntoIterator<Item = TagId>>) -> Self {
3122
+ self.set_headers(headers);
3123
+ self
3124
+ }
3125
+
3126
+ /// The row span of this table cell.
3127
+ pub fn row_span(&self) -> Option<NonZeroU32> {
3128
+ self.inner.get_table(TableAttr::ROW_SPAN).map(TableAttr::unwrap_row_span)
3129
+ }
3130
+
3131
+ /// Set the row span of this table cell.
3132
+ pub fn set_row_span(&mut self, row_span: Option<NonZeroU32>) {
3133
+ self.inner.set_or_remove_table(TableAttr::ROW_SPAN, row_span.map(TableAttr::RowSpan));
3134
+ }
3135
+
3136
+ /// Set the row span of this table cell.
3137
+ pub fn with_row_span(mut self, row_span: Option<NonZeroU32>) -> Self {
3138
+ self.set_row_span(row_span);
3139
+ self
3140
+ }
3141
+
3142
+ /// The column span of this table cell.
3143
+ pub fn col_span(&self) -> Option<NonZeroU32> {
3144
+ self.inner.get_table(TableAttr::COL_SPAN).map(TableAttr::unwrap_col_span)
3145
+ }
3146
+
3147
+ /// Set the column span of this table cell.
3148
+ pub fn set_col_span(&mut self, col_span: Option<NonZeroU32>) {
3149
+ self.inner.set_or_remove_table(TableAttr::COL_SPAN, col_span.map(TableAttr::ColSpan));
3150
+ }
3151
+
3152
+ /// Set the column span of this table cell.
3153
+ pub fn with_col_span(mut self, col_span: Option<NonZeroU32>) -> Self {
3154
+ self.set_col_span(col_span);
3155
+ self
3156
+ }
3157
+
3158
+ /// The width.
3159
+ pub fn width(&self) -> Option<f32> {
3160
+ self.inner.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
3161
+ }
3162
+
3163
+ /// Set the width.
3164
+ pub fn set_width(&mut self, width: Option<f32>) {
3165
+ self.inner.set_or_remove_layout(LayoutAttr::WIDTH, width.map(LayoutAttr::Width));
3166
+ }
3167
+
3168
+ /// Set the width.
3169
+ pub fn with_width(mut self, width: Option<f32>) -> Self {
3170
+ self.set_width(width);
3171
+ self
3172
+ }
3173
+
3174
+ /// The height.
3175
+ pub fn height(&self) -> Option<f32> {
3176
+ self.inner.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
3177
+ }
3178
+
3179
+ /// Set the height.
3180
+ pub fn set_height(&mut self, height: Option<f32>) {
3181
+ self.inner.set_or_remove_layout(LayoutAttr::HEIGHT, height.map(LayoutAttr::Height));
3182
+ }
3183
+
3184
+ /// Set the height.
3185
+ pub fn with_height(mut self, height: Option<f32>) -> Self {
3186
+ self.set_height(height);
3187
+ self
3188
+ }
3189
+
3190
+ /// The border style of table cells, overriding `BorderStyle`.
3191
+ pub fn table_border_style(&self) -> Option<Sides<BorderStyle>> {
3192
+ self.inner.get_layout(LayoutAttr::TABLE_BORDER_STYLE).map(LayoutAttr::unwrap_table_border_style)
3193
+ }
3194
+
3195
+ /// Set the border style of table cells, overriding `BorderStyle`.
3196
+ pub fn set_table_border_style(&mut self, table_border_style: Option<Sides<BorderStyle>>) {
3197
+ self.inner.set_or_remove_layout(LayoutAttr::TABLE_BORDER_STYLE, table_border_style.map(LayoutAttr::TableBorderStyle));
3198
+ }
3199
+
3200
+ /// Set the border style of table cells, overriding `BorderStyle`.
3201
+ pub fn with_table_border_style(mut self, table_border_style: Option<Sides<BorderStyle>>) -> Self {
3202
+ self.set_table_border_style(table_border_style);
3203
+ self
3204
+ }
3205
+
3206
+ /// The padding inside of table cells, overriding `Padding`.
3207
+ pub fn table_padding(&self) -> Option<Sides<f32>> {
3208
+ self.inner.get_layout(LayoutAttr::TABLE_PADDING).map(LayoutAttr::unwrap_table_padding)
3209
+ }
3210
+
3211
+ /// Set the padding inside of table cells, overriding `Padding`.
3212
+ pub fn set_table_padding(&mut self, table_padding: Option<Sides<f32>>) {
3213
+ self.inner.set_or_remove_layout(LayoutAttr::TABLE_PADDING, table_padding.map(LayoutAttr::TablePadding));
3214
+ }
3215
+
3216
+ /// Set the padding inside of table cells, overriding `Padding`.
3217
+ pub fn with_table_padding(mut self, table_padding: Option<Sides<f32>>) -> Self {
3218
+ self.set_table_padding(table_padding);
3219
+ self
3220
+ }
3221
+
3222
+ /// The alignment of block-level elements inside of this block-level element.
3223
+ pub fn block_align(&self) -> Option<BlockAlign> {
3224
+ self.inner.get_layout(LayoutAttr::BLOCK_ALIGN).map(LayoutAttr::unwrap_block_align)
3225
+ }
3226
+
3227
+ /// Set the alignment of block-level elements inside of this block-level element.
3228
+ pub fn set_block_align(&mut self, block_align: Option<BlockAlign>) {
3229
+ self.inner.set_or_remove_layout(LayoutAttr::BLOCK_ALIGN, block_align.map(LayoutAttr::BlockAlign));
3230
+ }
3231
+
3232
+ /// Set the alignment of block-level elements inside of this block-level element.
3233
+ pub fn with_block_align(mut self, block_align: Option<BlockAlign>) -> Self {
3234
+ self.set_block_align(block_align);
3235
+ self
3236
+ }
3237
+
3238
+ /// The alignment of inline-level elements inside of this block-level element.
3239
+ pub fn inline_align(&self) -> Option<InlineAlign> {
3240
+ self.inner.get_layout(LayoutAttr::INLINE_ALIGN).map(LayoutAttr::unwrap_inline_align)
3241
+ }
3242
+
3243
+ /// Set the alignment of inline-level elements inside of this block-level element.
3244
+ pub fn set_inline_align(&mut self, inline_align: Option<InlineAlign>) {
3245
+ self.inner.set_or_remove_layout(LayoutAttr::INLINE_ALIGN, inline_align.map(LayoutAttr::InlineAlign));
3246
+ }
3247
+
3248
+ /// Set the alignment of inline-level elements inside of this block-level element.
3249
+ pub fn with_inline_align(mut self, inline_align: Option<InlineAlign>) -> Self {
3250
+ self.set_inline_align(inline_align);
3251
+ self
3252
+ }
3253
+ }
3254
+
3255
+ impl From<Tag<kind::THead>> for TagKind {
3256
+ fn from(value: Tag<kind::THead>) -> Self {
3257
+ Self::THead(value)
3258
+ }
3259
+ }
3260
+ impl Tag<kind::THead> {
3261
+ /// A table header row group.
3262
+ #[allow(non_upper_case_globals)]
3263
+ pub const THead: Tag<kind::THead> = Tag::new();
3264
+ }
3265
+
3266
+ impl From<Tag<kind::TBody>> for TagKind {
3267
+ fn from(value: Tag<kind::TBody>) -> Self {
3268
+ Self::TBody(value)
3269
+ }
3270
+ }
3271
+ impl Tag<kind::TBody> {
3272
+ /// A table data row group.
3273
+ #[allow(non_upper_case_globals)]
3274
+ pub const TBody: Tag<kind::TBody> = Tag::new();
3275
+ }
3276
+
3277
+ impl From<Tag<kind::TFoot>> for TagKind {
3278
+ fn from(value: Tag<kind::TFoot>) -> Self {
3279
+ Self::TFoot(value)
3280
+ }
3281
+ }
3282
+ impl Tag<kind::TFoot> {
3283
+ /// A table footer row group.
3284
+ #[allow(non_upper_case_globals)]
3285
+ pub const TFoot: Tag<kind::TFoot> = Tag::new();
3286
+ }
3287
+
3288
+ impl From<Tag<kind::Span>> for TagKind {
3289
+ fn from(value: Tag<kind::Span>) -> Self {
3290
+ Self::Span(value)
3291
+ }
3292
+ }
3293
+ impl Tag<kind::Span> {
3294
+ /// An inline-level element that does not have a specific meaning.
3295
+ #[allow(non_upper_case_globals)]
3296
+ pub const Span: Tag<kind::Span> = Tag::new();
3297
+
3298
+ /// The spacing before the block-level element.
3299
+ pub fn space_before(&self) -> Option<f32> {
3300
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3301
+ }
3302
+
3303
+ /// Set the spacing before the block-level element.
3304
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3305
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3306
+ }
3307
+
3308
+ /// Set the spacing before the block-level element.
3309
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3310
+ self.set_space_before(space_before);
3311
+ self
3312
+ }
3313
+
3314
+ /// The spacing after the block-level element.
3315
+ pub fn space_after(&self) -> Option<f32> {
3316
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3317
+ }
3318
+
3319
+ /// Set the spacing after the block-level element.
3320
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3321
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3322
+ }
3323
+
3324
+ /// Set the spacing after the block-level element.
3325
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3326
+ self.set_space_after(space_after);
3327
+ self
3328
+ }
3329
+
3330
+ /// The spacing between the start inline edge of the element and the parent.
3331
+ pub fn start_indent(&self) -> Option<f32> {
3332
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3333
+ }
3334
+
3335
+ /// Set the spacing between the start inline edge of the element and the parent.
3336
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3337
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3338
+ }
3339
+
3340
+ /// Set the spacing between the start inline edge of the element and the parent.
3341
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3342
+ self.set_start_indent(start_indent);
3343
+ self
3344
+ }
3345
+
3346
+ /// The spacing between the end inline edge of the element and the parent.
3347
+ pub fn end_indent(&self) -> Option<f32> {
3348
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3349
+ }
3350
+
3351
+ /// Set the spacing between the end inline edge of the element and the parent.
3352
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3353
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3354
+ }
3355
+
3356
+ /// Set the spacing between the end inline edge of the element and the parent.
3357
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3358
+ self.set_end_indent(end_indent);
3359
+ self
3360
+ }
3361
+ }
3362
+
3363
+ impl From<Tag<kind::InlineQuote>> for TagKind {
3364
+ fn from(value: Tag<kind::InlineQuote>) -> Self {
3365
+ Self::InlineQuote(value)
3366
+ }
3367
+ }
3368
+ impl Tag<kind::InlineQuote> {
3369
+ /// An inline quotation.
3370
+ #[allow(non_upper_case_globals)]
3371
+ pub const InlineQuote: Tag<kind::InlineQuote> = Tag::new();
3372
+
3373
+ /// The spacing before the block-level element.
3374
+ pub fn space_before(&self) -> Option<f32> {
3375
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3376
+ }
3377
+
3378
+ /// Set the spacing before the block-level element.
3379
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3380
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3381
+ }
3382
+
3383
+ /// Set the spacing before the block-level element.
3384
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3385
+ self.set_space_before(space_before);
3386
+ self
3387
+ }
3388
+
3389
+ /// The spacing after the block-level element.
3390
+ pub fn space_after(&self) -> Option<f32> {
3391
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3392
+ }
3393
+
3394
+ /// Set the spacing after the block-level element.
3395
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3396
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3397
+ }
3398
+
3399
+ /// Set the spacing after the block-level element.
3400
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3401
+ self.set_space_after(space_after);
3402
+ self
3403
+ }
3404
+
3405
+ /// The spacing between the start inline edge of the element and the parent.
3406
+ pub fn start_indent(&self) -> Option<f32> {
3407
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3408
+ }
3409
+
3410
+ /// Set the spacing between the start inline edge of the element and the parent.
3411
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3412
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3413
+ }
3414
+
3415
+ /// Set the spacing between the start inline edge of the element and the parent.
3416
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3417
+ self.set_start_indent(start_indent);
3418
+ self
3419
+ }
3420
+
3421
+ /// The spacing between the end inline edge of the element and the parent.
3422
+ pub fn end_indent(&self) -> Option<f32> {
3423
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3424
+ }
3425
+
3426
+ /// Set the spacing between the end inline edge of the element and the parent.
3427
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3428
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3429
+ }
3430
+
3431
+ /// Set the spacing between the end inline edge of the element and the parent.
3432
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3433
+ self.set_end_indent(end_indent);
3434
+ self
3435
+ }
3436
+ }
3437
+
3438
+ impl From<Tag<kind::Note>> for TagKind {
3439
+ fn from(value: Tag<kind::Note>) -> Self {
3440
+ Self::Note(value)
3441
+ }
3442
+ }
3443
+ impl Tag<kind::Note> {
3444
+ /// A foot- or endnote, potentially referred to from within the text.
3445
+ ///
3446
+ /// **Best practice**: It may have a label as a child.
3447
+ #[allow(non_upper_case_globals)]
3448
+ pub const Note: Tag<kind::Note> = Tag::new();
3449
+
3450
+ /// The spacing before the block-level element.
3451
+ pub fn space_before(&self) -> Option<f32> {
3452
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3453
+ }
3454
+
3455
+ /// Set the spacing before the block-level element.
3456
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3457
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3458
+ }
3459
+
3460
+ /// Set the spacing before the block-level element.
3461
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3462
+ self.set_space_before(space_before);
3463
+ self
3464
+ }
3465
+
3466
+ /// The spacing after the block-level element.
3467
+ pub fn space_after(&self) -> Option<f32> {
3468
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3469
+ }
3470
+
3471
+ /// Set the spacing after the block-level element.
3472
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3473
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3474
+ }
3475
+
3476
+ /// Set the spacing after the block-level element.
3477
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3478
+ self.set_space_after(space_after);
3479
+ self
3480
+ }
3481
+
3482
+ /// The spacing between the start inline edge of the element and the parent.
3483
+ pub fn start_indent(&self) -> Option<f32> {
3484
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3485
+ }
3486
+
3487
+ /// Set the spacing between the start inline edge of the element and the parent.
3488
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3489
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3490
+ }
3491
+
3492
+ /// Set the spacing between the start inline edge of the element and the parent.
3493
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3494
+ self.set_start_indent(start_indent);
3495
+ self
3496
+ }
3497
+
3498
+ /// The spacing between the end inline edge of the element and the parent.
3499
+ pub fn end_indent(&self) -> Option<f32> {
3500
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3501
+ }
3502
+
3503
+ /// Set the spacing between the end inline edge of the element and the parent.
3504
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3505
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3506
+ }
3507
+
3508
+ /// Set the spacing between the end inline edge of the element and the parent.
3509
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3510
+ self.set_end_indent(end_indent);
3511
+ self
3512
+ }
3513
+ }
3514
+
3515
+ impl From<Tag<kind::Reference>> for TagKind {
3516
+ fn from(value: Tag<kind::Reference>) -> Self {
3517
+ Self::Reference(value)
3518
+ }
3519
+ }
3520
+ impl Tag<kind::Reference> {
3521
+ /// A reference to elsewhere in the document.
3522
+ ///
3523
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
3524
+ /// linking to a destination in the document, and the second child should consist of
3525
+ /// the children that should be associated with that reference.
3526
+ #[allow(non_upper_case_globals)]
3527
+ pub const Reference: Tag<kind::Reference> = Tag::new();
3528
+
3529
+ /// The spacing before the block-level element.
3530
+ pub fn space_before(&self) -> Option<f32> {
3531
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3532
+ }
3533
+
3534
+ /// Set the spacing before the block-level element.
3535
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3536
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3537
+ }
3538
+
3539
+ /// Set the spacing before the block-level element.
3540
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3541
+ self.set_space_before(space_before);
3542
+ self
3543
+ }
3544
+
3545
+ /// The spacing after the block-level element.
3546
+ pub fn space_after(&self) -> Option<f32> {
3547
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3548
+ }
3549
+
3550
+ /// Set the spacing after the block-level element.
3551
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3552
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3553
+ }
3554
+
3555
+ /// Set the spacing after the block-level element.
3556
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3557
+ self.set_space_after(space_after);
3558
+ self
3559
+ }
3560
+
3561
+ /// The spacing between the start inline edge of the element and the parent.
3562
+ pub fn start_indent(&self) -> Option<f32> {
3563
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3564
+ }
3565
+
3566
+ /// Set the spacing between the start inline edge of the element and the parent.
3567
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3568
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3569
+ }
3570
+
3571
+ /// Set the spacing between the start inline edge of the element and the parent.
3572
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3573
+ self.set_start_indent(start_indent);
3574
+ self
3575
+ }
3576
+
3577
+ /// The spacing between the end inline edge of the element and the parent.
3578
+ pub fn end_indent(&self) -> Option<f32> {
3579
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3580
+ }
3581
+
3582
+ /// Set the spacing between the end inline edge of the element and the parent.
3583
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3584
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3585
+ }
3586
+
3587
+ /// Set the spacing between the end inline edge of the element and the parent.
3588
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3589
+ self.set_end_indent(end_indent);
3590
+ self
3591
+ }
3592
+ }
3593
+
3594
+ impl From<Tag<kind::BibEntry>> for TagKind {
3595
+ fn from(value: Tag<kind::BibEntry>) -> Self {
3596
+ Self::BibEntry(value)
3597
+ }
3598
+ }
3599
+ impl Tag<kind::BibEntry> {
3600
+ /// A reference to the external source of some cited document.
3601
+ ///
3602
+ /// **Best practice**: It may have a label as a child.
3603
+ #[allow(non_upper_case_globals)]
3604
+ pub const BibEntry: Tag<kind::BibEntry> = Tag::new();
3605
+
3606
+ /// The spacing before the block-level element.
3607
+ pub fn space_before(&self) -> Option<f32> {
3608
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3609
+ }
3610
+
3611
+ /// Set the spacing before the block-level element.
3612
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3613
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3614
+ }
3615
+
3616
+ /// Set the spacing before the block-level element.
3617
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3618
+ self.set_space_before(space_before);
3619
+ self
3620
+ }
3621
+
3622
+ /// The spacing after the block-level element.
3623
+ pub fn space_after(&self) -> Option<f32> {
3624
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3625
+ }
3626
+
3627
+ /// Set the spacing after the block-level element.
3628
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3629
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3630
+ }
3631
+
3632
+ /// Set the spacing after the block-level element.
3633
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3634
+ self.set_space_after(space_after);
3635
+ self
3636
+ }
3637
+
3638
+ /// The spacing between the start inline edge of the element and the parent.
3639
+ pub fn start_indent(&self) -> Option<f32> {
3640
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3641
+ }
3642
+
3643
+ /// Set the spacing between the start inline edge of the element and the parent.
3644
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3645
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3646
+ }
3647
+
3648
+ /// Set the spacing between the start inline edge of the element and the parent.
3649
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3650
+ self.set_start_indent(start_indent);
3651
+ self
3652
+ }
3653
+
3654
+ /// The spacing between the end inline edge of the element and the parent.
3655
+ pub fn end_indent(&self) -> Option<f32> {
3656
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3657
+ }
3658
+
3659
+ /// Set the spacing between the end inline edge of the element and the parent.
3660
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3661
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3662
+ }
3663
+
3664
+ /// Set the spacing between the end inline edge of the element and the parent.
3665
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3666
+ self.set_end_indent(end_indent);
3667
+ self
3668
+ }
3669
+ }
3670
+
3671
+ impl From<Tag<kind::Code>> for TagKind {
3672
+ fn from(value: Tag<kind::Code>) -> Self {
3673
+ Self::Code(value)
3674
+ }
3675
+ }
3676
+ impl Tag<kind::Code> {
3677
+ /// Computer code.
3678
+ #[allow(non_upper_case_globals)]
3679
+ pub const Code: Tag<kind::Code> = Tag::new();
3680
+
3681
+ /// The spacing before the block-level element.
3682
+ pub fn space_before(&self) -> Option<f32> {
3683
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3684
+ }
3685
+
3686
+ /// Set the spacing before the block-level element.
3687
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3688
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3689
+ }
3690
+
3691
+ /// Set the spacing before the block-level element.
3692
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3693
+ self.set_space_before(space_before);
3694
+ self
3695
+ }
3696
+
3697
+ /// The spacing after the block-level element.
3698
+ pub fn space_after(&self) -> Option<f32> {
3699
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3700
+ }
3701
+
3702
+ /// Set the spacing after the block-level element.
3703
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3704
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3705
+ }
3706
+
3707
+ /// Set the spacing after the block-level element.
3708
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3709
+ self.set_space_after(space_after);
3710
+ self
3711
+ }
3712
+
3713
+ /// The spacing between the start inline edge of the element and the parent.
3714
+ pub fn start_indent(&self) -> Option<f32> {
3715
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3716
+ }
3717
+
3718
+ /// Set the spacing between the start inline edge of the element and the parent.
3719
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3720
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3721
+ }
3722
+
3723
+ /// Set the spacing between the start inline edge of the element and the parent.
3724
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3725
+ self.set_start_indent(start_indent);
3726
+ self
3727
+ }
3728
+
3729
+ /// The spacing between the end inline edge of the element and the parent.
3730
+ pub fn end_indent(&self) -> Option<f32> {
3731
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3732
+ }
3733
+
3734
+ /// Set the spacing between the end inline edge of the element and the parent.
3735
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3736
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3737
+ }
3738
+
3739
+ /// Set the spacing between the end inline edge of the element and the parent.
3740
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3741
+ self.set_end_indent(end_indent);
3742
+ self
3743
+ }
3744
+ }
3745
+
3746
+ impl From<Tag<kind::Link>> for TagKind {
3747
+ fn from(value: Tag<kind::Link>) -> Self {
3748
+ Self::Link(value)
3749
+ }
3750
+ }
3751
+ impl Tag<kind::Link> {
3752
+ /// A link.
3753
+ ///
3754
+ /// **Best practice**: The first child of a tag group with this tag should be a link annotation
3755
+ /// linking to an URL, and the second child should consist of the children that should
3756
+ /// be associated with that link.
3757
+ #[allow(non_upper_case_globals)]
3758
+ pub const Link: Tag<kind::Link> = Tag::new();
3759
+
3760
+ /// The spacing before the block-level element.
3761
+ pub fn space_before(&self) -> Option<f32> {
3762
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3763
+ }
3764
+
3765
+ /// Set the spacing before the block-level element.
3766
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3767
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3768
+ }
3769
+
3770
+ /// Set the spacing before the block-level element.
3771
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3772
+ self.set_space_before(space_before);
3773
+ self
3774
+ }
3775
+
3776
+ /// The spacing after the block-level element.
3777
+ pub fn space_after(&self) -> Option<f32> {
3778
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3779
+ }
3780
+
3781
+ /// Set the spacing after the block-level element.
3782
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3783
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3784
+ }
3785
+
3786
+ /// Set the spacing after the block-level element.
3787
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3788
+ self.set_space_after(space_after);
3789
+ self
3790
+ }
3791
+
3792
+ /// The spacing between the start inline edge of the element and the parent.
3793
+ pub fn start_indent(&self) -> Option<f32> {
3794
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3795
+ }
3796
+
3797
+ /// Set the spacing between the start inline edge of the element and the parent.
3798
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3799
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3800
+ }
3801
+
3802
+ /// Set the spacing between the start inline edge of the element and the parent.
3803
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3804
+ self.set_start_indent(start_indent);
3805
+ self
3806
+ }
3807
+
3808
+ /// The spacing between the end inline edge of the element and the parent.
3809
+ pub fn end_indent(&self) -> Option<f32> {
3810
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3811
+ }
3812
+
3813
+ /// Set the spacing between the end inline edge of the element and the parent.
3814
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3815
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3816
+ }
3817
+
3818
+ /// Set the spacing between the end inline edge of the element and the parent.
3819
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3820
+ self.set_end_indent(end_indent);
3821
+ self
3822
+ }
3823
+ }
3824
+
3825
+ impl From<Tag<kind::Annot>> for TagKind {
3826
+ fn from(value: Tag<kind::Annot>) -> Self {
3827
+ Self::Annot(value)
3828
+ }
3829
+ }
3830
+ impl Tag<kind::Annot> {
3831
+ /// An association between an annotation and the content it belongs to. PDF
3832
+ ///
3833
+ /// **Best practice**: Should be used for all annotations, except for link annotations and
3834
+ /// widget annotations. The first child should be the identifier of a non-link annotation,
3835
+ /// and all other subsequent children should be content identifiers associated with that
3836
+ /// annotation.
3837
+ #[allow(non_upper_case_globals)]
3838
+ pub const Annot: Tag<kind::Annot> = Tag::new();
3839
+
3840
+ /// The spacing before the block-level element.
3841
+ pub fn space_before(&self) -> Option<f32> {
3842
+ self.inner.get_layout(LayoutAttr::SPACE_BEFORE).map(LayoutAttr::unwrap_space_before)
3843
+ }
3844
+
3845
+ /// Set the spacing before the block-level element.
3846
+ pub fn set_space_before(&mut self, space_before: Option<f32>) {
3847
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_BEFORE, space_before.map(LayoutAttr::SpaceBefore));
3848
+ }
3849
+
3850
+ /// Set the spacing before the block-level element.
3851
+ pub fn with_space_before(mut self, space_before: Option<f32>) -> Self {
3852
+ self.set_space_before(space_before);
3853
+ self
3854
+ }
3855
+
3856
+ /// The spacing after the block-level element.
3857
+ pub fn space_after(&self) -> Option<f32> {
3858
+ self.inner.get_layout(LayoutAttr::SPACE_AFTER).map(LayoutAttr::unwrap_space_after)
3859
+ }
3860
+
3861
+ /// Set the spacing after the block-level element.
3862
+ pub fn set_space_after(&mut self, space_after: Option<f32>) {
3863
+ self.inner.set_or_remove_layout(LayoutAttr::SPACE_AFTER, space_after.map(LayoutAttr::SpaceAfter));
3864
+ }
3865
+
3866
+ /// Set the spacing after the block-level element.
3867
+ pub fn with_space_after(mut self, space_after: Option<f32>) -> Self {
3868
+ self.set_space_after(space_after);
3869
+ self
3870
+ }
3871
+
3872
+ /// The spacing between the start inline edge of the element and the parent.
3873
+ pub fn start_indent(&self) -> Option<f32> {
3874
+ self.inner.get_layout(LayoutAttr::START_INDENT).map(LayoutAttr::unwrap_start_indent)
3875
+ }
3876
+
3877
+ /// Set the spacing between the start inline edge of the element and the parent.
3878
+ pub fn set_start_indent(&mut self, start_indent: Option<f32>) {
3879
+ self.inner.set_or_remove_layout(LayoutAttr::START_INDENT, start_indent.map(LayoutAttr::StartIndent));
3880
+ }
3881
+
3882
+ /// Set the spacing between the start inline edge of the element and the parent.
3883
+ pub fn with_start_indent(mut self, start_indent: Option<f32>) -> Self {
3884
+ self.set_start_indent(start_indent);
3885
+ self
3886
+ }
3887
+
3888
+ /// The spacing between the end inline edge of the element and the parent.
3889
+ pub fn end_indent(&self) -> Option<f32> {
3890
+ self.inner.get_layout(LayoutAttr::END_INDENT).map(LayoutAttr::unwrap_end_indent)
3891
+ }
3892
+
3893
+ /// Set the spacing between the end inline edge of the element and the parent.
3894
+ pub fn set_end_indent(&mut self, end_indent: Option<f32>) {
3895
+ self.inner.set_or_remove_layout(LayoutAttr::END_INDENT, end_indent.map(LayoutAttr::EndIndent));
3896
+ }
3897
+
3898
+ /// Set the spacing between the end inline edge of the element and the parent.
3899
+ pub fn with_end_indent(mut self, end_indent: Option<f32>) -> Self {
3900
+ self.set_end_indent(end_indent);
3901
+ self
3902
+ }
3903
+ }
3904
+
3905
+ impl From<Tag<kind::Figure>> for TagKind {
3906
+ fn from(value: Tag<kind::Figure>) -> Self {
3907
+ Self::Figure(value)
3908
+ }
3909
+ }
3910
+ impl Tag<kind::Figure> {
3911
+ /// Item of graphical content.
3912
+ ///
3913
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
3914
+ #[allow(non_snake_case)]
3915
+ pub fn Figure(alt_text: Option<String>) -> Tag<kind::Figure> {
3916
+ let mut tag = Tag::new();
3917
+ tag.set_alt_text(alt_text);
3918
+ tag
3919
+ }
3920
+
3921
+ /// The bounding box of a tag that encloses its visible content.
3922
+ /// If the content spans multiple pages, this should be omitted.
3923
+ pub fn bbox(&self) -> Option<BBox> {
3924
+ self.inner.get_layout(LayoutAttr::B_BOX).map(LayoutAttr::unwrap_bbox)
3925
+ }
3926
+
3927
+ /// Set the bounding box of a tag that encloses its visible content.
3928
+ /// If the content spans multiple pages, this should be omitted.
3929
+ pub fn set_bbox(&mut self, bbox: Option<BBox>) {
3930
+ self.inner.set_or_remove_layout(LayoutAttr::B_BOX, bbox.map(LayoutAttr::BBox));
3931
+ }
3932
+
3933
+ /// Set the bounding box of a tag that encloses its visible content.
3934
+ /// If the content spans multiple pages, this should be omitted.
3935
+ pub fn with_bbox(mut self, bbox: Option<BBox>) -> Self {
3936
+ self.set_bbox(bbox);
3937
+ self
3938
+ }
3939
+
3940
+ /// The width.
3941
+ pub fn width(&self) -> Option<f32> {
3942
+ self.inner.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
3943
+ }
3944
+
3945
+ /// Set the width.
3946
+ pub fn set_width(&mut self, width: Option<f32>) {
3947
+ self.inner.set_or_remove_layout(LayoutAttr::WIDTH, width.map(LayoutAttr::Width));
3948
+ }
3949
+
3950
+ /// Set the width.
3951
+ pub fn with_width(mut self, width: Option<f32>) -> Self {
3952
+ self.set_width(width);
3953
+ self
3954
+ }
3955
+
3956
+ /// The height.
3957
+ pub fn height(&self) -> Option<f32> {
3958
+ self.inner.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
3959
+ }
3960
+
3961
+ /// Set the height.
3962
+ pub fn set_height(&mut self, height: Option<f32>) {
3963
+ self.inner.set_or_remove_layout(LayoutAttr::HEIGHT, height.map(LayoutAttr::Height));
3964
+ }
3965
+
3966
+ /// Set the height.
3967
+ pub fn with_height(mut self, height: Option<f32>) -> Self {
3968
+ self.set_height(height);
3969
+ self
3970
+ }
3971
+ }
3972
+
3973
+ impl From<Tag<kind::Formula>> for TagKind {
3974
+ fn from(value: Tag<kind::Formula>) -> Self {
3975
+ Self::Formula(value)
3976
+ }
3977
+ }
3978
+ impl Tag<kind::Formula> {
3979
+ /// A mathematical formula.
3980
+ ///
3981
+ /// Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
3982
+ #[allow(non_snake_case)]
3983
+ pub fn Formula(alt_text: Option<String>) -> Tag<kind::Formula> {
3984
+ let mut tag = Tag::new();
3985
+ tag.set_alt_text(alt_text);
3986
+ tag
3987
+ }
3988
+
3989
+ /// The bounding box of a tag that encloses its visible content.
3990
+ /// If the content spans multiple pages, this should be omitted.
3991
+ pub fn bbox(&self) -> Option<BBox> {
3992
+ self.inner.get_layout(LayoutAttr::B_BOX).map(LayoutAttr::unwrap_bbox)
3993
+ }
3994
+
3995
+ /// Set the bounding box of a tag that encloses its visible content.
3996
+ /// If the content spans multiple pages, this should be omitted.
3997
+ pub fn set_bbox(&mut self, bbox: Option<BBox>) {
3998
+ self.inner.set_or_remove_layout(LayoutAttr::B_BOX, bbox.map(LayoutAttr::BBox));
3999
+ }
4000
+
4001
+ /// Set the bounding box of a tag that encloses its visible content.
4002
+ /// If the content spans multiple pages, this should be omitted.
4003
+ pub fn with_bbox(mut self, bbox: Option<BBox>) -> Self {
4004
+ self.set_bbox(bbox);
4005
+ self
4006
+ }
4007
+
4008
+ /// The width.
4009
+ pub fn width(&self) -> Option<f32> {
4010
+ self.inner.get_layout(LayoutAttr::WIDTH).map(LayoutAttr::unwrap_width)
4011
+ }
4012
+
4013
+ /// Set the width.
4014
+ pub fn set_width(&mut self, width: Option<f32>) {
4015
+ self.inner.set_or_remove_layout(LayoutAttr::WIDTH, width.map(LayoutAttr::Width));
4016
+ }
4017
+
4018
+ /// Set the width.
4019
+ pub fn with_width(mut self, width: Option<f32>) -> Self {
4020
+ self.set_width(width);
4021
+ self
4022
+ }
4023
+
4024
+ /// The height.
4025
+ pub fn height(&self) -> Option<f32> {
4026
+ self.inner.get_layout(LayoutAttr::HEIGHT).map(LayoutAttr::unwrap_height)
4027
+ }
4028
+
4029
+ /// Set the height.
4030
+ pub fn set_height(&mut self, height: Option<f32>) {
4031
+ self.inner.set_or_remove_layout(LayoutAttr::HEIGHT, height.map(LayoutAttr::Height));
4032
+ }
4033
+
4034
+ /// Set the height.
4035
+ pub fn with_height(mut self, height: Option<f32>) -> Self {
4036
+ self.set_height(height);
4037
+ self
4038
+ }
4039
+ }
4040
+
4041
+ impl From<Tag<kind::Form>> for TagKind {
4042
+ fn from(value: Tag<kind::Form>) -> Self {
4043
+ Self::Form(value)
4044
+ }
4045
+ }
4046
+ impl Tag<kind::Form> {
4047
+ /// An interactive form field.
4048
+ #[allow(non_upper_case_globals)]
4049
+ pub const Form: Tag<kind::Form> = Tag::new();
4050
+ }
4051
+
4052
+ impl From<Tag<kind::NonStruct>> for TagKind {
4053
+ fn from(value: Tag<kind::NonStruct>) -> Self {
4054
+ Self::NonStruct(value)
4055
+ }
4056
+ }
4057
+ impl Tag<kind::NonStruct> {
4058
+ /// Non-structural element. A grouping element having no inherent structural significance;
4059
+ /// it serves solely for grouping purposes.
4060
+ #[allow(non_upper_case_globals)]
4061
+ pub const NonStruct: Tag<kind::NonStruct> = Tag::new();
4062
+ }
4063
+
4064
+ impl From<Tag<kind::Datetime>> for TagKind {
4065
+ fn from(value: Tag<kind::Datetime>) -> Self {
4066
+ Self::Datetime(value)
4067
+ }
4068
+ }
4069
+ impl Tag<kind::Datetime> {
4070
+ /// A date or time.
4071
+ #[allow(non_upper_case_globals)]
4072
+ pub const Datetime: Tag<kind::Datetime> = Tag::new();
4073
+ }
4074
+
4075
+ impl From<Tag<kind::Terms>> for TagKind {
4076
+ fn from(value: Tag<kind::Terms>) -> Self {
4077
+ Self::Terms(value)
4078
+ }
4079
+ }
4080
+ impl Tag<kind::Terms> {
4081
+ /// A list of terms.
4082
+ #[allow(non_upper_case_globals)]
4083
+ pub const Terms: Tag<kind::Terms> = Tag::new();
4084
+ }
4085
+
4086
+ impl From<Tag<kind::Title>> for TagKind {
4087
+ fn from(value: Tag<kind::Title>) -> Self {
4088
+ Self::Title(value)
4089
+ }
4090
+ }
4091
+ impl Tag<kind::Title> {
4092
+ /// A title.
4093
+ #[allow(non_upper_case_globals)]
4094
+ pub const Title: Tag<kind::Title> = Tag::new();
4095
+ }
4096
+
4097
+ impl From<Tag<kind::Strong>> for TagKind {
4098
+ fn from(value: Tag<kind::Strong>) -> Self {
4099
+ Self::Strong(value)
4100
+ }
4101
+ }
4102
+ impl Tag<kind::Strong> {
4103
+ /// Encloses content with strong importance, most commonly **bold** text.
4104
+ #[allow(non_upper_case_globals)]
4105
+ pub const Strong: Tag<kind::Strong> = Tag::new();
4106
+ }
4107
+
4108
+ impl From<Tag<kind::Em>> for TagKind {
4109
+ fn from(value: Tag<kind::Em>) -> Self {
4110
+ Self::Em(value)
4111
+ }
4112
+ }
4113
+ impl Tag<kind::Em> {
4114
+ /// Encloses content that is emphasized, most commonly *italic* text.
4115
+ #[allow(non_upper_case_globals)]
4116
+ pub const Em: Tag<kind::Em> = Tag::new();
4117
+ }
4118
+
4119
+ #[derive(Clone, Debug, PartialEq)]
4120
+ pub(crate) enum Attr {
4121
+ Struct(StructAttr),
4122
+ List(ListAttr),
4123
+ Table(TableAttr),
4124
+ Layout(LayoutAttr),
4125
+ }
4126
+
4127
+ impl Attr {
4128
+
4129
+ #[inline(always)]
4130
+ fn unwrap_struct(&self) -> &StructAttr {
4131
+ match self {
4132
+ Self::Struct(attr) => attr,
4133
+ _ => unreachable!(),
4134
+ }
4135
+ }
4136
+
4137
+ #[inline(always)]
4138
+ fn unwrap_list(&self) -> &ListAttr {
4139
+ match self {
4140
+ Self::List(attr) => attr,
4141
+ _ => unreachable!(),
4142
+ }
4143
+ }
4144
+
4145
+ #[inline(always)]
4146
+ fn unwrap_table(&self) -> &TableAttr {
4147
+ match self {
4148
+ Self::Table(attr) => attr,
4149
+ _ => unreachable!(),
4150
+ }
4151
+ }
4152
+
4153
+ #[inline(always)]
4154
+ fn unwrap_layout(&self) -> &LayoutAttr {
4155
+ match self {
4156
+ Self::Layout(attr) => attr,
4157
+ _ => unreachable!(),
4158
+ }
4159
+ }
4160
+ }
4161
+ impl Ordinal for Attr {
4162
+ fn ordinal(&self) -> usize {
4163
+ match self {
4164
+ Self::Struct(a) => a.ordinal(),
4165
+ Self::List(a) => a.ordinal(),
4166
+ Self::Table(a) => a.ordinal(),
4167
+ Self::Layout(a) => a.ordinal(),
4168
+ }
4169
+ }
4170
+ }
4171
+
4172
+ #[derive(Clone, Debug, PartialEq)]
4173
+ pub(crate) enum StructAttr {
4174
+ /// The tag id.
4175
+ Id(TagId),
4176
+ /// The language of this tag.
4177
+ Lang(String),
4178
+ /// The optional alternate text that describes the text (for example, if the text
4179
+ /// consists of a star symbol, the alt text should describe that in natural language).
4180
+ AltText(String),
4181
+ /// The expanded form of an abbreviation.
4182
+ /// Only applicable if the content of the tag is an abbreviation.
4183
+ Expanded(String),
4184
+ /// The actual text represented by the content of this tag, i.e. if it contained
4185
+ /// some curves that artistically represent some word. This should be the exact
4186
+ /// replacement text of the word.
4187
+ ActualText(String),
4188
+ /// The title, characterizing a specific tag such as `"Chapter 1"`.
4189
+ Title(String),
4190
+ /// The heading level
4191
+ HeadingLevel(NonZeroU16),
4192
+ }
4193
+
4194
+ impl StructAttr {
4195
+ pub(crate) const ID: usize = 0;
4196
+ pub(crate) const LANG: usize = 1;
4197
+ pub(crate) const ALT_TEXT: usize = 2;
4198
+ pub(crate) const EXPANDED: usize = 3;
4199
+ pub(crate) const ACTUAL_TEXT: usize = 4;
4200
+ pub(crate) const TITLE: usize = 5;
4201
+ pub(crate) const HEADING_LEVEL: usize = 6;
4202
+
4203
+ #[inline(always)]
4204
+ fn unwrap_id(&self) -> &TagId {
4205
+ match self {
4206
+ Self::Id(val) => val,
4207
+ _ => unreachable!(),
4208
+ }
4209
+ }
4210
+
4211
+ #[inline(always)]
4212
+ fn unwrap_lang(&self) -> &str {
4213
+ match self {
4214
+ Self::Lang(val) => val.as_ref(),
4215
+ _ => unreachable!(),
4216
+ }
4217
+ }
4218
+
4219
+ #[inline(always)]
4220
+ fn unwrap_alt_text(&self) -> &str {
4221
+ match self {
4222
+ Self::AltText(val) => val.as_ref(),
4223
+ _ => unreachable!(),
4224
+ }
4225
+ }
4226
+
4227
+ #[inline(always)]
4228
+ fn unwrap_expanded(&self) -> &str {
4229
+ match self {
4230
+ Self::Expanded(val) => val.as_ref(),
4231
+ _ => unreachable!(),
4232
+ }
4233
+ }
4234
+
4235
+ #[inline(always)]
4236
+ fn unwrap_actual_text(&self) -> &str {
4237
+ match self {
4238
+ Self::ActualText(val) => val.as_ref(),
4239
+ _ => unreachable!(),
4240
+ }
4241
+ }
4242
+
4243
+ #[inline(always)]
4244
+ fn unwrap_title(&self) -> &str {
4245
+ match self {
4246
+ Self::Title(val) => val.as_ref(),
4247
+ _ => unreachable!(),
4248
+ }
4249
+ }
4250
+
4251
+ #[inline(always)]
4252
+ fn unwrap_level(&self) -> NonZeroU16 {
4253
+ match self {
4254
+ Self::HeadingLevel(val) => *val,
4255
+ _ => unreachable!(),
4256
+ }
4257
+ }
4258
+ }
4259
+
4260
+ impl Ordinal for StructAttr {
4261
+ fn ordinal(&self) -> usize {
4262
+ match self {
4263
+ Self::Id(_) => Self::ID,
4264
+ Self::Lang(_) => Self::LANG,
4265
+ Self::AltText(_) => Self::ALT_TEXT,
4266
+ Self::Expanded(_) => Self::EXPANDED,
4267
+ Self::ActualText(_) => Self::ACTUAL_TEXT,
4268
+ Self::Title(_) => Self::TITLE,
4269
+ Self::HeadingLevel(_) => Self::HEADING_LEVEL,
4270
+ }
4271
+ }
4272
+ }
4273
+
4274
+ #[derive(Clone, Debug, PartialEq)]
4275
+ pub(crate) enum ListAttr {
4276
+ /// The list numbering.
4277
+ Numbering(ListNumbering),
4278
+ }
4279
+
4280
+ impl ListAttr {
4281
+ pub(crate) const NUMBERING: usize = 7;
4282
+
4283
+ #[inline(always)]
4284
+ fn unwrap_numbering(&self) -> ListNumbering {
4285
+ match self {
4286
+ Self::Numbering(val) => *val,
4287
+ }
4288
+ }
4289
+ }
4290
+
4291
+ impl Ordinal for ListAttr {
4292
+ fn ordinal(&self) -> usize {
4293
+ match self {
4294
+ Self::Numbering(_) => Self::NUMBERING,
4295
+ }
4296
+ }
4297
+ }
4298
+
4299
+ #[derive(Clone, Debug, PartialEq)]
4300
+ pub(crate) enum TableAttr {
4301
+ /// The table summary.
4302
+ Summary(String),
4303
+ /// The table header scope.
4304
+ HeaderScope(TableHeaderScope),
4305
+ /// The list of headers associated with a table cell.
4306
+ /// Table data cells (`TD`) may specify a list of table headers (`TH`),
4307
+ /// which can also specify a list of parent header cells (`TH`), and so on.
4308
+ /// To determine the list of associated headers this list is recursively
4309
+ /// evaluated.
4310
+ ///
4311
+ /// This allows specifying header hierarchies inside tables.
4312
+ CellHeaders(SmallVec<[TagId; 1]>),
4313
+ /// The row span of this table cell.
4314
+ RowSpan(NonZeroU32),
4315
+ /// The column span of this table cell.
4316
+ ColSpan(NonZeroU32),
4317
+ }
4318
+
4319
+ impl TableAttr {
4320
+ pub(crate) const SUMMARY: usize = 8;
4321
+ pub(crate) const HEADER_SCOPE: usize = 9;
4322
+ pub(crate) const CELL_HEADERS: usize = 10;
4323
+ pub(crate) const ROW_SPAN: usize = 11;
4324
+ pub(crate) const COL_SPAN: usize = 12;
4325
+
4326
+ #[inline(always)]
4327
+ fn unwrap_summary(&self) -> &str {
4328
+ match self {
4329
+ Self::Summary(val) => val.as_ref(),
4330
+ _ => unreachable!(),
4331
+ }
4332
+ }
4333
+
4334
+ #[inline(always)]
4335
+ fn unwrap_scope(&self) -> TableHeaderScope {
4336
+ match self {
4337
+ Self::HeaderScope(val) => *val,
4338
+ _ => unreachable!(),
4339
+ }
4340
+ }
4341
+
4342
+ #[inline(always)]
4343
+ fn unwrap_headers(&self) -> &[TagId] {
4344
+ match self {
4345
+ Self::CellHeaders(val) => val.as_ref(),
4346
+ _ => unreachable!(),
4347
+ }
4348
+ }
4349
+
4350
+ #[inline(always)]
4351
+ fn unwrap_row_span(&self) -> NonZeroU32 {
4352
+ match self {
4353
+ Self::RowSpan(val) => *val,
4354
+ _ => unreachable!(),
4355
+ }
4356
+ }
4357
+
4358
+ #[inline(always)]
4359
+ fn unwrap_col_span(&self) -> NonZeroU32 {
4360
+ match self {
4361
+ Self::ColSpan(val) => *val,
4362
+ _ => unreachable!(),
4363
+ }
4364
+ }
4365
+ }
4366
+
4367
+ impl Ordinal for TableAttr {
4368
+ fn ordinal(&self) -> usize {
4369
+ match self {
4370
+ Self::Summary(_) => Self::SUMMARY,
4371
+ Self::HeaderScope(_) => Self::HEADER_SCOPE,
4372
+ Self::CellHeaders(_) => Self::CELL_HEADERS,
4373
+ Self::RowSpan(_) => Self::ROW_SPAN,
4374
+ Self::ColSpan(_) => Self::COL_SPAN,
4375
+ }
4376
+ }
4377
+ }
4378
+
4379
+ #[derive(Clone, Debug, PartialEq)]
4380
+ pub(crate) enum LayoutAttr {
4381
+ /// The placement.
4382
+ Placement(Placement),
4383
+ /// The writing mode.
4384
+ WritingMode(WritingMode),
4385
+ /// The bounding box of a tag that encloses its visible content.
4386
+ /// If the content spans multiple pages, this should be omitted.
4387
+ BBox(BBox),
4388
+ /// The width.
4389
+ Width(f32),
4390
+ /// The height.
4391
+ Height(f32),
4392
+ /// The background color.
4393
+ BackgroundColor(NaiveRgbColor),
4394
+ /// The border color.
4395
+ BorderColor(Sides<NaiveRgbColor>),
4396
+ /// The way the border is drawn.
4397
+ BorderStyle(Sides<BorderStyle>),
4398
+ /// The border width.
4399
+ BorderThickness(Sides<f32>),
4400
+ /// The padding inside of an element.
4401
+ Padding(Sides<f32>),
4402
+ /// The color of text, borders, and text decorations.
4403
+ Color(NaiveRgbColor),
4404
+ /// The spacing before the block-level element.
4405
+ SpaceBefore(f32),
4406
+ /// The spacing after the block-level element.
4407
+ SpaceAfter(f32),
4408
+ /// The spacing between the start inline edge of the element and the parent.
4409
+ StartIndent(f32),
4410
+ /// The spacing between the end inline edge of the element and the parent.
4411
+ EndIndent(f32),
4412
+ /// The amount the first line of text in a block-level element is indented. Only
4413
+ /// applicable to paragraph-like elements with non-block-level elements.
4414
+ TextIndent(f32),
4415
+ /// The text alignment.
4416
+ TextAlign(TextAlign),
4417
+ /// The alignment of block-level elements inside of this block-level element.
4418
+ BlockAlign(BlockAlign),
4419
+ /// The alignment of inline-level elements inside of this block-level element.
4420
+ InlineAlign(InlineAlign),
4421
+ /// The border style of table cells, overriding `BorderStyle`.
4422
+ TableBorderStyle(Sides<BorderStyle>),
4423
+ /// The padding inside of table cells, overriding `Padding`.
4424
+ TablePadding(Sides<f32>),
4425
+ /// The distance by which the baseline shall be shifted from the default position.
4426
+ BaselineShift(f32),
4427
+ /// The height of each line in an element on the block axis.
4428
+ LineHeight(LineHeight),
4429
+ /// The color of the text decoration, overriding the fill color.
4430
+ TextDecorationColor(NaiveRgbColor),
4431
+ /// The width of the text decoration line.
4432
+ TextDecorationThickness(f32),
4433
+ /// The kind of text decoration.
4434
+ TextDecorationType(TextDecorationType),
4435
+ /// How the glyphs are rotated in a vertical writing mode.
4436
+ GlyphOrientationVertical(GlyphOrientationVertical),
4437
+ /// The number of columns in the grouping element.
4438
+ ColumnCount(NonZeroU32),
4439
+ /// The width of the gaps between columns in the grouping element.
4440
+ ColumnGap(ColumnDimensions),
4441
+ /// The width of the columns in the grouping element.
4442
+ ColumnWidths(ColumnDimensions),
4443
+ }
4444
+
4445
+ impl LayoutAttr {
4446
+ pub(crate) const PLACEMENT: usize = 13;
4447
+ pub(crate) const WRITING_MODE: usize = 14;
4448
+ pub(crate) const B_BOX: usize = 15;
4449
+ pub(crate) const WIDTH: usize = 16;
4450
+ pub(crate) const HEIGHT: usize = 17;
4451
+ pub(crate) const BACKGROUND_COLOR: usize = 18;
4452
+ pub(crate) const BORDER_COLOR: usize = 19;
4453
+ pub(crate) const BORDER_STYLE: usize = 20;
4454
+ pub(crate) const BORDER_THICKNESS: usize = 21;
4455
+ pub(crate) const PADDING: usize = 22;
4456
+ pub(crate) const COLOR: usize = 23;
4457
+ pub(crate) const SPACE_BEFORE: usize = 24;
4458
+ pub(crate) const SPACE_AFTER: usize = 25;
4459
+ pub(crate) const START_INDENT: usize = 26;
4460
+ pub(crate) const END_INDENT: usize = 27;
4461
+ pub(crate) const TEXT_INDENT: usize = 28;
4462
+ pub(crate) const TEXT_ALIGN: usize = 29;
4463
+ pub(crate) const BLOCK_ALIGN: usize = 30;
4464
+ pub(crate) const INLINE_ALIGN: usize = 31;
4465
+ pub(crate) const TABLE_BORDER_STYLE: usize = 32;
4466
+ pub(crate) const TABLE_PADDING: usize = 33;
4467
+ pub(crate) const BASELINE_SHIFT: usize = 34;
4468
+ pub(crate) const LINE_HEIGHT: usize = 35;
4469
+ pub(crate) const TEXT_DECORATION_COLOR: usize = 36;
4470
+ pub(crate) const TEXT_DECORATION_THICKNESS: usize = 37;
4471
+ pub(crate) const TEXT_DECORATION_TYPE: usize = 38;
4472
+ pub(crate) const GLYPH_ORIENTATION_VERTICAL: usize = 39;
4473
+ pub(crate) const COLUMN_COUNT: usize = 40;
4474
+ pub(crate) const COLUMN_GAP: usize = 41;
4475
+ pub(crate) const COLUMN_WIDTHS: usize = 42;
4476
+
4477
+ #[inline(always)]
4478
+ fn unwrap_placement(&self) -> Placement {
4479
+ match self {
4480
+ Self::Placement(val) => *val,
4481
+ _ => unreachable!(),
4482
+ }
4483
+ }
4484
+
4485
+ #[inline(always)]
4486
+ fn unwrap_writing_mode(&self) -> WritingMode {
4487
+ match self {
4488
+ Self::WritingMode(val) => *val,
4489
+ _ => unreachable!(),
4490
+ }
4491
+ }
4492
+
4493
+ #[inline(always)]
4494
+ fn unwrap_bbox(&self) -> BBox {
4495
+ match self {
4496
+ Self::BBox(val) => *val,
4497
+ _ => unreachable!(),
4498
+ }
4499
+ }
4500
+
4501
+ #[inline(always)]
4502
+ fn unwrap_width(&self) -> f32 {
4503
+ match self {
4504
+ Self::Width(val) => *val,
4505
+ _ => unreachable!(),
4506
+ }
4507
+ }
4508
+
4509
+ #[inline(always)]
4510
+ fn unwrap_height(&self) -> f32 {
4511
+ match self {
4512
+ Self::Height(val) => *val,
4513
+ _ => unreachable!(),
4514
+ }
4515
+ }
4516
+
4517
+ #[inline(always)]
4518
+ fn unwrap_background_color(&self) -> NaiveRgbColor {
4519
+ match self {
4520
+ Self::BackgroundColor(val) => *val,
4521
+ _ => unreachable!(),
4522
+ }
4523
+ }
4524
+
4525
+ #[inline(always)]
4526
+ fn unwrap_border_color(&self) -> Sides<NaiveRgbColor> {
4527
+ match self {
4528
+ Self::BorderColor(val) => *val,
4529
+ _ => unreachable!(),
4530
+ }
4531
+ }
4532
+
4533
+ #[inline(always)]
4534
+ fn unwrap_border_style(&self) -> Sides<BorderStyle> {
4535
+ match self {
4536
+ Self::BorderStyle(val) => *val,
4537
+ _ => unreachable!(),
4538
+ }
4539
+ }
4540
+
4541
+ #[inline(always)]
4542
+ fn unwrap_border_thickness(&self) -> Sides<f32> {
4543
+ match self {
4544
+ Self::BorderThickness(val) => *val,
4545
+ _ => unreachable!(),
4546
+ }
4547
+ }
4548
+
4549
+ #[inline(always)]
4550
+ fn unwrap_padding(&self) -> Sides<f32> {
4551
+ match self {
4552
+ Self::Padding(val) => *val,
4553
+ _ => unreachable!(),
4554
+ }
4555
+ }
4556
+
4557
+ #[inline(always)]
4558
+ fn unwrap_color(&self) -> NaiveRgbColor {
4559
+ match self {
4560
+ Self::Color(val) => *val,
4561
+ _ => unreachable!(),
4562
+ }
4563
+ }
4564
+
4565
+ #[inline(always)]
4566
+ fn unwrap_space_before(&self) -> f32 {
4567
+ match self {
4568
+ Self::SpaceBefore(val) => *val,
4569
+ _ => unreachable!(),
4570
+ }
4571
+ }
4572
+
4573
+ #[inline(always)]
4574
+ fn unwrap_space_after(&self) -> f32 {
4575
+ match self {
4576
+ Self::SpaceAfter(val) => *val,
4577
+ _ => unreachable!(),
4578
+ }
4579
+ }
4580
+
4581
+ #[inline(always)]
4582
+ fn unwrap_start_indent(&self) -> f32 {
4583
+ match self {
4584
+ Self::StartIndent(val) => *val,
4585
+ _ => unreachable!(),
4586
+ }
4587
+ }
4588
+
4589
+ #[inline(always)]
4590
+ fn unwrap_end_indent(&self) -> f32 {
4591
+ match self {
4592
+ Self::EndIndent(val) => *val,
4593
+ _ => unreachable!(),
4594
+ }
4595
+ }
4596
+
4597
+ #[inline(always)]
4598
+ fn unwrap_text_indent(&self) -> f32 {
4599
+ match self {
4600
+ Self::TextIndent(val) => *val,
4601
+ _ => unreachable!(),
4602
+ }
4603
+ }
4604
+
4605
+ #[inline(always)]
4606
+ fn unwrap_text_align(&self) -> TextAlign {
4607
+ match self {
4608
+ Self::TextAlign(val) => *val,
4609
+ _ => unreachable!(),
4610
+ }
4611
+ }
4612
+
4613
+ #[inline(always)]
4614
+ fn unwrap_block_align(&self) -> BlockAlign {
4615
+ match self {
4616
+ Self::BlockAlign(val) => *val,
4617
+ _ => unreachable!(),
4618
+ }
4619
+ }
4620
+
4621
+ #[inline(always)]
4622
+ fn unwrap_inline_align(&self) -> InlineAlign {
4623
+ match self {
4624
+ Self::InlineAlign(val) => *val,
4625
+ _ => unreachable!(),
4626
+ }
4627
+ }
4628
+
4629
+ #[inline(always)]
4630
+ fn unwrap_table_border_style(&self) -> Sides<BorderStyle> {
4631
+ match self {
4632
+ Self::TableBorderStyle(val) => *val,
4633
+ _ => unreachable!(),
4634
+ }
4635
+ }
4636
+
4637
+ #[inline(always)]
4638
+ fn unwrap_table_padding(&self) -> Sides<f32> {
4639
+ match self {
4640
+ Self::TablePadding(val) => *val,
4641
+ _ => unreachable!(),
4642
+ }
4643
+ }
4644
+
4645
+ #[inline(always)]
4646
+ fn unwrap_baseline_shift(&self) -> f32 {
4647
+ match self {
4648
+ Self::BaselineShift(val) => *val,
4649
+ _ => unreachable!(),
4650
+ }
4651
+ }
4652
+
4653
+ #[inline(always)]
4654
+ fn unwrap_line_height(&self) -> LineHeight {
4655
+ match self {
4656
+ Self::LineHeight(val) => *val,
4657
+ _ => unreachable!(),
4658
+ }
4659
+ }
4660
+
4661
+ #[inline(always)]
4662
+ fn unwrap_text_decoration_color(&self) -> NaiveRgbColor {
4663
+ match self {
4664
+ Self::TextDecorationColor(val) => *val,
4665
+ _ => unreachable!(),
4666
+ }
4667
+ }
4668
+
4669
+ #[inline(always)]
4670
+ fn unwrap_text_decoration_thickness(&self) -> f32 {
4671
+ match self {
4672
+ Self::TextDecorationThickness(val) => *val,
4673
+ _ => unreachable!(),
4674
+ }
4675
+ }
4676
+
4677
+ #[inline(always)]
4678
+ fn unwrap_text_decoration_type(&self) -> TextDecorationType {
4679
+ match self {
4680
+ Self::TextDecorationType(val) => *val,
4681
+ _ => unreachable!(),
4682
+ }
4683
+ }
4684
+
4685
+ #[inline(always)]
4686
+ fn unwrap_glyph_orientation_vertical(&self) -> GlyphOrientationVertical {
4687
+ match self {
4688
+ Self::GlyphOrientationVertical(val) => *val,
4689
+ _ => unreachable!(),
4690
+ }
4691
+ }
4692
+
4693
+ #[inline(always)]
4694
+ fn unwrap_column_count(&self) -> NonZeroU32 {
4695
+ match self {
4696
+ Self::ColumnCount(val) => *val,
4697
+ _ => unreachable!(),
4698
+ }
4699
+ }
4700
+
4701
+ #[inline(always)]
4702
+ fn unwrap_column_gap(&self) -> &ColumnDimensions {
4703
+ match self {
4704
+ Self::ColumnGap(val) => val,
4705
+ _ => unreachable!(),
4706
+ }
4707
+ }
4708
+
4709
+ #[inline(always)]
4710
+ fn unwrap_column_widths(&self) -> &ColumnDimensions {
4711
+ match self {
4712
+ Self::ColumnWidths(val) => val,
4713
+ _ => unreachable!(),
4714
+ }
4715
+ }
4716
+ }
4717
+
4718
+ impl Ordinal for LayoutAttr {
4719
+ fn ordinal(&self) -> usize {
4720
+ match self {
4721
+ Self::Placement(_) => Self::PLACEMENT,
4722
+ Self::WritingMode(_) => Self::WRITING_MODE,
4723
+ Self::BBox(_) => Self::B_BOX,
4724
+ Self::Width(_) => Self::WIDTH,
4725
+ Self::Height(_) => Self::HEIGHT,
4726
+ Self::BackgroundColor(_) => Self::BACKGROUND_COLOR,
4727
+ Self::BorderColor(_) => Self::BORDER_COLOR,
4728
+ Self::BorderStyle(_) => Self::BORDER_STYLE,
4729
+ Self::BorderThickness(_) => Self::BORDER_THICKNESS,
4730
+ Self::Padding(_) => Self::PADDING,
4731
+ Self::Color(_) => Self::COLOR,
4732
+ Self::SpaceBefore(_) => Self::SPACE_BEFORE,
4733
+ Self::SpaceAfter(_) => Self::SPACE_AFTER,
4734
+ Self::StartIndent(_) => Self::START_INDENT,
4735
+ Self::EndIndent(_) => Self::END_INDENT,
4736
+ Self::TextIndent(_) => Self::TEXT_INDENT,
4737
+ Self::TextAlign(_) => Self::TEXT_ALIGN,
4738
+ Self::BlockAlign(_) => Self::BLOCK_ALIGN,
4739
+ Self::InlineAlign(_) => Self::INLINE_ALIGN,
4740
+ Self::TableBorderStyle(_) => Self::TABLE_BORDER_STYLE,
4741
+ Self::TablePadding(_) => Self::TABLE_PADDING,
4742
+ Self::BaselineShift(_) => Self::BASELINE_SHIFT,
4743
+ Self::LineHeight(_) => Self::LINE_HEIGHT,
4744
+ Self::TextDecorationColor(_) => Self::TEXT_DECORATION_COLOR,
4745
+ Self::TextDecorationThickness(_) => Self::TEXT_DECORATION_THICKNESS,
4746
+ Self::TextDecorationType(_) => Self::TEXT_DECORATION_TYPE,
4747
+ Self::GlyphOrientationVertical(_) => Self::GLYPH_ORIENTATION_VERTICAL,
4748
+ Self::ColumnCount(_) => Self::COLUMN_COUNT,
4749
+ Self::ColumnGap(_) => Self::COLUMN_GAP,
4750
+ Self::ColumnWidths(_) => Self::COLUMN_WIDTHS,
4751
+ }
4752
+ }
4753
+ }
4754
+