html-to-markdown 3.11.4 → 3.11.6

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