html-to-markdown 3.11.4 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:d679b59088594adaffae8541ddda37761d2ea48733185dc6d5b1a45f82cf2d54
3
2
  # To regenerate: alef generate
4
3
  # To verify freshness: alef verify
5
4
  # frozen_string_literal: true
@@ -18,7 +17,7 @@ library_candidates = dlexts.flat_map do |dlext|
18
17
  File.join(__dir__, "..", extension_name, ruby_abi, "#{extension_name}.#{dlext}"),
19
18
  File.join(__dir__, "..", extension_name, ruby_abi, "lib#{extension_name}.#{dlext}"),
20
19
  File.join(__dir__, "..", "#{extension_name}.#{dlext}"),
21
- File.join(__dir__, "..", "lib#{extension_name}.#{dlext}"),
20
+ File.join(__dir__, "..", "lib#{extension_name}.#{dlext}")
22
21
  ]
23
22
  end
24
23
 
@@ -34,6 +33,7 @@ unless native_extension
34
33
  end
35
34
 
36
35
  require native_extension
36
+
37
37
  module HtmlToMarkdown
38
38
  # Re-export public types from the native extension (curated list, excludes Update/Builder types)
39
39
  ConversionOptions = HtmlToMarkdownRs.const_get(:ConversionOptions)
@@ -56,13 +56,16 @@ module HtmlToMarkdown
56
56
  TableGrid = HtmlToMarkdownRs.const_get(:TableGrid)
57
57
  TextAnnotation = HtmlToMarkdownRs.const_get(:TextAnnotation)
58
58
  # Re-export public module functions from the native extension (curated list)
59
- define_singleton_method(:convert) { |*args, **kwargs, &blk| HtmlToMarkdownRs.public_send(:convert, *args, **kwargs, &blk) }
59
+ define_singleton_method(:convert) { |*args, **kwargs, &blk|
60
+ HtmlToMarkdownRs.public_send(:convert, *args, **kwargs, &blk)
61
+ }
60
62
  end
63
+
61
64
  module HtmlToMarkdown
62
- # The semantic content type of a document node.
65
+ # The type of an inline text annotation.
63
66
  #
64
- # Uses internally tagged representation (`"node_type": "heading"`) for JSON serialization.
65
- module NodeContent
67
+ # Uses internally tagged representation (`"annotation_type": "bold"`) for JSON serialization.
68
+ module AnnotationKind
66
69
  extend T::Helpers
67
70
  extend T::Sig
68
71
 
@@ -73,369 +76,382 @@ module HtmlToMarkdown
73
76
  # @return [variant_class] an instance of the appropriate variant
74
77
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
75
78
  def self.from_hash(hash)
76
- discriminator = hash[:node_type] || hash["node_type"]
79
+ discriminator = hash[:annotation_type] || hash["annotation_type"]
77
80
  case discriminator
78
- when "heading" then NodeContentHeading.from_hash(hash)
79
- when "paragraph" then NodeContentParagraph.from_hash(hash)
80
- when "list" then NodeContentList.from_hash(hash)
81
- when "list_item" then NodeContentListItem.from_hash(hash)
82
- when "table" then NodeContentTable.from_hash(hash)
83
- when "image" then NodeContentImage.from_hash(hash)
84
- when "code" then NodeContentCode.from_hash(hash)
85
- when "quote" then NodeContentQuote.from_hash(hash)
86
- when "definition_list" then NodeContentDefinitionList.from_hash(hash)
87
- when "definition_item" then NodeContentDefinitionItem.from_hash(hash)
88
- when "raw_block" then NodeContentRawBlock.from_hash(hash)
89
- when "metadata_block" then NodeContentMetadataBlock.from_hash(hash)
90
- when "group" then NodeContentGroup.from_hash(hash)
91
- else raise "Unknown discriminator: #{discriminator}"
81
+ when "bold"
82
+ AnnotationKindBold.from_hash(hash)
83
+ when "italic"
84
+ AnnotationKindItalic.from_hash(hash)
85
+ when "underline"
86
+ AnnotationKindUnderline.from_hash(hash)
87
+ when "strikethrough"
88
+ AnnotationKindStrikethrough.from_hash(hash)
89
+ when "code"
90
+ AnnotationKindCode.from_hash(hash)
91
+ when "subscript"
92
+ AnnotationKindSubscript.from_hash(hash)
93
+ when "superscript"
94
+ AnnotationKindSuperscript.from_hash(hash)
95
+ when "highlight"
96
+ AnnotationKindHighlight.from_hash(hash)
97
+ when "link"
98
+ AnnotationKindLink.from_hash(hash)
99
+ else
100
+ raise "Unknown discriminator: #{discriminator}"
92
101
  end
93
102
  end
94
103
  end
95
- ## A heading element (h1-h6).
96
- NodeContentHeading = Data.define(:level, :text) do
97
- include NodeContent
104
+ ## Bold / strong emphasis.
105
+ AnnotationKindBold = Data.define do
106
+ include AnnotationKind
98
107
  extend T::Sig
99
108
 
100
- # Heading level (1-6).
101
- sig { returns(Integer) }
102
- def level = super # rubocop:disable Lint/UselessMethodDefinition
103
- # The heading text content.
104
- sig { returns(String) }
105
- def text = super # rubocop:disable Lint/UselessMethodDefinition
106
- sig { returns(T::Boolean) }
107
- def heading? = true
108
- sig { returns(T::Boolean) }
109
- def paragraph? = false
110
109
  sig { returns(T::Boolean) }
111
- def list? = false
110
+ def bold? = true
112
111
  sig { returns(T::Boolean) }
113
- def list_item? = false
112
+ def italic? = false
114
113
  sig { returns(T::Boolean) }
115
- def table? = false
114
+ def underline? = false
116
115
  sig { returns(T::Boolean) }
117
- def image? = false
116
+ def strikethrough? = false
118
117
  sig { returns(T::Boolean) }
119
118
  def code? = false
120
119
  sig { returns(T::Boolean) }
121
- def quote? = false
122
- sig { returns(T::Boolean) }
123
- def definition_list? = false
124
- sig { returns(T::Boolean) }
125
- def definition_item? = false
120
+ def subscript? = false
126
121
  sig { returns(T::Boolean) }
127
- def raw_block? = false
122
+ def superscript? = false
128
123
  sig { returns(T::Boolean) }
129
- def metadata_block? = false
124
+ def highlight? = false
130
125
  sig { returns(T::Boolean) }
131
- def group? = false
126
+ def link? = false
132
127
  # @param hash [Hash] deserialized from the native extension
133
128
  # @return [self]
134
129
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
135
130
  def self.from_hash(hash)
136
- new(level: hash[:level] || hash["level"], text: hash[:text] || hash["text"])
131
+ new
137
132
  end
138
133
  end
139
- ## A paragraph of text.
140
- NodeContentParagraph = Data.define(:text) do
141
- include NodeContent
134
+ ## Italic / emphasis.
135
+ AnnotationKindItalic = Data.define do
136
+ include AnnotationKind
142
137
  extend T::Sig
