From 2ba5156ee186f747e8102ac5e4872db5d634f6b3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 6 Oct 2023 20:34:13 -0400 Subject: [PATCH] Add a global setting for link templates. --- src/context/global_settings.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/context/global_settings.rs b/src/context/global_settings.rs index 32cad286..ebf9365a 100644 --- a/src/context/global_settings.rs +++ b/src/context/global_settings.rs @@ -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",