html-to-markdown 3.4.0 → 3.6.0.pre.rc.24
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.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +347 -0
- data/Steepfile +10 -2
- data/ext/html_to_markdown_rb/Cargo.toml +3 -2
- data/ext/html_to_markdown_rb/extconf.rb +5 -5
- data/ext/html_to_markdown_rb/native/Cargo.lock +962 -0
- data/ext/html_to_markdown_rb/native/Cargo.toml +6 -11
- data/ext/html_to_markdown_rb/native/extconf.rb +14 -0
- data/ext/html_to_markdown_rb/src/lib.rs +1715 -646
- data/lib/html_to_markdown/native.rb +913 -37
- data/lib/html_to_markdown/version.rb +3 -3
- data/lib/html_to_markdown.rb +9 -4
- data/lib/html_to_markdown_rb.so +0 -0
- data/sig/types.rbs +59 -292
- metadata +32 -179
- data/ext/html_to_markdown_rb/Makefile +0 -592
- data/lib/bin/html-to-markdown +0 -0
- data/vendor/Cargo.toml +0 -33
- data/vendor/html-to-markdown-rs/Cargo.toml +0 -54
- data/vendor/html-to-markdown-rs/README.md +0 -278
- data/vendor/html-to-markdown-rs/examples/basic.rs +0 -24
- data/vendor/html-to-markdown-rs/examples/table.rs +0 -25
- data/vendor/html-to-markdown-rs/examples/test_deser.rs +0 -12
- data/vendor/html-to-markdown-rs/examples/test_escape.rs +0 -58
- data/vendor/html-to-markdown-rs/examples/test_inline_formatting.rs +0 -113
- data/vendor/html-to-markdown-rs/examples/test_lists.rs +0 -39
- data/vendor/html-to-markdown-rs/examples/test_semantic_tags.rs +0 -89
- data/vendor/html-to-markdown-rs/examples/test_tables.rs +0 -100
- data/vendor/html-to-markdown-rs/examples/test_task_lists.rs +0 -61
- data/vendor/html-to-markdown-rs/examples/test_whitespace.rs +0 -34
- data/vendor/html-to-markdown-rs/src/convert_api.rs +0 -349
- data/vendor/html-to-markdown-rs/src/converter/block/blockquote.rs +0 -178
- data/vendor/html-to-markdown-rs/src/converter/block/container.rs +0 -114
- data/vendor/html-to-markdown-rs/src/converter/block/div.rs +0 -149
- data/vendor/html-to-markdown-rs/src/converter/block/heading.rs +0 -428
- data/vendor/html-to-markdown-rs/src/converter/block/horizontal_rule.rs +0 -103
- data/vendor/html-to-markdown-rs/src/converter/block/line_break.rs +0 -89
- data/vendor/html-to-markdown-rs/src/converter/block/mod.rs +0 -10
- data/vendor/html-to-markdown-rs/src/converter/block/paragraph.rs +0 -140
- data/vendor/html-to-markdown-rs/src/converter/block/preformatted.rs +0 -298
- data/vendor/html-to-markdown-rs/src/converter/block/table/builder.rs +0 -453
- data/vendor/html-to-markdown-rs/src/converter/block/table/caption.rs +0 -44
- data/vendor/html-to-markdown-rs/src/converter/block/table/cell.rs +0 -276
- data/vendor/html-to-markdown-rs/src/converter/block/table/cells.rs +0 -336
- data/vendor/html-to-markdown-rs/src/converter/block/table/layout.rs +0 -58
- data/vendor/html-to-markdown-rs/src/converter/block/table/mod.rs +0 -266
- data/vendor/html-to-markdown-rs/src/converter/block/table/scanner.rs +0 -146
- data/vendor/html-to-markdown-rs/src/converter/block/table/utils.rs +0 -34
- data/vendor/html-to-markdown-rs/src/converter/block/unknown.rs +0 -138
- data/vendor/html-to-markdown-rs/src/converter/context.rs +0 -208
- data/vendor/html-to-markdown-rs/src/converter/dom_context.rs +0 -337
- data/vendor/html-to-markdown-rs/src/converter/form/elements.rs +0 -770
- data/vendor/html-to-markdown-rs/src/converter/form/mod.rs +0 -82
- data/vendor/html-to-markdown-rs/src/converter/format/djot.rs +0 -64
- data/vendor/html-to-markdown-rs/src/converter/format/markdown.rs +0 -59
- data/vendor/html-to-markdown-rs/src/converter/format/mod.rs +0 -43
- data/vendor/html-to-markdown-rs/src/converter/handlers/blockquote.rs +0 -173
- data/vendor/html-to-markdown-rs/src/converter/handlers/code_block.rs +0 -434
- data/vendor/html-to-markdown-rs/src/converter/handlers/graphic.rs +0 -234
- data/vendor/html-to-markdown-rs/src/converter/handlers/image.rs +0 -282
- data/vendor/html-to-markdown-rs/src/converter/handlers/link.rs +0 -316
- data/vendor/html-to-markdown-rs/src/converter/handlers/mod.rs +0 -26
- data/vendor/html-to-markdown-rs/src/converter/inline/code.rs +0 -306
- data/vendor/html-to-markdown-rs/src/converter/inline/emphasis.rs +0 -345
- data/vendor/html-to-markdown-rs/src/converter/inline/link.rs +0 -428
- data/vendor/html-to-markdown-rs/src/converter/inline/mod.rs +0 -237
- data/vendor/html-to-markdown-rs/src/converter/inline/ruby.rs +0 -337
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/marks.rs +0 -566
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/mod.rs +0 -86
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/typography.rs +0 -558
- data/vendor/html-to-markdown-rs/src/converter/list/definition.rs +0 -232
- data/vendor/html-to-markdown-rs/src/converter/list/item.rs +0 -332
- data/vendor/html-to-markdown-rs/src/converter/list/mod.rs +0 -70
- data/vendor/html-to-markdown-rs/src/converter/list/ordered.rs +0 -201
- data/vendor/html-to-markdown-rs/src/converter/list/unordered.rs +0 -195
- data/vendor/html-to-markdown-rs/src/converter/list/utils.rs +0 -314
- data/vendor/html-to-markdown-rs/src/converter/main.rs +0 -710
- data/vendor/html-to-markdown-rs/src/converter/main_helpers.rs +0 -452
- data/vendor/html-to-markdown-rs/src/converter/media/embedded.rs +0 -393
- data/vendor/html-to-markdown-rs/src/converter/media/graphic.rs +0 -4
- data/vendor/html-to-markdown-rs/src/converter/media/image.rs +0 -183
- data/vendor/html-to-markdown-rs/src/converter/media/mod.rs +0 -87
- data/vendor/html-to-markdown-rs/src/converter/media/svg.rs +0 -280
- data/vendor/html-to-markdown-rs/src/converter/metadata.rs +0 -220
- data/vendor/html-to-markdown-rs/src/converter/mod.rs +0 -156
- data/vendor/html-to-markdown-rs/src/converter/plain_text.rs +0 -516
- data/vendor/html-to-markdown-rs/src/converter/preprocessing_helpers.rs +0 -201
- data/vendor/html-to-markdown-rs/src/converter/reference_collector.rs +0 -69
- data/vendor/html-to-markdown-rs/src/converter/semantic/attributes.rs +0 -269
- data/vendor/html-to-markdown-rs/src/converter/semantic/definition_list.rs +0 -266
- data/vendor/html-to-markdown-rs/src/converter/semantic/figure.rs +0 -391
- data/vendor/html-to-markdown-rs/src/converter/semantic/mod.rs +0 -112
- data/vendor/html-to-markdown-rs/src/converter/semantic/sectioning.rs +0 -85
- data/vendor/html-to-markdown-rs/src/converter/semantic/summary.rs +0 -324
- data/vendor/html-to-markdown-rs/src/converter/text/mod.rs +0 -8
- data/vendor/html-to-markdown-rs/src/converter/text/processing.rs +0 -56
- data/vendor/html-to-markdown-rs/src/converter/text_node.rs +0 -269
- data/vendor/html-to-markdown-rs/src/converter/utility/attributes.rs +0 -151
- data/vendor/html-to-markdown-rs/src/converter/utility/caching.rs +0 -74
- data/vendor/html-to-markdown-rs/src/converter/utility/content.rs +0 -271
- data/vendor/html-to-markdown-rs/src/converter/utility/mod.rs +0 -17
- data/vendor/html-to-markdown-rs/src/converter/utility/preprocessing.rs +0 -1002
- data/vendor/html-to-markdown-rs/src/converter/utility/serialization.rs +0 -126
- data/vendor/html-to-markdown-rs/src/converter/utility/siblings.rs +0 -97
- data/vendor/html-to-markdown-rs/src/converter/visitor_hooks.rs +0 -189
- data/vendor/html-to-markdown-rs/src/error.rs +0 -43
- data/vendor/html-to-markdown-rs/src/exports.rs +0 -24
- data/vendor/html-to-markdown-rs/src/inline_images.rs +0 -336
- data/vendor/html-to-markdown-rs/src/lib.rs +0 -139
- data/vendor/html-to-markdown-rs/src/metadata/collector.rs +0 -457
- data/vendor/html-to-markdown-rs/src/metadata/config.rs +0 -394
- data/vendor/html-to-markdown-rs/src/metadata/extraction.rs +0 -398
- data/vendor/html-to-markdown-rs/src/metadata/mod.rs +0 -288
- data/vendor/html-to-markdown-rs/src/metadata/types.rs +0 -477
- data/vendor/html-to-markdown-rs/src/options/conversion.rs +0 -559
- data/vendor/html-to-markdown-rs/src/options/inline_image.rs +0 -111
- data/vendor/html-to-markdown-rs/src/options/mod.rs +0 -20
- data/vendor/html-to-markdown-rs/src/options/preprocessing.rs +0 -201
- data/vendor/html-to-markdown-rs/src/options/validation.rs +0 -416
- data/vendor/html-to-markdown-rs/src/prelude.rs +0 -1
- data/vendor/html-to-markdown-rs/src/rcdom.rs +0 -487
- data/vendor/html-to-markdown-rs/src/text.rs +0 -358
- data/vendor/html-to-markdown-rs/src/types/document.rs +0 -191
- data/vendor/html-to-markdown-rs/src/types/mod.rs +0 -17
- data/vendor/html-to-markdown-rs/src/types/result.rs +0 -54
- data/vendor/html-to-markdown-rs/src/types/structure_builder.rs +0 -791
- data/vendor/html-to-markdown-rs/src/types/structure_collector.rs +0 -483
- data/vendor/html-to-markdown-rs/src/types/tables.rs +0 -52
- data/vendor/html-to-markdown-rs/src/types/warnings.rs +0 -33
- data/vendor/html-to-markdown-rs/src/validation.rs +0 -158
- data/vendor/html-to-markdown-rs/src/visitor/default_impl.rs +0 -63
- data/vendor/html-to-markdown-rs/src/visitor/mod.rs +0 -41
- data/vendor/html-to-markdown-rs/src/visitor/traits.rs +0 -370
- data/vendor/html-to-markdown-rs/src/visitor/types.rs +0 -319
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/callbacks/mod.rs +0 -1
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/content.rs +0 -126
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/mod.rs +0 -27
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/state.rs +0 -110
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/traversal.rs +0 -250
- data/vendor/html-to-markdown-rs/src/visitor_helpers.rs +0 -597
- data/vendor/html-to-markdown-rs/src/wrapper/sync.rs +0 -413
- data/vendor/html-to-markdown-rs/src/wrapper/utils.rs +0 -290
- data/vendor/html-to-markdown-rs/src/wrapper.rs +0 -9
- data/vendor/html-to-markdown-rs/tests/br_in_inline_test.rs +0 -87
- data/vendor/html-to-markdown-rs/tests/commonmark_compliance_test.rs +0 -297
- data/vendor/html-to-markdown-rs/tests/djot_output_test.rs +0 -153
- data/vendor/html-to-markdown-rs/tests/exclude_selectors_test.rs +0 -132
- data/vendor/html-to-markdown-rs/tests/integration_test.rs +0 -631
- data/vendor/html-to-markdown-rs/tests/issue_121_regressions.rs +0 -49
- data/vendor/html-to-markdown-rs/tests/issue_127_regressions.rs +0 -58
- data/vendor/html-to-markdown-rs/tests/issue_128_regressions.rs +0 -17
- data/vendor/html-to-markdown-rs/tests/issue_131_regressions.rs +0 -41
- data/vendor/html-to-markdown-rs/tests/issue_134_regressions.rs +0 -40
- data/vendor/html-to-markdown-rs/tests/issue_139_regressions.rs +0 -26
- data/vendor/html-to-markdown-rs/tests/issue_140_regressions.rs +0 -185
- data/vendor/html-to-markdown-rs/tests/issue_143_regressions.rs +0 -100
- data/vendor/html-to-markdown-rs/tests/issue_145_regressions.rs +0 -133
- data/vendor/html-to-markdown-rs/tests/issue_146_regressions.rs +0 -144
- data/vendor/html-to-markdown-rs/tests/issue_176_regressions.rs +0 -62
- data/vendor/html-to-markdown-rs/tests/issue_190_regressions.rs +0 -128
- data/vendor/html-to-markdown-rs/tests/issue_199_regressions.rs +0 -20
- data/vendor/html-to-markdown-rs/tests/issue_200_regressions.rs +0 -62
- data/vendor/html-to-markdown-rs/tests/issue_212_regressions.rs +0 -68
- data/vendor/html-to-markdown-rs/tests/issue_216_217_regressions.rs +0 -87
- data/vendor/html-to-markdown-rs/tests/issue_336_regressions.rs +0 -74
- data/vendor/html-to-markdown-rs/tests/issue_339_regressions.rs +0 -92
- data/vendor/html-to-markdown-rs/tests/issue_347_regressions.rs +0 -154
- data/vendor/html-to-markdown-rs/tests/issue_348_visitor_plain.rs +0 -93
- data/vendor/html-to-markdown-rs/tests/json_ld_script_extraction.rs +0 -44
- data/vendor/html-to-markdown-rs/tests/lists_test.rs +0 -199
- data/vendor/html-to-markdown-rs/tests/plain_output_test.rs +0 -273
- data/vendor/html-to-markdown-rs/tests/preprocessing_tests.rs +0 -61
- data/vendor/html-to-markdown-rs/tests/reference_links_test.rs +0 -169
- data/vendor/html-to-markdown-rs/tests/sectioning_elements_test.rs +0 -137
- data/vendor/html-to-markdown-rs/tests/skip_images_test.rs +0 -522
- data/vendor/html-to-markdown-rs/tests/tables_test.rs +0 -743
- data/vendor/html-to-markdown-rs/tests/test_custom_elements.rs +0 -41
- data/vendor/html-to-markdown-rs/tests/test_issue_187.rs +0 -204
- data/vendor/html-to-markdown-rs/tests/test_issue_218.rs +0 -68
- data/vendor/html-to-markdown-rs/tests/test_issue_277.rs +0 -77
- data/vendor/html-to-markdown-rs/tests/test_max_depth.rs +0 -82
- data/vendor/html-to-markdown-rs/tests/test_nested_simple.rs +0 -45
- data/vendor/html-to-markdown-rs/tests/test_script_style_stripping.rs +0 -396
- data/vendor/html-to-markdown-rs/tests/test_spa_bisect.rs +0 -34
- data/vendor/html-to-markdown-rs/tests/visitor_code_integration_test.rs +0 -121
- data/vendor/html-to-markdown-rs/tests/visitor_integration_test.rs +0 -1190
- data/vendor/html-to-markdown-rs/tests/xml_tables_test.rs +0 -372
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
#![allow(missing_docs)]
|
|
2
|
-
|
|
3
|
-
fn convert(
|
|
4
|
-
html: &str,
|
|
5
|
-
opts: Option<html_to_markdown_rs::ConversionOptions>,
|
|
6
|
-
) -> html_to_markdown_rs::error::Result<String> {
|
|
7
|
-
html_to_markdown_rs::convert(html, opts).map(|r| r.content.unwrap_or_default())
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
use html_to_markdown_rs::ConversionOptions;
|
|
11
|
-
|
|
12
|
-
#[test]
|
|
13
|
-
fn test_basic_row_and_cell_conversion() {
|
|
14
|
-
let html = r"<table>
|
|
15
|
-
<row><cell>Header 1</cell><cell>Header 2</cell></row>
|
|
16
|
-
<row><cell>Cell 1</cell><cell>Cell 2</cell></row>
|
|
17
|
-
</table>";
|
|
18
|
-
|
|
19
|
-
let result = convert(html, None).unwrap();
|
|
20
|
-
assert!(result.contains("| Header 1"), "header 1 missing: {result}");
|
|
21
|
-
assert!(result.contains("| Header 2"), "header 2 missing: {result}");
|
|
22
|
-
assert!(result.contains("| Cell 1"), "cell 1 missing: {result}");
|
|
23
|
-
assert!(result.contains("| Cell 2"), "cell 2 missing: {result}");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
#[test]
|
|
27
|
-
fn test_cell_role_head_as_table_header() {
|
|
28
|
-
let html = r#"<table>
|
|
29
|
-
<row><cell role="head">Column 1</cell><cell role="head">Column 2</cell></row>
|
|
30
|
-
<row><cell>Data 1</cell><cell>Data 2</cell></row>
|
|
31
|
-
</table>"#;
|
|
32
|
-
|
|
33
|
-
let result = convert(html, None).unwrap();
|
|
34
|
-
assert!(result.contains("| Column 1"), "column 1 missing: {result}");
|
|
35
|
-
assert!(result.contains("| Column 2"), "column 2 missing: {result}");
|
|
36
|
-
assert!(result.contains("| Data 1"), "data 1 missing: {result}");
|
|
37
|
-
assert!(result.contains("| Data 2"), "data 2 missing: {result}");
|
|
38
|
-
assert!(result.contains("| ---"), "separator row missing: {result}");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
#[test]
|
|
42
|
-
fn test_mixed_html_and_xml_elements() {
|
|
43
|
-
let html = r#"<table>
|
|
44
|
-
<row><cell role="head">Name</cell><cell role="head">Age</cell></row>
|
|
45
|
-
<row><td><strong>John</strong></td><td>25</td></row>
|
|
46
|
-
<row><cell><em>Jane</em></cell><cell>30</cell></row>
|
|
47
|
-
</table>"#;
|
|
48
|
-
|
|
49
|
-
let result = convert(html, None).unwrap();
|
|
50
|
-
assert!(result.contains("| Name"), "Name column missing: {result}");
|
|
51
|
-
assert!(result.contains("| Age"), "Age column missing: {result}");
|
|
52
|
-
assert!(result.contains("**John**"), "John bold missing: {result}");
|
|
53
|
-
assert!(result.contains("*Jane*"), "Jane italic missing: {result}");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#[test]
|
|
57
|
-
fn test_tei_cols_and_rows_attributes() {
|
|
58
|
-
let html = r#"<table cols="2" rows="3">
|
|
59
|
-
<row><cell>Header 1</cell><cell>Header 2</cell></row>
|
|
60
|
-
<row><cell>Cell 1</cell><cell>Cell 2</cell></row>
|
|
61
|
-
<row><cell>Cell 3</cell><cell>Cell 4</cell></row>
|
|
62
|
-
</table>"#;
|
|
63
|
-
|
|
64
|
-
let result = convert(html, None).unwrap();
|
|
65
|
-
assert!(result.contains("| Header 1"), "header 1 missing: {result}");
|
|
66
|
-
assert!(result.contains("| Header 2"), "header 2 missing: {result}");
|
|
67
|
-
assert!(result.contains("| Cell 1"), "cell 1 missing: {result}");
|
|
68
|
-
assert!(result.contains("| Cell 2"), "cell 2 missing: {result}");
|
|
69
|
-
assert!(result.contains("| Cell 3"), "cell 3 missing: {result}");
|
|
70
|
-
assert!(result.contains("| Cell 4"), "cell 4 missing: {result}");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
#[test]
|
|
74
|
-
fn test_graphic_element_with_xlink_href() {
|
|
75
|
-
let html = r#"<table>
|
|
76
|
-
<row>
|
|
77
|
-
<cell role="head">Image</cell>
|
|
78
|
-
<cell role="head">Description</cell>
|
|
79
|
-
</row>
|
|
80
|
-
<row>
|
|
81
|
-
<cell><graphic xlink:href="image.png"/></cell>
|
|
82
|
-
<cell>A test image</cell>
|
|
83
|
-
</row>
|
|
84
|
-
</table>"#;
|
|
85
|
-
|
|
86
|
-
let result = convert(html, None).unwrap();
|
|
87
|
-
assert!(result.contains("| Image"), "Image column missing: {result}");
|
|
88
|
-
assert!(result.contains("| Description"), "Description column missing: {result}");
|
|
89
|
-
assert!(result.contains("A test image"), "test image text missing: {result}");
|
|
90
|
-
// graphic element handling may vary based on implementation
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
#[test]
|
|
94
|
-
fn test_graphic_in_table_cells() {
|
|
95
|
-
let html = r#"<table>
|
|
96
|
-
<row>
|
|
97
|
-
<cell role="head">Figure</cell>
|
|
98
|
-
</row>
|
|
99
|
-
<row>
|
|
100
|
-
<cell><graphic url="diagram.svg" alt="System Diagram"/></cell>
|
|
101
|
-
</row>
|
|
102
|
-
</table>"#;
|
|
103
|
-
|
|
104
|
-
let result = convert(html, None).unwrap();
|
|
105
|
-
assert!(result.contains("| Figure"), "Figure column missing: {result}");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#[test]
|
|
109
|
-
fn test_empty_cells_xml() {
|
|
110
|
-
let html = r"<table>
|
|
111
|
-
<row><cell>Data</cell><cell></cell></row>
|
|
112
|
-
</table>";
|
|
113
|
-
|
|
114
|
-
let result = convert(html, None).unwrap();
|
|
115
|
-
assert!(result.contains("| Data | |"));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
#[test]
|
|
119
|
-
fn test_nested_content_in_cells() {
|
|
120
|
-
let html = r#"<table>
|
|
121
|
-
<row><cell role="head">Text</cell><cell role="head">Formatted</cell></row>
|
|
122
|
-
<row>
|
|
123
|
-
<cell>Plain text</cell>
|
|
124
|
-
<cell><b>Bold</b> and <a href="http://example.com">Link</a></cell>
|
|
125
|
-
</row>
|
|
126
|
-
</table>"#;
|
|
127
|
-
|
|
128
|
-
let result = convert(html, None).unwrap();
|
|
129
|
-
assert!(result.contains("| Text"), "Text column missing: {result}");
|
|
130
|
-
assert!(result.contains("| Formatted"), "Formatted column missing: {result}");
|
|
131
|
-
assert!(result.contains("| Plain text"), "plain text missing: {result}");
|
|
132
|
-
assert!(result.contains("**Bold**"), "bold missing: {result}");
|
|
133
|
-
assert!(result.contains("[Link](http://example.com)"), "link missing: {result}");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
#[test]
|
|
137
|
-
fn test_mixed_tr_and_row_in_same_table() {
|
|
138
|
-
let html = r"<table>
|
|
139
|
-
<tr><th>Col 1</th><th>Col 2</th></tr>
|
|
140
|
-
<row><cell>Data 1</cell><cell>Data 2</cell></row>
|
|
141
|
-
<tr><td>Data 3</td><td>Data 4</td></tr>
|
|
142
|
-
</table>";
|
|
143
|
-
|
|
144
|
-
let result = convert(html, None).unwrap();
|
|
145
|
-
assert!(result.contains("| Col 1"), "Col 1 missing: {result}");
|
|
146
|
-
assert!(result.contains("| Col 2"), "Col 2 missing: {result}");
|
|
147
|
-
assert!(result.contains("| Data 1"), "Data 1 missing: {result}");
|
|
148
|
-
assert!(result.contains("| Data 2"), "Data 2 missing: {result}");
|
|
149
|
-
assert!(result.contains("| Data 3"), "Data 3 missing: {result}");
|
|
150
|
-
assert!(result.contains("| Data 4"), "Data 4 missing: {result}");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
#[test]
|
|
154
|
-
fn test_cell_without_role_attribute_defaults_to_data() {
|
|
155
|
-
let html = r"<table>
|
|
156
|
-
<row><cell>Header</cell></row>
|
|
157
|
-
<row><cell>Data Cell</cell></row>
|
|
158
|
-
</table>";
|
|
159
|
-
|
|
160
|
-
let result = convert(html, None).unwrap();
|
|
161
|
-
assert!(result.contains("| Header"), "Header missing: {result}");
|
|
162
|
-
assert!(result.contains("| Data Cell"), "Data Cell missing: {result}");
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
#[test]
|
|
166
|
-
fn test_xml_table_with_multiline_content() {
|
|
167
|
-
let html = r#"<table>
|
|
168
|
-
<row><cell role="head">Content</cell></row>
|
|
169
|
-
<row>
|
|
170
|
-
<cell>
|
|
171
|
-
<p>Line 1</p>
|
|
172
|
-
<p>Line 2</p>
|
|
173
|
-
</cell>
|
|
174
|
-
</row>
|
|
175
|
-
</table>"#;
|
|
176
|
-
|
|
177
|
-
let options = ConversionOptions {
|
|
178
|
-
br_in_tables: true,
|
|
179
|
-
..Default::default()
|
|
180
|
-
};
|
|
181
|
-
let result = convert(html, Some(options)).unwrap();
|
|
182
|
-
|
|
183
|
-
assert!(result.contains("| Content"), "Content column missing: {result}");
|
|
184
|
-
assert!(result.contains("Line 1"), "Line 1 missing: {result}");
|
|
185
|
-
assert!(result.contains("Line 2"), "Line 2 missing: {result}");
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
#[test]
|
|
189
|
-
fn test_cell_with_lists() {
|
|
190
|
-
let html = r#"<table>
|
|
191
|
-
<row><cell role="head">Items</cell></row>
|
|
192
|
-
<row>
|
|
193
|
-
<cell>
|
|
194
|
-
<ul>
|
|
195
|
-
<li>Item 1</li>
|
|
196
|
-
<li>Item 2</li>
|
|
197
|
-
</ul>
|
|
198
|
-
</cell>
|
|
199
|
-
</row>
|
|
200
|
-
</table>"#;
|
|
201
|
-
|
|
202
|
-
let result = convert(html, None).unwrap();
|
|
203
|
-
assert!(result.contains("| Items"), "Items column missing: {result}");
|
|
204
|
-
assert!(result.contains("Item 1"), "Item 1 missing: {result}");
|
|
205
|
-
assert!(result.contains("Item 2"), "Item 2 missing: {result}");
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
#[test]
|
|
209
|
-
fn test_single_column_xml_table() {
|
|
210
|
-
let html = r#"<table>
|
|
211
|
-
<row><cell role="head">Header</cell></row>
|
|
212
|
-
<row><cell>Data 1</cell></row>
|
|
213
|
-
<row><cell>Data 2</cell></row>
|
|
214
|
-
</table>"#;
|
|
215
|
-
|
|
216
|
-
let result = convert(html, None).unwrap();
|
|
217
|
-
assert!(result.contains("| Header"), "Header missing: {result}");
|
|
218
|
-
assert!(result.contains("| ---"), "separator row missing: {result}");
|
|
219
|
-
assert!(result.contains("| Data 1"), "Data 1 missing: {result}");
|
|
220
|
-
assert!(result.contains("| Data 2"), "Data 2 missing: {result}");
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
#[test]
|
|
224
|
-
fn test_cell_with_code_blocks() {
|
|
225
|
-
let html = r#"<table>
|
|
226
|
-
<row><cell role="head">Code</cell></row>
|
|
227
|
-
<row><cell><code>function()</code></cell></row>
|
|
228
|
-
</table>"#;
|
|
229
|
-
|
|
230
|
-
let result = convert(html, None).unwrap();
|
|
231
|
-
assert!(result.contains("| Code"), "Code column missing: {result}");
|
|
232
|
-
assert!(result.contains("`function()`"), "code block missing: {result}");
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
#[test]
|
|
236
|
-
fn test_xml_table_with_emphasis() {
|
|
237
|
-
let html = r#"<table>
|
|
238
|
-
<row>
|
|
239
|
-
<cell role="head"><em>Emphasized</em></cell>
|
|
240
|
-
<cell role="head"><strong>Strong</strong></cell>
|
|
241
|
-
</row>
|
|
242
|
-
<row>
|
|
243
|
-
<cell><i>Italic</i></cell>
|
|
244
|
-
<cell><b>Bold</b></cell>
|
|
245
|
-
</row>
|
|
246
|
-
</table>"#;
|
|
247
|
-
|
|
248
|
-
let result = convert(html, None).unwrap();
|
|
249
|
-
assert!(result.contains("*Emphasized*"));
|
|
250
|
-
assert!(result.contains("**Strong**"));
|
|
251
|
-
assert!(result.contains("*Italic*"));
|
|
252
|
-
assert!(result.contains("**Bold**"));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
#[test]
|
|
256
|
-
fn test_xml_table_with_multiple_headers() {
|
|
257
|
-
let html = r#"<table>
|
|
258
|
-
<row>
|
|
259
|
-
<cell role="head">First</cell>
|
|
260
|
-
<cell role="head">Second</cell>
|
|
261
|
-
<cell role="head">Third</cell>
|
|
262
|
-
</row>
|
|
263
|
-
<row>
|
|
264
|
-
<cell>A</cell>
|
|
265
|
-
<cell>B</cell>
|
|
266
|
-
<cell>C</cell>
|
|
267
|
-
</row>
|
|
268
|
-
<row>
|
|
269
|
-
<cell>D</cell>
|
|
270
|
-
<cell>E</cell>
|
|
271
|
-
<cell>F</cell>
|
|
272
|
-
</row>
|
|
273
|
-
</table>"#;
|
|
274
|
-
|
|
275
|
-
let result = convert(html, None).unwrap();
|
|
276
|
-
assert!(result.contains("| First"), "First column missing: {result}");
|
|
277
|
-
assert!(result.contains("| Second"), "Second column missing: {result}");
|
|
278
|
-
assert!(result.contains("| Third"), "Third column missing: {result}");
|
|
279
|
-
assert!(result.contains("| ---"), "separator row missing: {result}");
|
|
280
|
-
assert!(result.contains("| A"), "A missing: {result}");
|
|
281
|
-
assert!(result.contains("| B"), "B missing: {result}");
|
|
282
|
-
assert!(result.contains("| C"), "C missing: {result}");
|
|
283
|
-
assert!(result.contains("| D"), "D missing: {result}");
|
|
284
|
-
assert!(result.contains("| E"), "E missing: {result}");
|
|
285
|
-
assert!(result.contains("| F"), "F missing: {result}");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
#[test]
|
|
289
|
-
fn test_cell_role_variations() {
|
|
290
|
-
let html = r#"<table>
|
|
291
|
-
<row>
|
|
292
|
-
<cell role="head">Header Cell</cell>
|
|
293
|
-
<cell role="data">Data Cell</cell>
|
|
294
|
-
</row>
|
|
295
|
-
<row>
|
|
296
|
-
<cell role="label">Label</cell>
|
|
297
|
-
<cell role="head">Another Header</cell>
|
|
298
|
-
</row>
|
|
299
|
-
</table>"#;
|
|
300
|
-
|
|
301
|
-
let result = convert(html, None).unwrap();
|
|
302
|
-
assert!(result.contains("| Header Cell"), "Header Cell missing: {result}");
|
|
303
|
-
assert!(result.contains("| Data Cell"), "Data Cell missing: {result}");
|
|
304
|
-
assert!(result.contains("| Label"), "Label missing: {result}");
|
|
305
|
-
assert!(result.contains("| Another Header"), "Another Header missing: {result}");
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
#[test]
|
|
309
|
-
fn test_deeply_nested_xml_content() {
|
|
310
|
-
let html = r#"<table>
|
|
311
|
-
<row><cell role="head">Complex</cell></row>
|
|
312
|
-
<row>
|
|
313
|
-
<cell>
|
|
314
|
-
<div>
|
|
315
|
-
<p>
|
|
316
|
-
<strong>
|
|
317
|
-
<em>Nested</em>
|
|
318
|
-
</strong>
|
|
319
|
-
</p>
|
|
320
|
-
</div>
|
|
321
|
-
</cell>
|
|
322
|
-
</row>
|
|
323
|
-
</table>"#;
|
|
324
|
-
|
|
325
|
-
let result = convert(html, None).unwrap();
|
|
326
|
-
assert!(result.contains("| Complex"), "Complex column missing: {result}");
|
|
327
|
-
assert!(result.contains("Nested"), "Nested text missing: {result}");
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
#[test]
|
|
331
|
-
fn test_xml_table_with_attributes_preserved() {
|
|
332
|
-
let html = r#"<table id="table1" class="data-table" xmlns:tei="http://www.tei-c.org/ns/1.0">
|
|
333
|
-
<row>
|
|
334
|
-
<cell role="head">Column 1</cell>
|
|
335
|
-
<cell role="head">Column 2</cell>
|
|
336
|
-
</row>
|
|
337
|
-
<row>
|
|
338
|
-
<cell>Value 1</cell>
|
|
339
|
-
<cell>Value 2</cell>
|
|
340
|
-
</row>
|
|
341
|
-
</table>"#;
|
|
342
|
-
|
|
343
|
-
let result = convert(html, None).unwrap();
|
|
344
|
-
assert!(result.contains("| Column 1"), "Column 1 missing: {result}");
|
|
345
|
-
assert!(result.contains("| Column 2"), "Column 2 missing: {result}");
|
|
346
|
-
assert!(result.contains("| Value 1"), "Value 1 missing: {result}");
|
|
347
|
-
assert!(result.contains("| Value 2"), "Value 2 missing: {result}");
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
#[test]
|
|
351
|
-
fn test_mixed_cell_types_in_rows() {
|
|
352
|
-
let html = r#"<table>
|
|
353
|
-
<row>
|
|
354
|
-
<cell role="head">Name</cell>
|
|
355
|
-
<th>Age</th>
|
|
356
|
-
<cell role="head">City</cell>
|
|
357
|
-
</row>
|
|
358
|
-
<row>
|
|
359
|
-
<cell>John</cell>
|
|
360
|
-
<td>25</td>
|
|
361
|
-
<cell>NYC</cell>
|
|
362
|
-
</row>
|
|
363
|
-
</table>"#;
|
|
364
|
-
|
|
365
|
-
let result = convert(html, None).unwrap();
|
|
366
|
-
assert!(result.contains("| Name"), "Name column missing: {result}");
|
|
367
|
-
assert!(result.contains("| Age"), "Age column missing: {result}");
|
|
368
|
-
assert!(result.contains("| City"), "City column missing: {result}");
|
|
369
|
-
assert!(result.contains("| John"), "John missing: {result}");
|
|
370
|
-
assert!(result.contains("| 25"), "25 missing: {result}");
|
|
371
|
-
assert!(result.contains("| NYC"), "NYC missing: {result}");
|
|
372
|
-
}
|