143
138
 
144
- # The paragraph text content.
145
- sig { returns(String) }
146
- def text = super # rubocop:disable Lint/UselessMethodDefinition
147
- sig { returns(T::Boolean) }
148
- def heading? = false
149
139
  sig { returns(T::Boolean) }
150
- def paragraph? = true
151
- sig { returns(T::Boolean) }
152
- def list? = false
140
+ def bold? = false
153
141
  sig { returns(T::Boolean) }
154
- def list_item? = false
142
+ def italic? = true
155
143
  sig { returns(T::Boolean) }
156
- def table? = false
144
+ def underline? = false
157
145
  sig { returns(T::Boolean) }
158
- def image? = false
146
+ def strikethrough? = false
159
147
  sig { returns(T::Boolean) }
160
148
  def code? = false
161
149
  sig { returns(T::Boolean) }
162
- def quote? = false
163
- sig { returns(T::Boolean) }
164
- def definition_list? = false
165
- sig { returns(T::Boolean) }
166
- def definition_item? = false
150
+ def subscript? = false
167
151
  sig { returns(T::Boolean) }
168
- def raw_block? = false
152
+ def superscript? = false
169
153
  sig { returns(T::Boolean) }
170
- def metadata_block? = false
154
+ def highlight? = false
171
155
  sig { returns(T::Boolean) }
172
- def group? = false
156
+ def link? = false
173
157
  # @param hash [Hash] deserialized from the native extension
174
158
  # @return [self]
175
159
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
176
160
  def self.from_hash(hash)
177
- new(text: hash[:text] || hash["text"])
161
+ new
178
162
  end
179
163
  end
180
- ## A list container (ordered or unordered). Children are `ListItem` nodes.
181
- NodeContentList = Data.define(:ordered) do
182
- include NodeContent
164
+ ## Underline.
165
+ AnnotationKindUnderline = Data.define do
166
+ include AnnotationKind
183
167
  extend T::Sig
184
168
 
185
- # Whether this is an ordered list.
186
- sig { returns(T::Boolean) }
187
- def ordered = super # rubocop:disable Lint/UselessMethodDefinition
188
169
  sig { returns(T::Boolean) }
189
- def heading? = false
190
- sig { returns(T::Boolean) }
191
- def paragraph? = false
192
- sig { returns(T::Boolean) }
193
- def list? = true
170
+ def bold? = false
194
171
  sig { returns(T::Boolean) }
195
- def list_item? = false
172
+ def italic? = false
196
173
  sig { returns(T::Boolean) }
197
- def table? = false
174
+ def underline? = true
198
175
  sig { returns(T::Boolean) }
199
- def image? = false
176
+ def strikethrough? = false
200
177
  sig { returns(T::Boolean) }
201
178
  def code? = false
202
179
  sig { returns(T::Boolean) }
203
- def quote? = false
204
- sig { returns(T::Boolean) }
205
- def definition_list? = false
206
- sig { returns(T::Boolean) }
207
- def definition_item? = false
180
+ def subscript? = false
208
181
  sig { returns(T::Boolean) }
209
- def raw_block? = false
182
+ def superscript? = false
210
183
  sig { returns(T::Boolean) }
211
- def metadata_block? = false
184
+ def highlight? = false
212
185
  sig { returns(T::Boolean) }
213
- def group? = false
186
+ def link? = false
214
187
  # @param hash [Hash] deserialized from the native extension
215
188
  # @return [self]
216
189
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
217
190
  def self.from_hash(hash)
218
- new(ordered: hash[:ordered] || hash["ordered"])
191
+ new
219
192
  end
220
193
  end
221
- ## A single list item.
222
- NodeContentListItem = Data.define(:text) do
223
- include NodeContent
194
+ ## Strikethrough / deleted text.
195
+ AnnotationKindStrikethrough = Data.define do
196
+ include AnnotationKind
224
197
  extend T::Sig
225
198
 
226
- # The list item text content.
227
- sig { returns(String) }
228
- def text = super # rubocop:disable Lint/UselessMethodDefinition
229
- sig { returns(T::Boolean) }
230
- def heading? = false
231
199
  sig { returns(T::Boolean) }
232
- def paragraph? = false
233
- sig { returns(T::Boolean) }
234
- def list? = false
200
+ def bold? = false
235
201
  sig { returns(T::Boolean) }
236
- def list_item? = true
202
+ def italic? = false
237
203
  sig { returns(T::Boolean) }
238
- def table? = false
204
+ def underline? = false
239
205
  sig { returns(T::Boolean) }
240
- def image? = false
206
+ def strikethrough? = true
241
207
  sig { returns(T::Boolean) }
242
208
  def code? = false
243
209
  sig { returns(T::Boolean) }
244
- def quote? = false
245
- sig { returns(T::Boolean) }
246
- def definition_list? = false
247
- sig { returns(T::Boolean) }
248
- def definition_item? = false
210
+ def subscript? = false
249
211
  sig { returns(T::Boolean) }
250
- def raw_block? = false
212
+ def superscript? = false
251
213
  sig { returns(T::Boolean) }
252
- def metadata_block? = false
214
+ def highlight? = false
253
215
  sig { returns(T::Boolean) }
254
- def group? = false
216
+ def link? = false
255
217
  # @param hash [Hash] deserialized from the native extension
256
218
  # @return [self]
257
219
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
258
220
  def self.from_hash(hash)
259
- new(text: hash[:text] || hash["text"])
221
+ new
260
222
  end
261
223
  end
262
- ## A table with structured cell data.
263
- NodeContentTable = Data.define(:grid) do
264
- include NodeContent
224
+ ## Inline code.
225
+ AnnotationKindCode = Data.define do
226
+ include AnnotationKind
265
227
  extend T::Sig
266
228
 
267
- # The table grid structure.
268
- sig { returns(TableGrid) }
269
- def grid = super # rubocop:disable Lint/UselessMethodDefinition
270
- sig { returns(T::Boolean) }
271
- def heading? = false
272
- sig { returns(T::Boolean) }
273
- def paragraph? = false
274
229
  sig { returns(T::Boolean) }
275
- def list? = false
276
- sig { returns(T::Boolean) }
277
- def list_item? = false
278
- sig { returns(T::Boolean) }
279
- def table? = true
230
+ def bold? = false
280
231
  sig { returns(T::Boolean) }
281
- def image? = false
232
+ def italic? = false
282
233
  sig { returns(T::Boolean) }
283
- def code? = false
234
+ def underline? = false
284
235
  sig { returns(T::Boolean) }
285
- def quote? = false
236
+ def strikethrough? = false
286
237
  sig { returns(T::Boolean) }
287
- def definition_list? = false
238
+ def code? = true
288
239
  sig { returns(T::Boolean) }
289
- def definition_item? = false
240
+ def subscript? = false
290
241
  sig { returns(T::Boolean) }
291
- def raw_block? = false
242
+ def superscript? = false
292
243
  sig { returns(T::Boolean) }
