Skip to content

Commit

Permalink
Update YAML API.
Browse files Browse the repository at this point in the history
  • Loading branch information
KmolYuan committed Jul 26, 2021
1 parent d353f45 commit 335b388
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ zip = "0.5"
reqwest = { version = "0.11", features = ["blocking"] }
actix-web = "3.3"
actix-files = "0.5"
yaml-peg = "0.10"
yaml-peg = "0.12"
pulldown-cmark = "0.8"
5 changes: 2 additions & 3 deletions src/loader/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct FragMap(HashMap<String, HashMap<usize, String>>);
impl FragMap {
fn new(slide: &Node, count: &mut usize) -> Result<Self, Error> {
let mut frag_map = HashMap::new();
for h in slide.get_default("fragment", &vec![], Node::as_array)? {
for h in slide.get_default("fragment", vec![], Node::as_array)? {
for (k, v) in h.as_map()?.iter() {
let k = k.as_str()?;
let v = v.as_str()?;
Expand Down Expand Up @@ -177,8 +177,7 @@ pub(crate) fn content_block(
.iter()
.enumerate()
{
let empty = vec![];
let stack = slide.get_default(title, &empty, Node::as_array)?;
let stack = slide.get_default(title, vec![], Node::as_array)?;
if stack.is_empty() {
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn load_main(yaml: Array<RcRepr>, v: &Anchors, mount: &str) -> Result<String, Er
let slide = slide.as_anchor(v);
doc += "<section>";
doc += &slide_block(&slide, v, &bg, i == 0)?;
for slide in slide.get_default("sub", &vec![], Node::as_array)? {
for slide in slide.get_default("sub", vec![], Node::as_array)? {
doc += &slide_block(&slide.as_anchor(v), v, &bg, false)?;
}
if i == 0 {
Expand All @@ -225,8 +225,7 @@ fn load_main(yaml: Array<RcRepr>, v: &Anchors, mount: &str) -> Result<String, Er
continue;
}
doc += &format!("<li><a href=\"#/{}\">{}</a></li>", i, t);
let empty = vec![];
let sub = slide.get_default("sub", &empty, Node::as_array)?;
let sub = slide.get_default("sub", vec![], Node::as_array)?;
if sub.is_empty() {
continue;
}
Expand Down

0 comments on commit 335b388

Please sign in to comment.