pub struct Document {
pub children: Vec<Block>,
pub title: Option<Vec<Inline>>,
pub subtitle: Option<Vec<Inline>>,
pub header: Vec<Block>,
pub footer: Vec<Block>,
pub next_id: usize,
pub messages: Vec<SystemMessage>,
pub meta: Vec<(String, String)>,
}Expand description
Parsed document: section tree plus collected metadata.
Fields§
§children: Vec<Block>§title: Option<Vec<Inline>>§subtitle: Option<Vec<Inline>>§header: Vec<Block>.. header:: / .. footer:: decoration bodies.
next_id: usizeNext free linkage number for message/problematic ids.
messages: Vec<SystemMessage>Non-halting parse problems, in document order.
meta: Vec<(String, String)>.. meta:: name/content pairs for the HTML head.
Implementations§
Source§impl Document
impl Document
Sourcepub fn astext(&self) -> String
pub fn astext(&self) -> String
Examples found in repository?
examples/publish.rs (line 40)
10fn main() {
11 let path = std::env::args().nth(1).expect("usage: publish <file.rst>");
12 let source = std::fs::read_to_string(&path).expect("read input");
13 // Parity harness: report everything (mirrors the oracle at
14 // report_level 1); default filtering is covered by unit tests.
15 let settings = Settings {
16 report_level: 1,
17 ..Settings::default()
18 };
19 let doc = match publish_doctree_with(&source, &settings, None) {
20 Ok(doc) => doc,
21 Err(h) => {
22 eprintln!("HALT {h}");
23 std::process::exit(1);
24 }
25 };
26 eprintln!("-- messages:");
27 for m in &doc.messages {
28 let line = m
29 .line
30 .map(|n| n.to_string())
31 .unwrap_or_else(|| "None".into());
32 eprintln!(
33 "MSG level={} line={} {}",
34 m.level,
35 line,
36 m.text.replace('\n', "\\n")
37 );
38 }
39 eprintln!("-- astext --");
40 eprintln!("{}", doc.astext());
41 match publish_string_with(&source, &settings, None) {
42 Ok((html, _)) => println!("{html}"),
43 Err(h) => {
44 eprintln!("HALT {h}");
45 std::process::exit(1);
46 }
47 }
48}Trait Implementations§
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more