293
- def metadata_block? = false
244
+ def highlight? = false
294
245
  sig { returns(T::Boolean) }
295
- def group? = false
246
+ def link? = false
296
247
  # @param hash [Hash] deserialized from the native extension
297
248
  # @return [self]
298
249
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
299
250
  def self.from_hash(hash)
300
- new(grid: hash[:grid] || hash["grid"])
251
+ new
301
252
  end
302
253
  end
303
- ## An image element.
304
- NodeContentImage = Data.define(:description, :src, :image_index) do
305
- include NodeContent
254
+ ## Subscript text.
255
+ AnnotationKindSubscript = Data.define do
256
+ include AnnotationKind
306
257
  extend T::Sig
307
258
 
308
- # Alt text or caption.
309
- sig { returns(T.nilable(String)) }
310
- def description = super # rubocop:disable Lint/UselessMethodDefinition
311
- # Image source URL.
312
- sig { returns(T.nilable(String)) }
313
- def src = super # rubocop:disable Lint/UselessMethodDefinition
314
- # Index into `ConversionResult.images` when image extraction is enabled.
315
- sig { returns(T.nilable(Integer)) }
316
- def image_index = super # rubocop:disable Lint/UselessMethodDefinition
317
- sig { returns(T::Boolean) }
318
- def heading? = false
319
- sig { returns(T::Boolean) }
320
- def paragraph? = false
321
259
  sig { returns(T::Boolean) }
322
- def list? = false
260
+ def bold? = false
323
261
  sig { returns(T::Boolean) }
324
- def list_item? = false
262
+ def italic? = false
325
263
  sig { returns(T::Boolean) }
326
- def table? = false
264
+ def underline? = false
327
265
  sig { returns(T::Boolean) }
328
- def image? = true
266
+ def strikethrough? = false
329
267
  sig { returns(T::Boolean) }
330
268
  def code? = false
331
269
  sig { returns(T::Boolean) }
332
- def quote? = false
333
- sig { returns(T::Boolean) }
334
- def definition_list? = false
335
- sig { returns(T::Boolean) }
336
- def definition_item? = false
270
+ def subscript? = true
337
271
  sig { returns(T::Boolean) }
338
- def raw_block? = false
272
+ def superscript? = false
339
273
  sig { returns(T::Boolean) }
340
- def metadata_block? = false
274
+ def highlight? = false
341
275
  sig { returns(T::Boolean) }
342
- def group? = false
276
+ def link? = false
343
277
  # @param hash [Hash] deserialized from the native extension
344
278
  # @return [self]
345
279
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
346
280
  def self.from_hash(hash)
347
- new(description: hash[:description] || hash["description"], src: hash[:src] || hash["src"], image_index: hash[:image_index] || hash["image_index"])
281
+ new
348
282
  end
349
283
  end
350
- ## A code block or inline code.
351
- NodeContentCode = Data.define(:text, :language) do
352
- include NodeContent
284
+ ## Superscript text.
285
+ AnnotationKindSuperscript = Data.define do
286
+ include AnnotationKind
353
287
  extend T::Sig
354
288
 
355
- # The code text content.
356
- sig { returns(String) }
357
- def text = super # rubocop:disable Lint/UselessMethodDefinition
358
- # Programming language (from class="language-*" or similar).
359
- sig { returns(T.nilable(String)) }
360
- def language = super # rubocop:disable Lint/UselessMethodDefinition
361
- sig { returns(T::Boolean) }
362
- def heading? = false
363
- sig { returns(T::Boolean) }
364
- def paragraph? = false
365
- sig { returns(T::Boolean) }
366
- def list? = false
367
- sig { returns(T::Boolean) }
368
- def list_item? = false
369
289
  sig { returns(T::Boolean) }
370
- def table? = false
290
+ def bold? = false
371
291
  sig { returns(T::Boolean) }
372
- def image? = false
292
+ def italic? = false
373
293
  sig { returns(T::Boolean) }
374
- def code? = true
294
+ def underline? = false
375
295
  sig { returns(T::Boolean) }
376
- def quote? = false
296
+ def strikethrough? = false
377
297
  sig { returns(T::Boolean) }
378
- def definition_list? = false
298
+ def code? = false
379
299
  sig { returns(T::Boolean) }
380
- def definition_item? = false
300
+ def subscript? = false
381
301
  sig { returns(T::Boolean) }
382
- def raw_block? = false
302
+ def superscript? = true
383
303
  sig { returns(T::Boolean) }
384
- def metadata_block? = false
304
+ def highlight? = false
385
305
  sig { returns(T::Boolean) }
386
- def group? = false
306
+ def link? = false
387
307
  # @param hash [Hash] deserialized from the native extension
388
308
  # @return [self]
389
309
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
390
310
  def self.from_hash(hash)
391
- new(text: hash[:text] || hash["text"], language: hash[:language] || hash["language"])
311
+ new
392
312
  end
393
313
  end
394
- ## A block quote container.
395
- NodeContentQuote = Data.define do
396
- include NodeContent
314
+ ## Highlighted / marked text.
315
+ AnnotationKindHighlight = Data.define do
316
+ include AnnotationKind
397
317
  extend T::Sig
398
318
 
399
319
  sig { returns(T::Boolean) }
400
- def heading? = false
320
+ def bold? = false
401
321
  sig { returns(T::Boolean) }
402
- def paragraph? = false
322
+ def italic? = false
403
323
  sig { returns(T::Boolean) }
404
- def list? = false
324
+ def underline? = false
405
325
  sig { returns(T::Boolean) }
406
- def list_item? = false
326
+ def strikethrough? = false
407
327
  sig { returns(T::Boolean) }
408
- def table? = false
328
+ def code? = false
409
329
  sig { returns(T::Boolean) }
410
- def image? = false
330
+ def subscript? = false
411
331
  sig { returns(T::Boolean) }
412
- def code? = false
332
+ def superscript? = false
413
333
  sig { returns(T::Boolean) }
414
- def quote? = true
334
+ def highlight? = true
415
335
  sig { returns(T::Boolean) }
416
- def definition_list? = false
336
+ def link? = false
337
+ # @param hash [Hash] deserialized from the native extension
338
+ # @return [self]
339
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
340
+ def self.from_hash(hash)
341
+ new
342
+ end
343
+ end
344
+ ## A hyperlink sourced from an `<a href="...">` element.
345
+ AnnotationKindLink = Data.define(:url, :title) do
346
+ include AnnotationKind
347
+ extend T::Sig
348
+
349
+ # The URL from the `href` attribute, copied verbatim from the source HTML.
350
+ #
351
+ # No URL decoding or normalization is performed: percent-encoded sequences, relative
352
+ # paths, and protocol-relative URLs (`//example.com`) are all preserved exactly as
353
+ # written in the source. Callers that need an absolute URL must resolve it against the
354
+ # document base URL themselves.
355
+ sig { returns(String) }
356
+ # rubocop:disable Lint/UselessMethodDefinition
357
+ def url = super
358
+ # The `title` attribute of the `<a>` element, if present.
359
+ #
360
+ # `None` when the `<a>` tag has no `title="..."` attribute. When present, the value
361
+ # is copied verbatim — HTML entities within the title are not decoded.
362
+ sig { returns(T.nilable(String)) }
363
+ # rubocop:disable Lint/UselessMethodDefinition
364
+ def title = super
417
365
  sig { returns(T::Boolean) }
