Serialize toc level
This commit is contained in:
parent
d7bad732f1
commit
622b0f2965
|
@ -3,7 +3,6 @@ use serde_derive::Serialize;
|
||||||
/// Populated while receiving events from the markdown parser
|
/// Populated while receiving events from the markdown parser
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||||
pub struct Heading {
|
pub struct Heading {
|
||||||
#[serde(skip_serializing)]
|
|
||||||
pub level: u32,
|
pub level: u32,
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub permalink: String,
|
pub permalink: String,
|
||||||
|
@ -115,6 +114,7 @@ mod tests {
|
||||||
];
|
];
|
||||||
let toc = make_table_of_contents(input);
|
let toc = make_table_of_contents(input);
|
||||||
assert_eq!(toc.len(), 1);
|
assert_eq!(toc.len(), 1);
|
||||||
|
assert_eq!(toc[0].level, 1);
|
||||||
assert_eq!(toc[0].children.len(), 1);
|
assert_eq!(toc[0].children.len(), 1);
|
||||||
assert_eq!(toc[0].children[0].children.len(), 1);
|
assert_eq!(toc[0].children[0].children.len(), 1);
|
||||||
assert_eq!(toc[0].children[0].children[0].children.len(), 2);
|
assert_eq!(toc[0].children[0].children[0].children.len(), 2);
|
||||||
|
|
Loading…
Reference in a new issue