Add a global setting for link templates.

This commit is contained in:
Tom Alexander 2023-10-06 20:34:13 -04:00
parent ae3a6ff919
commit 2ba5156ee1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,4 @@
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use super::FileAccessInterface;
@ -42,6 +43,13 @@ pub struct GlobalSettings<'g, 's> {
///
/// Corresponds to org-link-parameters elisp variable.
pub link_parameters: &'g [&'g str],
/// Link templates where the key is the document text and the value is the replacement.
///
/// For example, `"foo": "bar%s"` will replace `[[foo::baz]]` with `[[barbaz]]`
///
/// This is set by including #+LINK in the org-mode document.
pub link_templates: BTreeMap<&'s str, &'s str>,
}
pub const DEFAULT_TAB_WIDTH: IndentationLevel = 8;
@ -60,7 +68,8 @@ impl<'g, 's> GlobalSettings<'g, 's> {
odd_levels_only: HeadlineLevelFilter::default(),
footnote_section: "Footnotes",
coderef_label_format: "(ref:%s)",
link_parameters: &ORG_LINK_PARAMETERS,
link_parameters: &DEFAULT_ORG_LINK_PARAMETERS,
link_templates: BTreeMap::new(),
}
}
}
@ -83,7 +92,7 @@ impl Default for HeadlineLevelFilter {
}
}
const ORG_LINK_PARAMETERS: [&'static str; 23] = [
const DEFAULT_ORG_LINK_PARAMETERS: [&'static str; 23] = [
"id",
"eww",
"rmail",