summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/ast.rs b/src/ast.rs
index c48a1e7..b60df71 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -60,6 +60,7 @@ impl YamlMetadata {
fn new(yaml_text: &str) -> Result<Self, Error> {
trace!("Parsing YAML");
let meta: Self = serde_yaml::from_str(yaml_text)?;
+ trace!("parsed metadata: {:#?}", meta);
Ok(meta)
}
@@ -68,6 +69,60 @@ impl YamlMetadata {
&self.markdowns[0]
}
+ /// Title.
+ pub fn title(&self) -> &str {
+ &self.title
+ }
+
+ /// Subtitle.
+ pub fn subtitle(&self) -> Option<&str> {
+ self.subtitle.as_deref()
+ }
+
+ /// Date.
+ pub fn date(&self) -> Option<&str> {
+ self.date.as_deref()
+ }
+
+ /// Authors.
+ pub fn authors(&self) -> Option<&[String]> {
+ self.authors.as_deref()
+ }
+
+ /// Names of bindings files.
+ pub fn bindings_filenames(&self) -> Option<&[PathBuf]> {
+ self.bindings.as_deref()
+ }
+
+ /// Impls section.
+ pub fn impls(&self) -> &BTreeMap<String, Vec<PathBuf>> {
+ &self.impls
+ }
+
+ /// Bibliographies.
+ pub fn bibliographies(&self) -> Option<&[PathBuf]> {
+ self.bibliography.as_deref()
+ }
+
+ /// Classes..
+ pub fn classes(&self) -> Option<&[String]> {
+ self.classes.as_deref()
+ }
+
+ /// Documentclass.
+ pub fn documentclass(&self) -> Option<&str> {
+ self.documentclass.as_deref()
+ }
+
+ /// Pandoc metadata.
+ pub fn pandoc(&self) -> Option<&HashMap<String, Value>> {
+ if let Some(x) = &self.pandoc {
+ Some(x)
+ } else {
+ None
+ }
+ }
+
/// Convert into a pandoc_ast::Map.
pub fn to_map(&self) -> Map<String, MetaValue> {
trace!("Creating metadata map from parsed YAML");