Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Adds ability to set variables at build time

AuthorDaveJarvis <email>
Date2023-07-23 15:25:28 GMT-0700
Commitdedc57e1cecac77df904749ae8e5dceea8e59d3c
Parent013112a
Delta23 lines added, 0 lines removed, 23-line increase
src/main/java/com/keenwrite/processors/ProcessorContext.java
}
+ /**
+ * Sets metadata to use in the document header. These are made available
+ * to the typesetting engine as {@code \documentvariable} values.
+ *
+ * @param metadata The key/value pairs to publish as document metadata.
+ */
public void setMetadata( final Supplier<Map<String, String>> metadata ) {
assert metadata != null;
mMetadata = metadata.get() == null ? HashMap::new : metadata;
+ }
+
+ /**
+ * Sets document variables to use when building the document. These
+ * variables will override existing key/value pairs, or be added as
+ * new key/value pairs if not already defined. This allows users to
+ * inject variables into the document from the command-line, allowing
+ * for dynamic assignment of in-text values when building documents.
+ *
+ * @param overrides The key/value pairs to add (or override) as variables.
+ */
+ public void setOverrides( final Supplier<Map<String, String>> overrides ) {
+ assert overrides != null;
+ assert mDefinitions != null;
+ assert mDefinitions.get() != null;
+
+ mDefinitions.get().putAll( overrides.get() );
}