418
- def definition_item? = false
366
+ def bold? = false
419
367
  sig { returns(T::Boolean) }
420
- def raw_block? = false
368
+ def italic? = false
421
369
  sig { returns(T::Boolean) }
422
- def metadata_block? = false
370
+ def underline? = false
423
371
  sig { returns(T::Boolean) }
424
- def group? = false
372
+ def strikethrough? = false
373
+ sig { returns(T::Boolean) }
374
+ def code? = false
375
+ sig { returns(T::Boolean) }
376
+ def subscript? = false
377
+ sig { returns(T::Boolean) }
378
+ def superscript? = false
379
+ sig { returns(T::Boolean) }
380
+ def highlight? = false
381
+ sig { returns(T::Boolean) }
382
+ def link? = true
425
383
  # @param hash [Hash] deserialized from the native extension
426
384
  # @return [self]
427
385
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
428
386
  def self.from_hash(hash)
429
- new
387
+ new(url: hash[:url] || hash["url"], title: hash[:title] || hash["title"])
430
388
  end
431
389
  end
432
- ## A definition list container.
433
- NodeContentDefinitionList = Data.define do
390
+ end
391
+
392
+ module HtmlToMarkdown
393
+ # The semantic content type of a document node.
394
+ #
395
+ # Uses internally tagged representation (`"node_type": "heading"`) for JSON serialization.
396
+ module NodeContent
397
+ extend T::Helpers
398
+ extend T::Sig
399
+
400
+ interface!
401
+
402
+ # Dispatch from a Hash to the appropriate variant constructor.
403
+ # @param hash [Hash] with discriminator field and variant-specific fields
404
+ # @return [variant_class] an instance of the appropriate variant
405
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
406
+ def self.from_hash(hash)
407
+ discriminator = hash[:node_type] || hash["node_type"]
408
+ case discriminator
409
+ when "heading"
410
+ NodeContentHeading.from_hash(hash)
411
+ when "paragraph"
412
+ NodeContentParagraph.from_hash(hash)
413
+ when "list"
414
+ NodeContentList.from_hash(hash)
415
+ when "list_item"
416
+ NodeContentListItem.from_hash(hash)
417
+ when "table"
418
+ NodeContentTable.from_hash(hash)
419
+ when "image"
420
+ NodeContentImage.from_hash(hash)
421
+ when "code"
422
+ NodeContentCode.from_hash(hash)
423
+ when "quote"
424
+ NodeContentQuote.from_hash(hash)
425
+ when "definition_list"
426
+ NodeContentDefinitionList.from_hash(hash)
427
+ when "definition_item"
428
+ NodeContentDefinitionItem.from_hash(hash)
429
+ when "raw_block"
430
+ NodeContentRawBlock.from_hash(hash)
431
+ when "metadata_block"
432
+ NodeContentMetadataBlock.from_hash(hash)
433
+ when "group"
434
+ NodeContentGroup.from_hash(hash)
435
+ else
436
+ raise "Unknown discriminator: #{discriminator}"
437
+ end
438
+ end
439
+ end
440
+ ## A heading element (h1-h6).
441
+ NodeContentHeading = Data.define(:level, :text) do
434
442
  include NodeContent
435
443
  extend T::Sig
436
444
 
445
+ # Heading level (1-6).
446
+ sig { returns(Integer) }
447
+ # rubocop:disable Lint/UselessMethodDefinition
448
+ def level = super
449
+ # The heading text content.
450
+ sig { returns(String) }
451
+ # rubocop:disable Lint/UselessMethodDefinition
452
+ def text = super
437
453
  sig { returns(T::Boolean) }
438
- def heading? = false
454
+ def heading? = true
439
455
  sig { returns(T::Boolean) }
440
456
  def paragraph? = false
441
457
  sig { returns(T::Boolean) }
@@ -451,7 +467,7 @@ module HtmlToMarkdown
451
467
  sig { returns(T::Boolean) }
452
468
  def quote? = false
453
469
  sig { returns(T::Boolean) }
454
- def definition_list? = true
470
+ def definition_list? = false
455
471
  sig { returns(T::Boolean) }
456
472
  def definition_item? = false
457
473
  sig { returns(T::Boolean) }
@@ -464,24 +480,22 @@ module HtmlToMarkdown
464
480
  # @return [self]
465
481
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
466
482
  def self.from_hash(hash)
467
- new
483
+ new(level: hash[:level] || hash["level"], text: hash[:text] || hash["text"])
468
484
  end
469
485
  end
470
- ## A definition list entry with term and description.
471
- NodeContentDefinitionItem = Data.define(:term, :definition) do
486
+ ## A paragraph of text.
487
+ NodeContentParagraph = Data.define(:text) do
472
488
  include NodeContent
473
489
  extend T::Sig
474
490
 
475
- # The term being defined.
476
- sig { returns(String) }
477
- def term = super # rubocop:disable Lint/UselessMethodDefinition
478
- # The definition text.
491
+ # The paragraph text content.
479
492
  sig { returns(String) }
480
- def definition = super # rubocop:disable Lint/UselessMethodDefinition
493
+ # rubocop:disable Lint/UselessMethodDefinition
494
+ def text = super
481
495
  sig { returns(T::Boolean) }
482
496
  def heading? = false
483
497
  sig { returns(T::Boolean) }
484
- def paragraph? = false
498
+ def paragraph? = true
485
499
  sig { returns(T::Boolean) }
486
500
  def list? = false
487
501
  sig { returns(T::Boolean) }
@@ -497,7 +511,7 @@ module HtmlToMarkdown
497
511
  sig { returns(T::Boolean) }
498
512
  def definition_list? = false
499
513
  sig { returns(T::Boolean) }
500
- def definition_item? = true
514
+ def definition_item? = false
501
515
  sig { returns(T::Boolean) }
502
516
  def raw_block? = false
503
517
  sig { returns(T::Boolean) }
@@ -508,26 +522,24 @@ module HtmlToMarkdown
508
522
  # @return [self]
509
523
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
510
524
  def self.from_hash(hash)
511
- new(term: hash[:term] || hash["term"], definition: hash[:definition] || hash["definition"])
525
+ new(text: hash[:text] || hash["text"])
512
526
  end
513
527
  end
514
- ## A raw block preserved as-is (e.g. `<script>`, `<style>` content).
515
- NodeContentRawBlock = Data.define(:format, :content) do
528
+ ## A list container (ordered or unordered). Children are `ListItem` nodes.
529
+ NodeContentList = Data.define(:ordered) do
516
530
  include NodeContent
517
531
  extend T::Sig
518
532
 
