summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-12-01 18:01:44 +0200
committerLars Wirzenius <liw@liw.fi>2023-12-25 10:17:07 +0200
commit9972ba7f7c798e12741e9310a258df64c9310c05 (patch)
tree0084856ea6a9c3dbb4c4cedac83d3b24aa48bdc0 /src/doc.rs
parentd6ba90c694fe8905aadf02acbbb0ff7e24f30b4e (diff)
downloadsubplot-9972ba7f7c798e12741e9310a258df64c9310c05.tar.gz
feat: typeset scenarios by typesetting steps
Typeset each step in a scenario, including captures in the steps. Previously the scenario was just one <pre> element, now things can be styled with CSS. Signed-off-by: Lars Wirzenius <liw@liw.fi> Sponsored-by: author
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 397bb75..1e48e40 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -526,7 +526,12 @@ impl Document {
for scenario in scenarios {
for step in scenario.steps() {
for captured in step.parts() {
- if let PartialStep::CapturedText { name, text } = captured {
+ if let PartialStep::CapturedText {
+ name,
+ text,
+ kind: _,
+ } = captured
+ {
if matches!(step.types().get(name.as_str()), Some(CaptureType::File))
&& !filenames.contains(&text.to_lowercase())
{
@@ -562,7 +567,12 @@ impl Document {
for scenario in scenarios {
for step in scenario.steps() {
for captured in step.parts() {
- if let PartialStep::CapturedText { name, text } = captured {
+ if let PartialStep::CapturedText {
+ name,
+ text,
+ kind: _,
+ } = captured
+ {
if matches!(step.types().get(name.as_str()), Some(CaptureType::File)) {
filenames.remove(&text.to_lowercase());
}
@@ -607,10 +617,15 @@ impl Document {
}
/// Typeset a Subplot document.
- pub fn typeset(&mut self, warnings: &mut Warnings) {
+ pub fn typeset(
+ &mut self,
+ warnings: &mut Warnings,
+ template: Option<&str>,
+ ) -> Result<(), SubplotError> {
for md in self.markdowns.iter_mut() {
- warnings.push_all(md.typeset(self.style.clone(), self.meta.bindings()));
+ warnings.push_all(md.typeset(self.style.clone(), template, self.meta.bindings()));
}
+ Ok(())
}
/// Return all scenarios in a document.