html-to-markdown 3.4.0 → 3.6.0.pre.rc.23
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,278 +0,0 @@
|
|
|
1
|
-
# html-to-markdown-rs
|
|
2
|
-
|
|
3
|
-
High-performance HTML to Markdown converter built with Rust.
|
|
4
|
-
|
|
5
|
-
This crate is the core engine compiled into the Python wheels, Ruby gem, Node.js NAPI bindings, WebAssembly package, and CLI, ensuring identical Markdown output across every language.
|
|
6
|
-
|
|
7
|
-
[](https://crates.io/crates/html-to-markdown-rs)
|
|
8
|
-
[](https://www.npmjs.com/package/@kreuzberg/html-to-markdown)
|
|
9
|
-
[](https://pypi.org/project/html-to-markdown/)
|
|
10
|
-
[](https://rubygems.org/gems/html-to-markdown)
|
|
11
|
-
[](https://packagist.org/packages/kreuzberg-dev/html-to-markdown)
|
|
12
|
-
[](https://docs.rs/html-to-markdown-rs)
|
|
13
|
-
[](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/LICENSE)
|
|
14
|
-
|
|
15
|
-
Fast, reliable HTML to Markdown conversion with full CommonMark compliance. Built with `html5ever` for correctness and a DOM-based filter for safe preprocessing.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```toml
|
|
20
|
-
[dependencies]
|
|
21
|
-
html-to-markdown-rs = "3.0"
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Basic Usage
|
|
25
|
-
|
|
26
|
-
`convert()` returns a structured `ConversionResult` with the converted text, metadata, tables, and more:
|
|
27
|
-
|
|
28
|
-
```rust
|
|
29
|
-
use html_to_markdown_rs::convert;
|
|
30
|
-
|
|
31
|
-
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
32
|
-
let html = r#"
|
|
33
|
-
<html lang="en">
|
|
34
|
-
<head><title>Welcome</title></head>
|
|
35
|
-
<body>
|
|
36
|
-
<h1>Welcome</h1>
|
|
37
|
-
<p>This is <strong>fast</strong> conversion!</p>
|
|
38
|
-
<ul>
|
|
39
|
-
<li>Built with Rust</li>
|
|
40
|
-
<li>CommonMark compliant</li>
|
|
41
|
-
</ul>
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|
|
44
|
-
"#;
|
|
45
|
-
|
|
46
|
-
let result = convert(html, None)?;
|
|
47
|
-
println!("{}", result.content.unwrap_or_default());
|
|
48
|
-
|
|
49
|
-
if let Some(metadata) = &result.metadata {
|
|
50
|
-
println!("Title: {:?}", metadata.document.title);
|
|
51
|
-
println!("Headers: {:?}", metadata.headers);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
for table in &result.tables {
|
|
55
|
-
println!("Table with {} rows", table.cells.len());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Ok(())
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Error Handling
|
|
63
|
-
|
|
64
|
-
Conversion returns a `Result<ConversionResult, ConversionError>`. Inputs that look like binary data are rejected with
|
|
65
|
-
`ConversionError::InvalidInput` to prevent runaway allocations. Table `colspan`/`rowspan` values are also clamped
|
|
66
|
-
internally to keep output sizes bounded.
|
|
67
|
-
|
|
68
|
-
## Configuration
|
|
69
|
-
|
|
70
|
-
### Builder Pattern
|
|
71
|
-
|
|
72
|
-
```rust
|
|
73
|
-
use html_to_markdown_rs::{
|
|
74
|
-
convert, ConversionOptions, HeadingStyle, CodeBlockStyle,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
let options = ConversionOptions::builder()
|
|
78
|
-
.heading_style(HeadingStyle::Atx)
|
|
79
|
-
.list_indent_width(2)
|
|
80
|
-
.bullets("-")
|
|
81
|
-
.autolinks(true)
|
|
82
|
-
.wrap(true)
|
|
83
|
-
.wrap_width(80)
|
|
84
|
-
.build();
|
|
85
|
-
|
|
86
|
-
let result = convert(html, Some(options))?;
|
|
87
|
-
println!("{}", result.content.unwrap_or_default());
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Struct Literal
|
|
91
|
-
|
|
92
|
-
```rust
|
|
93
|
-
use html_to_markdown_rs::{
|
|
94
|
-
convert, ConversionOptions, HeadingStyle, ListIndentType,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
let options = ConversionOptions {
|
|
98
|
-
heading_style: HeadingStyle::Atx,
|
|
99
|
-
list_indent_width: 2,
|
|
100
|
-
list_indent_type: ListIndentType::Spaces,
|
|
101
|
-
bullets: "-".to_string(),
|
|
102
|
-
strong_em_symbol: '*',
|
|
103
|
-
escape_asterisks: false,
|
|
104
|
-
escape_underscores: false,
|
|
105
|
-
newline_style: html_to_markdown_rs::NewlineStyle::Backslash,
|
|
106
|
-
code_block_style: html_to_markdown_rs::CodeBlockStyle::Backticks,
|
|
107
|
-
..Default::default()
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
let result = convert(html, Some(options))?;
|
|
111
|
-
println!("{}", result.content.unwrap_or_default());
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Preserving HTML Tags
|
|
115
|
-
|
|
116
|
-
The `preserve_tags` option allows you to keep specific HTML tags in their original form instead of converting them to Markdown:
|
|
117
|
-
|
|
118
|
-
```rust
|
|
119
|
-
use html_to_markdown_rs::{convert, ConversionOptions};
|
|
120
|
-
|
|
121
|
-
let html = r#"
|
|
122
|
-
<p>Before table</p>
|
|
123
|
-
<table class="data">
|
|
124
|
-
<tr><th>Name</th><th>Value</th></tr>
|
|
125
|
-
<tr><td>Item 1</td><td>100</td></tr>
|
|
126
|
-
</table>
|
|
127
|
-
<p>After table</p>
|
|
128
|
-
"#;
|
|
129
|
-
|
|
130
|
-
let options = ConversionOptions {
|
|
131
|
-
preserve_tags: vec!["table".to_string()],
|
|
132
|
-
..Default::default()
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
let result = convert(html, Some(options))?;
|
|
136
|
-
// result.content => "Before table\n\n<table class=\"data\">...</table>\n\nAfter table\n"
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Web Scraping with Preprocessing
|
|
140
|
-
|
|
141
|
-
```rust
|
|
142
|
-
use html_to_markdown_rs::{convert, ConversionOptions, PreprocessingOptions};
|
|
143
|
-
|
|
144
|
-
let mut options = ConversionOptions::default();
|
|
145
|
-
options.preprocessing.enabled = true;
|
|
146
|
-
options.preprocessing.preset = html_to_markdown_rs::PreprocessingPreset::Aggressive;
|
|
147
|
-
options.preprocessing.remove_navigation = true;
|
|
148
|
-
options.preprocessing.remove_forms = true;
|
|
149
|
-
|
|
150
|
-
let result = convert(scraped_html, Some(options))?;
|
|
151
|
-
println!("{}", result.content.unwrap_or_default());
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Metadata Extraction
|
|
155
|
-
|
|
156
|
-
Metadata is automatically included in the result. Configure which fields to extract via `MetadataConfig`:
|
|
157
|
-
|
|
158
|
-
```rust
|
|
159
|
-
use html_to_markdown_rs::{convert, ConversionOptions, MetadataConfig};
|
|
160
|
-
|
|
161
|
-
let options = ConversionOptions::builder()
|
|
162
|
-
.metadata_config(MetadataConfig {
|
|
163
|
-
extract_headers: true,
|
|
164
|
-
extract_links: true,
|
|
165
|
-
extract_images: false,
|
|
166
|
-
..Default::default()
|
|
167
|
-
})
|
|
168
|
-
.build();
|
|
169
|
-
|
|
170
|
-
let result = convert(html, Some(options))?;
|
|
171
|
-
if let Some(metadata) = &result.metadata {
|
|
172
|
-
println!("Title: {:?}", metadata.document.title);
|
|
173
|
-
for header in &metadata.headers {
|
|
174
|
-
println!("H{}: {}", header.level, header.text);
|
|
175
|
-
}
|
|
176
|
-
for link in &metadata.links {
|
|
177
|
-
println!("Link: {} -> {}", link.text, link.href);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## Image Extraction
|
|
183
|
-
|
|
184
|
-
```rust
|
|
185
|
-
use html_to_markdown_rs::{convert, ConversionOptions};
|
|
186
|
-
|
|
187
|
-
let options = ConversionOptions::builder()
|
|
188
|
-
.extract_images(true)
|
|
189
|
-
.max_image_size(5 * 1024 * 1024) // 5 MB max
|
|
190
|
-
.infer_dimensions(true)
|
|
191
|
-
.build();
|
|
192
|
-
|
|
193
|
-
let result = convert(html, Some(options))?;
|
|
194
|
-
println!("{}", result.content.unwrap_or_default());
|
|
195
|
-
for img in &result.images {
|
|
196
|
-
println!("Image: {} ({} bytes)", img.src, img.data.as_ref().map_or(0, |d| d.len()));
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Table Extraction
|
|
201
|
-
|
|
202
|
-
Structured table data is always included in `ConversionResult.tables`:
|
|
203
|
-
|
|
204
|
-
```rust
|
|
205
|
-
use html_to_markdown_rs::convert;
|
|
206
|
-
|
|
207
|
-
let html = r#"
|
|
208
|
-
<table>
|
|
209
|
-
<tr><th>Name</th><th>Age</th></tr>
|
|
210
|
-
<tr><td>Alice</td><td>30</td></tr>
|
|
211
|
-
<tr><td>Bob</td><td>25</td></tr>
|
|
212
|
-
</table>
|
|
213
|
-
"#;
|
|
214
|
-
|
|
215
|
-
let result = convert(html, None)?;
|
|
216
|
-
|
|
217
|
-
println!("{}", result.content.unwrap_or_default());
|
|
218
|
-
for table in &result.tables {
|
|
219
|
-
println!("Table with {} rows:", table.cells.len());
|
|
220
|
-
for (i, row) in table.cells.iter().enumerate() {
|
|
221
|
-
let prefix = if table.is_header_row[i] { "Header" } else { "Row" };
|
|
222
|
-
println!(" {}: {:?}", prefix, row);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## Custom Visitors
|
|
228
|
-
|
|
229
|
-
```rust
|
|
230
|
-
use html_to_markdown_rs::{convert, ConversionOptions};
|
|
231
|
-
use html_to_markdown_rs::visitor::{HtmlVisitor, NodeContext, VisitResult};
|
|
232
|
-
|
|
233
|
-
struct NoImagesVisitor;
|
|
234
|
-
|
|
235
|
-
impl HtmlVisitor for NoImagesVisitor {
|
|
236
|
-
fn visit_image(
|
|
237
|
-
&mut self,
|
|
238
|
-
_ctx: &NodeContext,
|
|
239
|
-
_src: &str,
|
|
240
|
-
_alt: &str,
|
|
241
|
-
_title: Option<&str>,
|
|
242
|
-
) -> VisitResult {
|
|
243
|
-
VisitResult::Skip
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
let options = ConversionOptions::builder()
|
|
248
|
-
.visitor(Box::new(NoImagesVisitor))
|
|
249
|
-
.build();
|
|
250
|
-
|
|
251
|
-
let result = convert(html, Some(options))?;
|
|
252
|
-
println!("{}", result.content.unwrap_or_default());
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## Other Language Bindings
|
|
256
|
-
|
|
257
|
-
This is the core Rust library. For other languages:
|
|
258
|
-
|
|
259
|
-
- **JavaScript/TypeScript**: [html-to-markdown-node](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/crates/html-to-markdown-node) (NAPI-RS) or [html-to-markdown-wasm](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/crates/html-to-markdown-wasm) (WebAssembly)
|
|
260
|
-
- **Python**: [html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/crates/html-to-markdown-py) (PyO3)
|
|
261
|
-
- **PHP**: [html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/packages/php) (PIE + Composer helpers)
|
|
262
|
-
- **Ruby**: [html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/packages/ruby) (Magnus + rb-sys)
|
|
263
|
-
- **CLI**: [html-to-markdown-cli](https://github.com/kreuzberg-dev/html-to-markdown/tree/main/crates/html-to-markdown-cli)
|
|
264
|
-
|
|
265
|
-
## Documentation
|
|
266
|
-
|
|
267
|
-
- [Full Documentation](https://docs.html-to-markdown.kreuzberg.dev)
|
|
268
|
-
- [API Reference](https://docs.rs/html-to-markdown-rs)
|
|
269
|
-
- [Migration Guide (v2 -> v3)](https://docs.html-to-markdown.kreuzberg.dev/migration/v3/)
|
|
270
|
-
- [Contributing Guide](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/CONTRIBUTING.md)
|
|
271
|
-
|
|
272
|
-
## Performance
|
|
273
|
-
|
|
274
|
-
10-30x faster than pure Python/JavaScript implementations, delivering 150-280 MB/s throughput.
|
|
275
|
-
|
|
276
|
-
## License
|
|
277
|
-
|
|
278
|
-
MIT
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//! Example: Basic HTML to Markdown conversion
|
|
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
|
-
fn main() {
|
|
11
|
-
let html = "<h1>Hello World</h1><p>This is a <strong>test</strong>.</p>";
|
|
12
|
-
|
|
13
|
-
match convert(html, None) {
|
|
14
|
-
Ok(markdown) => {
|
|
15
|
-
println!("HTML:");
|
|
16
|
-
println!("{html}");
|
|
17
|
-
println!("\nMarkdown:");
|
|
18
|
-
println!("{markdown}");
|
|
19
|
-
}
|
|
20
|
-
Err(e) => {
|
|
21
|
-
eprintln!("Error: {e}");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//! Example: Converting HTML tables to Markdown
|
|
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
|
-
fn main() {
|
|
11
|
-
let html = r"<table>
|
|
12
|
-
<tr><th>Name</th><th>Age</th></tr>
|
|
13
|
-
<tr><td>Alice</td><td>30</td></tr>
|
|
14
|
-
<tr><td>Bob</td><td>25</td></tr>
|
|
15
|
-
</table>";
|
|
16
|
-
|
|
17
|
-
match convert(html, None) {
|
|
18
|
-
Ok(markdown) => {
|
|
19
|
-
println!("Markdown:\n{markdown}");
|
|
20
|
-
}
|
|
21
|
-
Err(e) => {
|
|
22
|
-
eprintln!("Error: {e}");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#![allow(missing_docs)]
|
|
2
|
-
use html_to_markdown_rs::ConversionOptions;
|
|
3
|
-
|
|
4
|
-
fn main() {
|
|
5
|
-
let json = r#"{"headingStyle":"","listIndentType":"","listIndentWidth":2,"bullets":"-*+","strongEmSymbol":"*","escapeAsterisks":false,"escapeUnderscores":false,"escapeMisc":false,"escapeAscii":false,"codeLanguage":"","autolinks":true,"defaultTitle":false,"brInTables":false,"highlightStyle":"","extractMetadata":true,"whitespaceMode":"","stripNewlines":false,"wrap":false,"wrapWidth":80,"convertAsInline":false,"subSymbol":"","supSymbol":"","newlineStyle":"spaces","codeBlockStyle":"tildes","keepInlineImagesIn":null,"preprocessing":{"enabled":false,"preset":"","removeNavigation":false,"removeForms":false},"encoding":"utf-8","debug":false,"stripTags":null,"preserveTags":null,"skipImages":false,"linkStyle":"","outputFormat":"","includeDocumentStructure":false,"extractImages":false,"maxImageSize":5242880,"captureSvg":false,"inferDimensions":true}"#;
|
|
6
|
-
|
|
7
|
-
let opts: ConversionOptions = serde_json::from_str(json).unwrap();
|
|
8
|
-
println!("code_block_style: {:?}", opts.code_block_style);
|
|
9
|
-
|
|
10
|
-
let result = html_to_markdown_rs::convert("<pre><code>some code</code></pre>", Some(opts)).unwrap();
|
|
11
|
-
println!("result: {:?}", result.content);
|
|
12
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
//! Example: Testing HTML escape sequences and special characters
|
|
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
|
-
fn main() {
|
|
11
|
-
let html = "<p>Use *wildcards* for search</p>";
|
|
12
|
-
match convert(html, None) {
|
|
13
|
-
Ok(markdown) => {
|
|
14
|
-
println!("Test 1 - Asterisks:");
|
|
15
|
-
println!("HTML: {html}");
|
|
16
|
-
println!("Markdown: {markdown}");
|
|
17
|
-
println!("Expected: Use \\*wildcards\\* for search");
|
|
18
|
-
println!();
|
|
19
|
-
}
|
|
20
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let html2 = "<p>variable_name in code</p>";
|
|
24
|
-
match convert(html2, None) {
|
|
25
|
-
Ok(markdown) => {
|
|
26
|
-
println!("Test 2 - Underscores:");
|
|
27
|
-
println!("HTML: {html2}");
|
|
28
|
-
println!("Markdown: {markdown}");
|
|
29
|
-
println!("Expected: variable\\_name in code");
|
|
30
|
-
println!();
|
|
31
|
-
}
|
|
32
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let html3 = "<code>use *wildcards* for search</code>";
|
|
36
|
-
match convert(html3, None) {
|
|
37
|
-
Ok(markdown) => {
|
|
38
|
-
println!("Test 3 - Code (no escaping):");
|
|
39
|
-
println!("HTML: {html3}");
|
|
40
|
-
println!("Markdown: {markdown}");
|
|
41
|
-
println!("Expected: `use *wildcards* for search`");
|
|
42
|
-
println!();
|
|
43
|
-
}
|
|
44
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
let html4 = "<p>List: 1. First item</p>";
|
|
48
|
-
match convert(html4, None) {
|
|
49
|
-
Ok(markdown) => {
|
|
50
|
-
println!("Test 4 - Numbered list escape:");
|
|
51
|
-
println!("HTML: {html4}");
|
|
52
|
-
println!("Markdown: {markdown}");
|
|
53
|
-
println!("Expected: List: 1\\. First item");
|
|
54
|
-
println!();
|
|
55
|
-
}
|
|
56
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#![allow(missing_docs)]
|
|
2
|
-
fn convert(
|
|
3
|
-
html: &str,
|
|
4
|
-
opts: Option<html_to_markdown_rs::ConversionOptions>,
|
|
5
|
-
) -> html_to_markdown_rs::error::Result<String> {
|
|
6
|
-
html_to_markdown_rs::convert(html, opts).map(|r| r.content.unwrap_or_default())
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
use html_to_markdown_rs::ConversionOptions;
|
|
10
|
-
|
|
11
|
-
fn main() {
|
|
12
|
-
let html = "<p>This is <mark>highlighted</mark> text</p>";
|
|
13
|
-
match convert(html, None) {
|
|
14
|
-
Ok(markdown) => {
|
|
15
|
-
println!("Test - Mark (default):");
|
|
16
|
-
println!("HTML: {html}");
|
|
17
|
-
println!("Markdown: {markdown}");
|
|
18
|
-
println!("Expected: This is ==highlighted== text");
|
|
19
|
-
println!();
|
|
20
|
-
}
|
|
21
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let html2 = "<p>This is <del>deleted</del> and <s>strikethrough</s> text</p>";
|
|
25
|
-
match convert(html2, None) {
|
|
26
|
-
Ok(markdown) => {
|
|
27
|
-
println!("Test - Del/Strike:");
|
|
28
|
-
println!("HTML: {html2}");
|
|
29
|
-
println!("Markdown: {markdown}");
|
|
30
|
-
println!("Expected: This is ~~deleted~~ and ~~strikethrough~~ text");
|
|
31
|
-
println!();
|
|
32
|
-
}
|
|
33
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let html3 = "<p>This is <ins>inserted</ins> text</p>";
|
|
37
|
-
match convert(html3, None) {
|
|
38
|
-
Ok(markdown) => {
|
|
39
|
-
println!("Test - Ins:");
|
|
40
|
-
println!("HTML: {html3}");
|
|
41
|
-
println!("Markdown: {markdown}");
|
|
42
|
-
println!("Expected: This is ==inserted== text");
|
|
43
|
-
println!();
|
|
44
|
-
}
|
|
45
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let html4 = "<p>Press <kbd>Ctrl+C</kbd> and see <samp>output</samp></p>";
|
|
49
|
-
match convert(html4, None) {
|
|
50
|
-
Ok(markdown) => {
|
|
51
|
-
println!("Test - Kbd/Samp:");
|
|
52
|
-
println!("HTML: {html4}");
|
|
53
|
-
println!("Markdown: {markdown}");
|
|
54
|
-
println!("Expected: Press `Ctrl+C` and see `output`");
|
|
55
|
-
println!();
|
|
56
|
-
}
|
|
57
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let html5 = "<p>The variable <var>x</var> is defined</p>";
|
|
61
|
-
match convert(html5, None) {
|
|
62
|
-
Ok(markdown) => {
|
|
63
|
-
println!("Test - Var:");
|
|
64
|
-
println!("HTML: {html5}");
|
|
65
|
-
println!("Markdown: {markdown}");
|
|
66
|
-
println!("Expected: The variable *x* is defined");
|
|
67
|
-
println!();
|
|
68
|
-
}
|
|
69
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let opts = ConversionOptions {
|
|
73
|
-
sub_symbol: "~".to_string(),
|
|
74
|
-
sup_symbol: "^".to_string(),
|
|
75
|
-
..Default::default()
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
let html6 = "<p>H<sub>2</sub>O and x<sup>2</sup></p>";
|
|
79
|
-
match convert(html6, Some(opts)) {
|
|
80
|
-
Ok(markdown) => {
|
|
81
|
-
println!("Test - Sub/Sup:");
|
|
82
|
-
println!("HTML: {html6}");
|
|
83
|
-
println!("Markdown: {markdown}");
|
|
84
|
-
println!("Expected: H~2~O and x^2^");
|
|
85
|
-
println!();
|
|
86
|
-
}
|
|
87
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let html7 = r#"<p>The <abbr title="World Health Organization">WHO</abbr> announced</p>"#;
|
|
91
|
-
match convert(html7, None) {
|
|
92
|
-
Ok(markdown) => {
|
|
93
|
-
println!("Test - Abbr:");
|
|
94
|
-
println!("HTML: {html7}");
|
|
95
|
-
println!("Markdown: {markdown}");
|
|
96
|
-
println!("Expected: The WHO (World Health Organization) announced");
|
|
97
|
-
println!();
|
|
98
|
-
}
|
|
99
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let html8 = "<p>This is <u>underlined</u> and <small>small</small> text</p>";
|
|
103
|
-
match convert(html8, None) {
|
|
104
|
-
Ok(markdown) => {
|
|
105
|
-
println!("Test - U/Small:");
|
|
106
|
-
println!("HTML: {html8}");
|
|
107
|
-
println!("Markdown: {markdown}");
|
|
108
|
-
println!("Expected: This is underlined and small text");
|
|
109
|
-
println!();
|
|
110
|
-
}
|
|
111
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//! Example: Testing HTML list conversion (ordered and unordered lists)
|
|
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
|
-
fn main() {
|
|
11
|
-
let html = "<ol><li>First item</li><li>Second item</li><li>Third item</li></ol>";
|
|
12
|
-
match convert(html, None) {
|
|
13
|
-
Ok(markdown) => {
|
|
14
|
-
println!("Test - Ordered list:");
|
|
15
|
-
println!("HTML: {html}");
|
|
16
|
-
println!("Markdown:\n{markdown}");
|
|
17
|
-
println!("Expected:");
|
|
18
|
-
println!("1. First item");
|
|
19
|
-
println!("2. Second item");
|
|
20
|
-
println!("3. Third item");
|
|
21
|
-
println!();
|
|
22
|
-
}
|
|
23
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let html2 = "<ul><li>First item</li><li>Second item</li></ul>";
|
|
27
|
-
match convert(html2, None) {
|
|
28
|
-
Ok(markdown) => {
|
|
29
|
-
println!("Test - Unordered list:");
|
|
30
|
-
println!("HTML: {html2}");
|
|
31
|
-
println!("Markdown:\n{markdown}");
|
|
32
|
-
println!("Expected:");
|
|
33
|
-
println!("* First item");
|
|
34
|
-
println!("* Second item");
|
|
35
|
-
println!();
|
|
36
|
-
}
|
|
37
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
//! Example: Testing HTML5 semantic tags (article, section, nav, etc.)
|
|
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
|
-
fn main() {
|
|
11
|
-
let html = r"<article>
|
|
12
|
-
<header><h1>Title</h1></header>
|
|
13
|
-
<section><p>Content here</p></section>
|
|
14
|
-
<footer><p>Footer</p></footer>
|
|
15
|
-
</article>";
|
|
16
|
-
match convert(html, None) {
|
|
17
|
-
Ok(markdown) => {
|
|
18
|
-
println!("Test - Semantic blocks:");
|
|
19
|
-
println!("HTML: {html}");
|
|
20
|
-
println!("\nMarkdown:\n{markdown}");
|
|
21
|
-
println!();
|
|
22
|
-
}
|
|
23
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let html2 = r#"<figure>
|
|
27
|
-
<img src="image.jpg" alt="Diagram">
|
|
28
|
-
<figcaption>Figure 1: Example diagram</figcaption>
|
|
29
|
-
</figure>"#;
|
|
30
|
-
match convert(html2, None) {
|
|
31
|
-
Ok(markdown) => {
|
|
32
|
-
println!("Test - Figure/Figcaption:");
|
|
33
|
-
println!("HTML: {html2}");
|
|
34
|
-
println!("\nMarkdown:\n{markdown}");
|
|
35
|
-
println!("Expected: ");
|
|
36
|
-
println!(" *Figure 1: Example diagram*");
|
|
37
|
-
println!();
|
|
38
|
-
}
|
|
39
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let html3 = r"<p>As <cite>Shakespeare</cite> said, <q>To be or not to be</q></p>";
|
|
43
|
-
match convert(html3, None) {
|
|
44
|
-
Ok(markdown) => {
|
|
45
|
-
println!("Test - Cite/Quote:");
|
|
46
|
-
println!("HTML: {html3}");
|
|
47
|
-
println!("Markdown: {markdown}");
|
|
48
|
-
println!("Expected: As *Shakespeare* said, \"To be or not to be\"");
|
|
49
|
-
println!();
|
|
50
|
-
}
|
|
51
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let html4 = r"<dl>
|
|
55
|
-
<dt>Term 1</dt>
|
|
56
|
-
<dd>Definition 1</dd>
|
|
57
|
-
<dt>Term 2</dt>
|
|
58
|
-
<dd>Definition 2</dd>
|
|
59
|
-
</dl>";
|
|
60
|
-
match convert(html4, None) {
|
|
61
|
-
Ok(markdown) => {
|
|
62
|
-
println!("Test - Definition list:");
|
|
63
|
-
println!("HTML: {html4}");
|
|
64
|
-
println!("\nMarkdown:\n{markdown}");
|
|
65
|
-
println!("Expected:");
|
|
66
|
-
println!("**Term 1**");
|
|
67
|
-
println!("Definition 1");
|
|
68
|
-
println!();
|
|
69
|
-
println!("**Term 2**");
|
|
70
|
-
println!("Definition 2");
|
|
71
|
-
println!();
|
|
72
|
-
}
|
|
73
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let html5 = r"<hgroup>
|
|
77
|
-
<h1>Main Title</h1>
|
|
78
|
-
<h2>Subtitle</h2>
|
|
79
|
-
</hgroup>";
|
|
80
|
-
match convert(html5, None) {
|
|
81
|
-
Ok(markdown) => {
|
|
82
|
-
println!("Test - Hgroup:");
|
|
83
|
-
println!("HTML: {html5}");
|
|
84
|
-
println!("\nMarkdown:\n{markdown}");
|
|
85
|
-
println!();
|
|
86
|
-
}
|
|
87
|
-
Err(e) => eprintln!("Error: {e}"),
|
|
88
|
-
}
|
|
89
|
-
}
|