519
- # The format of the raw content (e.g. "html", "css", "javascript").
520
- sig { returns(String) }
521
- def format = super # rubocop:disable Lint/UselessMethodDefinition
522
- # The raw content.
523
- sig { returns(String) }
524
- def content = super # rubocop:disable Lint/UselessMethodDefinition
533
+ # Whether this is an ordered list.
534
+ sig { returns(T::Boolean) }
535
+ # rubocop:disable Lint/UselessMethodDefinition
536
+ def ordered = super
525
537
  sig { returns(T::Boolean) }
526
538
  def heading? = false
527
539
  sig { returns(T::Boolean) }
528
540
  def paragraph? = false
529
541
  sig { returns(T::Boolean) }
530
- def list? = false
542
+ def list? = true
531
543
  sig { returns(T::Boolean) }
532
544
  def list_item? = false
533
545
  sig { returns(T::Boolean) }
@@ -543,7 +555,7 @@ module HtmlToMarkdown
543
555
  sig { returns(T::Boolean) }
544
556
  def definition_item? = false
545
557
  sig { returns(T::Boolean) }
546
- def raw_block? = true
558
+ def raw_block? = false
547
559
  sig { returns(T::Boolean) }
548
560
  def metadata_block? = false
549
561
  sig { returns(T::Boolean) }
@@ -552,17 +564,18 @@ module HtmlToMarkdown
552
564
  # @return [self]
553
565
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
554
566
  def self.from_hash(hash)
555
- new(format: hash[:format] || hash["format"], content: hash[:content] || hash["content"])
567
+ new(ordered: hash[:ordered] || hash["ordered"])
556
568
  end
557
569
  end
558
- ## A block of key-value metadata pairs (from `<head>` meta tags).
559
- NodeContentMetadataBlock = Data.define(:entries) do
570
+ ## A single list item.
571
+ NodeContentListItem = Data.define(:text) do
560
572
  include NodeContent
561
573
  extend T::Sig
562
574
 
563
- # Key-value metadata pairs.
564
- sig { returns(T::Array[MetadataEntry]) }
565
- def entries = super # rubocop:disable Lint/UselessMethodDefinition
575
+ # The list item text content.
576
+ sig { returns(String) }
577
+ # rubocop:disable Lint/UselessMethodDefinition
578
+ def text = super
566
579
  sig { returns(T::Boolean) }
567
580
  def heading? = false
568
581
  sig { returns(T::Boolean) }
@@ -570,7 +583,7 @@ module HtmlToMarkdown
570
583
  sig { returns(T::Boolean) }
571
584
  def list? = false
572
585
  sig { returns(T::Boolean) }
573
- def list_item? = false
586
+ def list_item? = true
574
587
  sig { returns(T::Boolean) }
575
588
  def table? = false
576
589
  sig { returns(T::Boolean) }
@@ -586,30 +599,25 @@ module HtmlToMarkdown
586
599
  sig { returns(T::Boolean) }
587
600
  def raw_block? = false
588
601
  sig { returns(T::Boolean) }
589
- def metadata_block? = true
602
+ def metadata_block? = false
590
603
  sig { returns(T::Boolean) }
591
604
  def group? = false
592
605
  # @param hash [Hash] deserialized from the native extension
593
606
  # @return [self]
594
607
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
595
608
  def self.from_hash(hash)
596
- new(entries: hash[:entries] || hash["entries"])
609
+ new(text: hash[:text] || hash["text"])
597
610
  end
598
611
  end
599
- ## A section grouping container (auto-generated from heading hierarchy).
600
- NodeContentGroup = Data.define(:label, :heading_level, :heading_text) do
612
+ ## A table with structured cell data.
613
+ NodeContentTable = Data.define(:grid) do
601
614
  include NodeContent
602
615
  extend T::Sig
603
616
 
604
- # Optional section label.
605
- sig { returns(T.nilable(String)) }
606
- def label = super # rubocop:disable Lint/UselessMethodDefinition
607
- # The heading level that created this group.
608
- sig { returns(T.nilable(Integer)) }
609
- def heading_level = super # rubocop:disable Lint/UselessMethodDefinition
610
- # The heading text that created this group.
611
- sig { returns(T.nilable(String)) }
612
- def heading_text = super # rubocop:disable Lint/UselessMethodDefinition
617
+ # The table grid structure.
618
+ sig { returns(TableGrid) }
619
+ # rubocop:disable Lint/UselessMethodDefinition
620
+ def grid = super
613
621
  sig { returns(T::Boolean) }
614
622
  def heading? = false
615
623
  sig { returns(T::Boolean) }
@@ -619,7 +627,7 @@ module HtmlToMarkdown
619
627
  sig { returns(T::Boolean) }
620
628
  def list_item? = false
621
629
  sig { returns(T::Boolean) }
622
- def table? = false
630
+ def table? = true
623
631
  sig { returns(T::Boolean) }
624
632
  def image? = false
625
633
  sig { returns(T::Boolean) }
@@ -635,159 +643,145 @@ module HtmlToMarkdown
635
643
  sig { returns(T::Boolean) }
636
644
  def metadata_block? = false
637
645
  sig { returns(T::Boolean) }
638
- def group? = true
646
+ def group? = false
639
647
  # @param hash [Hash] deserialized from the native extension
640
648
  # @return [self]
641
649
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
642
650
  def self.from_hash(hash)
643
- new(label: hash[:label] || hash["label"], heading_level: hash[:heading_level] || hash["heading_level"], heading_text: hash[:heading_text] || hash["heading_text"])
644
- end
645
- end
646
- end
647
-
648
- module HtmlToMarkdown
649
- # The type of an inline text annotation.
650
- #
651
- # Uses internally tagged representation (`"annotation_type": "bold"`) for JSON serialization.
652
- module AnnotationKind
653
- extend T::Helpers
654
- extend T::Sig
655
-
656
- interface!
657
-
658
- # Dispatch from a Hash to the appropriate variant constructor.
659
- # @param hash [Hash] with discriminator field and variant-specific fields
660
- # @return [variant_class] an instance of the appropriate variant
661
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
662
- def self.from_hash(hash)
663
- discriminator = hash[:annotation_type] || hash["annotation_type"]
664
- case discriminator
665
- when "bold" then AnnotationKindBold.from_hash(hash)
666
- when "italic" then AnnotationKindItalic.from_hash(hash)
667
- when "underline" then AnnotationKindUnderline.from_hash(hash)
668
- when "strikethrough" then AnnotationKindStrikethrough.from_hash(hash)
669
- when "code" then AnnotationKindCode.from_hash(hash)
670
- when "subscript" then AnnotationKindSubscript.from_hash(hash)
671
- when "superscript" then AnnotationKindSuperscript.from_hash(hash)
672
- when "highlight" then AnnotationKindHighlight.from_hash(hash)
673
- when "link" then AnnotationKindLink.from_hash(hash)
674
- else raise "Unknown discriminator: #{discriminator}"
675
- end
651
+ new(grid: hash[:grid] || hash["grid"])
676
652
  end
