Remove Notable Traits section from definitions

Rust 1.47.0 introduced the Notable Traits section that lists information
about types used in code block.  As we only want to display the code
block itself without meta-information, this patch ignores the
notable-traits class when extracting the text from nodes.
This commit is contained in:
Robin Krahl 2020-10-08 21:10:35 +02:00
parent 9832c22b4d
commit ce06129976
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8
2 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,7 @@ SPDX-License-Identifier: MIT
- Add interactive tui viewer that adds support for following links from the - Add interactive tui viewer that adds support for following links from the
documentation. documentation.
- Add tests for Rust 1.47.0. - Add tests for Rust 1.47.0.
- Remove Notable Traits section from definitions.
## v0.3.0 (2020-09-11) ## v0.3.0 (2020-09-11)

View File

@ -186,6 +186,12 @@ fn node_to_text(node: &kuchiki::NodeRef) -> String {
} }
fn push_node_to_text(s: &mut String, node: &kuchiki::NodeRef) { fn push_node_to_text(s: &mut String, node: &kuchiki::NodeRef) {
if node.has_class("notable-traits") {
// The notable-traits element lists informations about types in a code block. But we only
// want to extract the code, so we skip this element.
return;
}
let is_docblock = node.has_class("docblock"); let is_docblock = node.has_class("docblock");
let add_newline = if node.is_element(&local_name!("br")) { let add_newline = if node.is_element(&local_name!("br")) {