diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-04-30 07:48:25 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-04-30 08:01:23 +0300 |
commit | 669c1dff64a45350b61e3cc0b393a72191dd2a37 (patch) | |
tree | 2b52c1bc8bb8ab3b1c64f5293d4f8d120044fa9a /src | |
parent | 76c290a9e46b5e9fb9021565d6fd84b9a38fa390 (diff) | |
download | subplot-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.rs | 14 |
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 { |