677
653
  end
678
- ## Bold / strong emphasis.
679
- AnnotationKindBold = Data.define do
680
- include AnnotationKind
654
+ ## An image element.
655
+ NodeContentImage = Data.define(:description, :src, :image_index) do
656
+ include NodeContent
681
657
  extend T::Sig
682
658
 
659
+ # Alt text or caption.
660
+ sig { returns(T.nilable(String)) }
661
+ # rubocop:disable Lint/UselessMethodDefinition
662
+ def description = super
663
+ # Image source URL.
664
+ sig { returns(T.nilable(String)) }
665
+ # rubocop:disable Lint/UselessMethodDefinition
666
+ def src = super
667
+ # Index into `ConversionResult.images` when image extraction is enabled.
668
+ sig { returns(T.nilable(Integer)) }
669
+ # rubocop:disable Lint/UselessMethodDefinition
670
+ def image_index = super
683
671
  sig { returns(T::Boolean) }
684
- def bold? = true
672
+ def heading? = false
685
673
  sig { returns(T::Boolean) }
686
- def italic? = false
674
+ def paragraph? = false
687
675
  sig { returns(T::Boolean) }
688
- def underline? = false
676
+ def list? = false
689
677
  sig { returns(T::Boolean) }
690
- def strikethrough? = false
678
+ def list_item? = false
679
+ sig { returns(T::Boolean) }
680
+ def table? = false
681
+ sig { returns(T::Boolean) }
682
+ def image? = true
691
683
  sig { returns(T::Boolean) }
692
684
  def code? = false
693
685
  sig { returns(T::Boolean) }
694
- def subscript? = false
686
+ def quote? = false
695
687
  sig { returns(T::Boolean) }
696
- def superscript? = false
688
+ def definition_list? = false
697
689
  sig { returns(T::Boolean) }
698
- def highlight? = false
690
+ def definition_item? = false
699
691
  sig { returns(T::Boolean) }
700
- def link? = false
692
+ def raw_block? = false
693
+ sig { returns(T::Boolean) }
694
+ def metadata_block? = false
695
+ sig { returns(T::Boolean) }
696
+ def group? = false
701
697
  # @param hash [Hash] deserialized from the native extension
702
698
  # @return [self]
703
699
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
704
700
  def self.from_hash(hash)
705
- new
701
+ new(
702
+ description: hash[:description] || hash["description"],
703
+ src: hash[:src] || hash["src"],
704
+ image_index: hash[:image_index] || hash["image_index"]
705
+ )
706
706
  end
707
707
  end
708
- ## Italic / emphasis.
709
- AnnotationKindItalic = Data.define do
710
- include AnnotationKind
708
+ ## A code block or inline code.
709
+ NodeContentCode = Data.define(:text, :language) do
710
+ include NodeContent
711
711
  extend T::Sig
712
712
 
713
+ # The code text content.
714
+ sig { returns(String) }
715
+ # rubocop:disable Lint/UselessMethodDefinition
716
+ def text = super
717
+ # Programming language (from class="language-*" or similar).
718
+ sig { returns(T.nilable(String)) }
719
+ # rubocop:disable Lint/UselessMethodDefinition
720
+ def language = super
713
721
  sig { returns(T::Boolean) }
714
- def bold? = false
715
- sig { returns(T::Boolean) }
716
- def italic? = true
717
- sig { returns(T::Boolean) }
718
- def underline? = false
719
- sig { returns(T::Boolean) }
720
- def strikethrough? = false
721
- sig { returns(T::Boolean) }
722
- def code? = false
723
- sig { returns(T::Boolean) }
724
- def subscript? = false
722
+ def heading? = false
725
723
  sig { returns(T::Boolean) }
726
- def superscript? = false
724
+ def paragraph? = false
727
725
  sig { returns(T::Boolean) }
728
- def highlight? = false
726
+ def list? = false
729
727
  sig { returns(T::Boolean) }
730
- def link? = false
731
- # @param hash [Hash] deserialized from the native extension
732
- # @return [self]
733
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
734
- def self.from_hash(hash)
735
- new
736
- end
737
- end
738
- ## Underline.
739
- AnnotationKindUnderline = Data.define do
740
- include AnnotationKind
741
- extend T::Sig
742
-
728
+ def list_item? = false
743
729
  sig { returns(T::Boolean) }
744
- def bold? = false
730
+ def table? = false
745
731
  sig { returns(T::Boolean) }
746
- def italic? = false
732
+ def image? = false
747
733
  sig { returns(T::Boolean) }
748
- def underline? = true
734
+ def code? = true
749
735
  sig { returns(T::Boolean) }
750
- def strikethrough? = false
736
+ def quote? = false
751
737
  sig { returns(T::Boolean) }
752
- def code? = false
738
+ def definition_list? = false
753
739
  sig { returns(T::Boolean) }
754
- def subscript? = false
740
+ def definition_item? = false
755
741
  sig { returns(T::Boolean) }
756
- def superscript? = false
742
+ def raw_block? = false
757
743
  sig { returns(T::Boolean) }
758
- def highlight? = false
744
+ def metadata_block? = false
759
745
  sig { returns(T::Boolean) }
760
- def link? = false
746
+ def group? = false
761
747
  # @param hash [Hash] deserialized from the native extension
762
748
  # @return [self]
763
749
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
764
750
  def self.from_hash(hash)
765
- new
751
+ new(text: hash[:text] || hash["text"], language: hash[:language] || hash["language"])
766
752
  end
767
753
  end
768
- ## Strikethrough / deleted text.
769
- AnnotationKindStrikethrough = Data.define do
770
- include AnnotationKind
754
+ ## A block quote container.
755
+ NodeContentQuote = Data.define do
756
+ include NodeContent
771
757
  extend T::Sig
772
758
 
773
759
  sig { returns(T::Boolean) }
774
- def bold? = false
760
+ def heading? = false
775
761
  sig { returns(T::Boolean) }
776
- def italic? = false
762
+ def paragraph? = false
777
763
  sig { returns(T::Boolean) }
778
- def underline? = false
764
+ def list? = false
779
765
  sig { returns(T::Boolean) }
780
- def strikethrough? = true
766
+ def list_item? = false
767
+ sig { returns(T::Boolean) }
768
+ def table? = false
769
+ sig { returns(T::Boolean) }
770
+ def image? = false
781
771
  sig { returns(T::Boolean) }
782
772
  def code? = false
783
773
  sig { returns(T::Boolean) }
784
- def subscript? = false
774
+ def quote? = true
785
775
  sig { returns(T::Boolean) }
786
- def superscript? = false
776
+ def definition_list? = false
787
777
  sig { returns(T::Boolean) }
788
- def highlight? = false
778
+ def definition_item? = false
789
779
  sig { returns(T::Boolean) }
790
- def link? = false
780
+ def raw_block? = false
781
+ sig { returns(T::Boolean) }
782
+ def metadata_block? = false
783
+ sig { returns(T::Boolean) }
784
+ def group? = false
791
785
  # @param hash [Hash] deserialized from the native extension
