Skip to content

Commit

Permalink
Improve parser mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
KmolYuan committed May 24, 2022
1 parent 7d10e59 commit 0bbf3f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "reveal-yaml"
description = "A YAML project manager serving Reveal.js slides."
version = "1.1.0"
version = "1.1.1"
authors = ["KmolYuan <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
8 changes: 6 additions & 2 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub use self::{
background::*, content::*, footer::*, js_option::*, js_plugin::*, metadata::*, slides::*,
to_html::*, wrap_string::*,
};
use serde::Deserialize;
use serde::Deserialize as _;
use std::io::{Error as IoError, ErrorKind};
use yaml_peg::{indicated_msg, parse, repr::RcRepr, serde::SerdeError};

Expand Down Expand Up @@ -172,7 +172,11 @@ pub(crate) fn load(doc: &str, mount: &str, auto_reload: bool) -> Result<String,
(Metadata::default(), Slides { slides })
}
[n1, n2] => {
let slides = Vec::deserialize(n2.clone()).map_err(disp)?;
let slides = if let Ok(slides) = Vec::deserialize(n2.clone()) {
slides
} else {
vec![ChapterSlide::deserialize(n2.clone()).map_err(disp)?]
};
(metadata(n1.clone()).map_err(disp)?, Slides { slides })
}
[n1, ns @ ..] => {
Expand Down

0 comments on commit 0bbf3f3

Please sign in to comment.