From ce06129976f7e19f3a508a32119f29eb5202e35c Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 8 Oct 2020 21:10:35 +0200 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + src/parser/mod.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 886d2e2..9b033e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ SPDX-License-Identifier: MIT - Add interactive tui viewer that adds support for following links from the documentation. - Add tests for Rust 1.47.0. +- Remove Notable Traits section from definitions. ## v0.3.0 (2020-09-11) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 25fee96..830728a 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -186,6 +186,12 @@ fn node_to_text(node: &kuchiki::NodeRef) -> String { } 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 add_newline = if node.is_element(&local_name!("br")) {