792
786
  # @return [self]
793
787
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
@@ -795,29 +789,37 @@ module HtmlToMarkdown
795
789
  new
796
790
  end
797
791
  end
798
- ## Inline code.
799
- AnnotationKindCode = Data.define do
800
- include AnnotationKind
792
+ ## A definition list container.
793
+ NodeContentDefinitionList = Data.define do
794
+ include NodeContent
801
795
  extend T::Sig
802
796
 
803
797
  sig { returns(T::Boolean) }
804
- def bold? = false
798
+ def heading? = false
805
799
  sig { returns(T::Boolean) }
806
- def italic? = false
800
+ def paragraph? = false
807
801
  sig { returns(T::Boolean) }
808
- def underline? = false
802
+ def list? = false
809
803
  sig { returns(T::Boolean) }
810
- def strikethrough? = false
804
+ def list_item? = false
811
805
  sig { returns(T::Boolean) }
812
- def code? = true
806
+ def table? = false
813
807
  sig { returns(T::Boolean) }
814
- def subscript? = false
808
+ def image? = false
815
809
  sig { returns(T::Boolean) }
816
- def superscript? = false
810
+ def code? = false
817
811
  sig { returns(T::Boolean) }
818
- def highlight? = false
812
+ def quote? = false
819
813
  sig { returns(T::Boolean) }
820
- def link? = false
814
+ def definition_list? = true
815
+ sig { returns(T::Boolean) }
816
+ def definition_item? = false
817
+ sig { returns(T::Boolean) }
818
+ def raw_block? = false
819
+ sig { returns(T::Boolean) }
820
+ def metadata_block? = false
821
+ sig { returns(T::Boolean) }
822
+ def group? = false
821
823
  # @param hash [Hash] deserialized from the native extension
822
824
  # @return [self]
823
825
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
@@ -825,138 +827,192 @@ module HtmlToMarkdown
825
827
  new
826
828
  end
827
829
  end
828
- ## Subscript text.
829
- AnnotationKindSubscript = Data.define do
830
- include AnnotationKind
830
+ ## A definition list entry with term and description.
831
+ NodeContentDefinitionItem = Data.define(:term, :definition) do
832
+ include NodeContent
831
833
  extend T::Sig
832
834
 
835
+ # The term being defined.
836
+ sig { returns(String) }
837
+ # rubocop:disable Lint/UselessMethodDefinition
838
+ def term = super
839
+ # The definition text.
840
+ sig { returns(String) }
841
+ # rubocop:disable Lint/UselessMethodDefinition
842
+ def definition = super
833
843
  sig { returns(T::Boolean) }
834
- def bold? = false
844
+ def heading? = false
835
845
  sig { returns(T::Boolean) }
836
- def italic? = false
846
+ def paragraph? = false
837
847
  sig { returns(T::Boolean) }
838
- def underline? = false
848
+ def list? = false
839
849
  sig { returns(T::Boolean) }
840
- def strikethrough? = false
850
+ def list_item? = false
851
+ sig { returns(T::Boolean) }
852
+ def table? = false
853
+ sig { returns(T::Boolean) }
854
+ def image? = false
841
855
  sig { returns(T::Boolean) }
842
856
  def code? = false
843
857
  sig { returns(T::Boolean) }
844
- def subscript? = true
858
+ def quote? = false
845
859
  sig { returns(T::Boolean) }
846
- def superscript? = false
860
+ def definition_list? = false
847
861
  sig { returns(T::Boolean) }
848
- def highlight? = false
862
+ def definition_item? = true
849
863
  sig { returns(T::Boolean) }
850
- def link? = false
864
+ def raw_block? = false
865
+ sig { returns(T::Boolean) }
866
+ def metadata_block? = false
867
+ sig { returns(T::Boolean) }
868
+ def group? = false
851
869
  # @param hash [Hash] deserialized from the native extension
852
870
  # @return [self]
853
871
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
854
872
  def self.from_hash(hash)
855
- new
873
+ new(term: hash[:term] || hash["term"], definition: hash[:definition] || hash["definition"])
856
874
  end
857
875
  end
858
- ## Superscript text.
859
- AnnotationKindSuperscript = Data.define do
860
- include AnnotationKind
876
+ ## A raw block preserved as-is (e.g. `<script>`, `<style>` content).
877
+ NodeContentRawBlock = Data.define(:format, :content) do
878
+ include NodeContent
861
879
  extend T::Sig
862
880
 
881
+ # The format of the raw content (e.g. "html", "css", "javascript").
882
+ sig { returns(String) }
883
+ # rubocop:disable Lint/UselessMethodDefinition
884
+ def format = super
885
+ # The raw content.
886
+ sig { returns(String) }
887
+ # rubocop:disable Lint/UselessMethodDefinition
888
+ def content = super
863
889
  sig { returns(T::Boolean) }
864
- def bold? = false
890
+ def heading? = false
865
891
  sig { returns(T::Boolean) }
866
- def italic? = false
892
+ def paragraph? = false
867
893
  sig { returns(T::Boolean) }
868
- def underline? = false
894
+ def list? = false
869
895
  sig { returns(T::Boolean) }
870
- def strikethrough? = false
896
+ def list_item? = false
897
+ sig { returns(T::Boolean) }
898
+ def table? = false
899
+ sig { returns(T::Boolean) }
900
+ def image? = false
871
901
  sig { returns(T::Boolean) }
872
902
  def code? = false
873
903
  sig { returns(T::Boolean) }
874
- def subscript? = false
904
+ def quote? = false
875
905
  sig { returns(T::Boolean) }
876
- def superscript? = true
906
+ def definition_list? = false
877
907
  sig { returns(T::Boolean) }
878
- def highlight? = false
908
+ def definition_item? = false
879
909
  sig { returns(T::Boolean) }
880
- def link? = false
910
+ def raw_block? = true
911
+ sig { returns(T::Boolean) }
912
+ def metadata_block? = false
913
+ sig { returns(T::Boolean) }
914
+ def group? = false
881
915
  # @param hash [Hash] deserialized from the native extension
882
916
  # @return [self]
883
917
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
884
918
  def self.from_hash(hash)
885
- new
919
+ new(format: hash[:format] || hash["format"], content: hash[:content] || hash["content"])
886
920
  end
887
921
  end
888
- ## Highlighted / marked text.
889
- AnnotationKindHighlight = Data.define do
890
- include AnnotationKind
922
+ ## A block of key-value metadata pairs (from `<head>` meta tags).
923
+ NodeContentMetadataBlock = Data.define(:entries) do
924
+ include NodeContent
891
925
  extend T::Sig
892
926
 
927
+ # Key-value metadata pairs.
928
+ sig { returns(T::Array[MetadataEntry]) }
929
+ # rubocop:disable Lint/UselessMethodDefinition
930
+ def entries = super
893
931
  sig { returns(T::Boolean) }
894
- def bold? = false
932
+ def heading? = false
895
933
  sig { returns(T::Boolean) }
