summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2023-04-30 08:10:48 +0000
committerDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2023-04-30 08:10:48 +0000
commit265b69a84bfd3ade02c13b57f6ad0353765e040a (patch)
tree2b52c1bc8bb8ab3b1c64f5293d4f8d120044fa9a
parent76c290a9e46b5e9fb9021565d6fd84b9a38fa390 (diff)
parent669c1dff64a45350b61e3cc0b393a72191dd2a37 (diff)
downloadsubplot-265b69a84bfd3ade02c13b57f6ad0353765e040a.tar.gz
Merge branch 'liw/fix-scenario-title-markup' into 'main'
fix: extraction of plain text in scenario titles Closes #316 See merge request subplot/subplot!325
-rw-r--r--src/html.rs14
-rw-r--r--subplot.md34
2 files changed, 45 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 {
diff --git a/subplot.md b/subplot.md
index 934623e..05edeae 100644
--- a/subplot.md
+++ b/subplot.md
@@ -1275,6 +1275,40 @@ impls: { python: [] }
# Introduction
~~~~
+## Scenario titles
+
+A scenario gets its title from the lowest level of section heading
+that applies to it. The heading can use markup.
+
+~~~scenario
+given file scenario-titles.subplot
+given file scenario-titles.md
+given file b.yaml
+given file f.py
+given an installed subplot
+when I run subplot metadata scenario-titles.subplot
+then stdout contains "My fun scenario title"
+~~~
+
+~~~~{#scenario-titles.subplot .file .yaml .numberLines}
+title: Test scenario
+markdowns:
+- scenario-titles.md
+bindings: [b.yaml]
+impls:
+ python: [f.py]
+~~~~
+
+~~~~{#scenario-titles.md .file .markdown .numberLines}
+# My **fun** _scenario_ `title`
+
+```scenario
+given precondition foo
+when I do bar
+then bar was done
+```
+~~~~
+
## Empty lines in scenarios
This scenario verifies that empty lines in scenarios are OK.