summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-04-30 07:48:25 +0300
committerLars Wirzenius <liw@liw.fi>2023-04-30 08:01:23 +0300
commit669c1dff64a45350b61e3cc0b393a72191dd2a37 (patch)
tree2b52c1bc8bb8ab3b1c64f5293d4f8d120044fa9a /src
parent76c290a9e46b5e9fb9021565d6fd84b9a38fa390 (diff)
downloadsubplot-669c1dff64a45350b61e3cc0b393a72191dd2a37.tar.gz
fix: extraction of plain text in scenario titles
When I changed Subplot to use pulldown_cmark for parsing markdown, I introduced a bug: if a scenario title uses markup (e.g., bold face), that part of the title was dropped when it was converted into scenario title. Fix that. Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/html.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/html.rs b/src/html.rs
index bff9c75..7237258 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -304,9 +304,7 @@ impl Element {
pub fn content(&self) -> String {
let mut buf = String::new();
for child in self.children() {
- if let Content::Text(s) = child {
- buf.push_str(s)
- }
+ buf.push_str(&child.content());
}
buf
}
@@ -534,6 +532,16 @@ pub enum Content {
Html(String),
}
+impl Content {
+ fn content(&self) -> String {
+ match self {
+ Self::Text(s) => s.clone(),
+ Self::Elt(e) => e.content(),
+ Self::Html(h) => h.clone(),
+ }
+ }
+}
+
/// Location of element in source file.
#[derive(Debug, Clone, Copy)]
pub struct Location {