896
- def italic? = false
934
+ def paragraph? = false
897
935
  sig { returns(T::Boolean) }
898
- def underline? = false
936
+ def list? = false
899
937
  sig { returns(T::Boolean) }
900
- def strikethrough? = false
938
+ def list_item? = false
939
+ sig { returns(T::Boolean) }
940
+ def table? = false
941
+ sig { returns(T::Boolean) }
942
+ def image? = false
901
943
  sig { returns(T::Boolean) }
902
944
  def code? = false
903
945
  sig { returns(T::Boolean) }
904
- def subscript? = false
946
+ def quote? = false
905
947
  sig { returns(T::Boolean) }
906
- def superscript? = false
948
+ def definition_list? = false
907
949
  sig { returns(T::Boolean) }
908
- def highlight? = true
950
+ def definition_item? = false
909
951
  sig { returns(T::Boolean) }
910
- def link? = false
952
+ def raw_block? = false
953
+ sig { returns(T::Boolean) }
954
+ def metadata_block? = true
955
+ sig { returns(T::Boolean) }
956
+ def group? = false
911
957
  # @param hash [Hash] deserialized from the native extension
912
958
  # @return [self]
913
959
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
914
960
  def self.from_hash(hash)
915
- new
961
+ new(entries: hash[:entries] || hash["entries"])
916
962
  end
917
963
  end
918
- ## A hyperlink sourced from an `<a href="...">` element.
919
- AnnotationKindLink = Data.define(:url, :title) do
920
- include AnnotationKind
964
+ ## A section grouping container (auto-generated from heading hierarchy).
965
+ NodeContentGroup = Data.define(:label, :heading_level, :heading_text) do
966
+ include NodeContent
921
967
  extend T::Sig
922
968
 
923
- # The URL from the `href` attribute, copied verbatim from the source HTML.
924
- #
925
- # No URL decoding or normalization is performed: percent-encoded sequences, relative
926
- # paths, and protocol-relative URLs (`//example.com`) are all preserved exactly as
927
- # written in the source. Callers that need an absolute URL must resolve it against the
928
- # document base URL themselves.
929
- sig { returns(String) }
930
- def url = super # rubocop:disable Lint/UselessMethodDefinition
931
- # The `title` attribute of the `<a>` element, if present.
932
- #
933
- # `None` when the `<a>` tag has no `title="..."` attribute. When present, the value
934
- # is copied verbatim — HTML entities within the title are not decoded.
969
+ # Optional section label.
970
+ sig { returns(T.nilable(String)) }
971
+ # rubocop:disable Lint/UselessMethodDefinition
972
+ def label = super
973
+ # The heading level that created this group.
974
+ sig { returns(T.nilable(Integer)) }
975
+ # rubocop:disable Lint/UselessMethodDefinition
976
+ def heading_level = super
977
+ # The heading text that created this group.
935
978
  sig { returns(T.nilable(String)) }
936
- def title = super # rubocop:disable Lint/UselessMethodDefinition
979
+ # rubocop:disable Lint/UselessMethodDefinition
980
+ def heading_text = super
937
981
  sig { returns(T::Boolean) }
938
- def bold? = false
982
+ def heading? = false
939
983
  sig { returns(T::Boolean) }
940
- def italic? = false
984
+ def paragraph? = false
941
985
  sig { returns(T::Boolean) }
942
- def underline? = false
986
+ def list? = false
943
987
  sig { returns(T::Boolean) }
944
- def strikethrough? = false
988
+ def list_item? = false
989
+ sig { returns(T::Boolean) }
990
+ def table? = false
991
+ sig { returns(T::Boolean) }
992
+ def image? = false
945
993
  sig { returns(T::Boolean) }
946
994
  def code? = false
947
995
  sig { returns(T::Boolean) }
948
- def subscript? = false
996
+ def quote? = false
949
997
  sig { returns(T::Boolean) }
950
- def superscript? = false
998
+ def definition_list? = false
951
999
  sig { returns(T::Boolean) }
952
- def highlight? = false
1000
+ def definition_item? = false
953
1001
  sig { returns(T::Boolean) }
954
- def link? = true
1002
+ def raw_block? = false
1003
+ sig { returns(T::Boolean) }
1004
+ def metadata_block? = false
1005
+ sig { returns(T::Boolean) }
1006
+ def group? = true
955
1007
  # @param hash [Hash] deserialized from the native extension
956
1008
  # @return [self]
957
1009
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
958
1010
  def self.from_hash(hash)
959
- new(url: hash[:url] || hash["url"], title: hash[:title] || hash["title"])
1011
+ new(
1012
+ label: hash[:label] || hash["label"],
1013
+ heading_level: hash[:heading_level] || hash["heading_level"],
1014
+ heading_text: hash[:heading_text] || hash["heading_text"]
1015
+ )
960
1016
  end
961
1017
  end
962
1018
  end
@@ -980,12 +1036,18 @@ module HtmlToMarkdown
980
1036
  def self.from_hash(hash)
981
1037
  discriminator = hash[:type] || hash["type"]
982
1038
  case discriminator
983
- when "continue" then VisitResultContinue.from_hash(hash)
984
- when "custom" then VisitResultCustom.from_hash(hash)
985
- when "skip" then VisitResultSkip.from_hash(hash)
986
- when "preserve_html" then VisitResultPreserveHtml.from_hash(hash)
987
- when "error" then VisitResultError.from_hash(hash)
988
- else raise "Unknown discriminator: #{discriminator}"
1039
+ when "continue"
1040
+ VisitResultContinue.from_hash(hash)
1041
+ when "custom"
1042
+ VisitResultCustom.from_hash(hash)
1043
+ when "skip"
1044
+ VisitResultSkip.from_hash(hash)
1045
+ when "preserve_html"
1046
+ VisitResultPreserveHtml.from_hash(hash)
1047
+ when "error"
1048
+ VisitResultError.from_hash(hash)
1049
+ else
1050
+ raise "Unknown discriminator: #{discriminator}"
989
1051
  end
990
1052
  end
991
1053
  end
@@ -1021,7 +1083,8 @@ module HtmlToMarkdown
1021
1083
 
1022
1084
  # @return [String]
1023
1085
  sig { returns(String) }
1024
- def value = super # rubocop:disable Lint/UselessMethodDefinition
1086
+ # rubocop:disable Lint/UselessMethodDefinition
1087
+ def value = super
1025
1088
  sig { returns(T::Boolean) }
1026
1089
  def continue? = false
1027
1090
  sig { returns(T::Boolean) }
@@ -1096,7 +1159,8 @@ module HtmlToMarkdown
1096
1159
 
1097
1160
  # @return [String]
1098
1161
  sig { returns(String) }
1099
- def value = super # rubocop:disable Lint/UselessMethodDefinition
1162
+ # rubocop:disable Lint/UselessMethodDefinition
1163
+ def value = super
1100
1164
  sig { returns(T::Boolean) }
1101
1165
  def continue? = false
1102
1166
  sig { returns(T::Boolean) }