
This PR adds a new crate for converting rustdoc output to Markdown. We're leveraging Servo's `html5ever` to parse the Markdown content, and then walking the DOM nodes to convert it to a Markdown string. The Markdown output will be continued to be refined, but it's in a place where it should be reasonable. Release Notes: - N/A
29 lines
746 B
Rust
29 lines
746 B
Rust
use indoc::indoc;
|
|
use rustdoc_to_markdown::convert_rustdoc_to_markdown;
|
|
|
|
pub fn main() {
|
|
let html = indoc! {"
|
|
<html>
|
|
<body>
|
|
<h1>Hello World</h1>
|
|
<p>
|
|
Here is some content.
|
|
</p>
|
|
<h2>Some items</h2>
|
|
<ul>
|
|
<li>One</li>
|
|
<li>Two</li>
|
|
<li>Three</li>
|
|
</ul>
|
|
</body>
|
|
</html>
|
|
"};
|
|
// To test this out with some real input, try this:
|
|
//
|
|
// ```
|
|
// let html = include_str!("/path/to/zed/target/doc/gpui/index.html");
|
|
// ```
|
|
let markdown = convert_rustdoc_to_markdown(html).unwrap();
|
|
|
|
println!("{markdown}");
|
|
}
|