Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
src/main/java/com/keenwrite/MainPane.java
return builder()
- .with( Mutator::setDefinitions, this::getDefinitions )
.with( Mutator::setWorkspace, w )
+ .with( Mutator::setDefinitions, this::getDefinitions )
.with( Mutator::setLocale, w::getLocale )
+ .with( Mutator::setMetadata, w::getMetadata )
.with( Mutator::setThemePath, w::getThemePath )
.with( Mutator::setCaret,
src/main/java/com/keenwrite/cmdline/Arguments.java
.with( Mutator::setOutputPath, mPathOutput )
.with( Mutator::setExportFormat, format )
+ .with( Mutator::setDefinitions, () -> definitions )
+ .with( Mutator::setMetadata, () -> mMetadata )
.with( Mutator::setLocale, () -> locale )
.with( Mutator::setThemePath, () -> mDirTheme )
.with( Mutator::setConcatenate, mConcatenate )
.with( Mutator::setImageDir, () -> mImageDir )
.with( Mutator::setImageServer, () -> mImageServer )
.with( Mutator::setImageOrder, () -> mImageOrder )
- .with( Mutator::setDefinitions, () -> definitions )
.with( Mutator::setSigilBegan, () -> mSigilBegan )
.with( Mutator::setSigilEnded, () -> mSigilEnded )
}
- private Locale lookupLocale( final String locale ) {
+ private static Locale lookupLocale( final String locale ) {
try {
return Locale.forLanguageTag( locale );
src/main/java/com/keenwrite/preferences/Workspace.java
}
+ @SuppressWarnings( "unchecked" )
+ public <K, V> Map<K, V> getMetadata() {
+ final var metadata = listsProperty( KEY_DOC_META );
+ final var map = new HashMap<K, V>( metadata.size() );
+
+ metadata.forEach(
+ entry -> map.put( (K) entry.getKey(), (V) entry.getValue() )
+ );
+
+ return map;
+ }
+
public Path getThemePath() {
final var dir = getFile( KEY_TYPESET_CONTEXT_THEMES_PATH );
src/main/java/com/keenwrite/processors/ProcessorContext.java
import java.io.File;
import java.nio.file.Path;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
private Supplier<Path> mThemePath;
- private Supplier<Locale> mLocale;
+ private Supplier<Locale> mLocale = () -> Locale.ENGLISH;
- private Supplier<Map<String, String>> mDefinitions;
+ private Supplier<Map<String, String>> mDefinitions = HashMap::new;
+ private Supplier<Map<String, String>> mMetadata = HashMap::new;
private Supplier<Caret> mCaret = () -> Caret.builder().build();
private Supplier<Path> mImageDir;
- private Supplier<String> mImageServer;
- private Supplier<String> mImageOrder;
+ private Supplier<String> mImageServer = () -> DIAGRAM_SERVER_NAME;
+ private Supplier<String> mImageOrder = () -> PERSIST_IMAGES_DEFAULT;
- private Supplier<String> mSigilBegan;
- private Supplier<String> mSigilEnded;
+ private Supplier<String> mSigilBegan = () -> DEF_DELIM_BEGAN_DEFAULT;
+ private Supplier<String> mSigilEnded = () -> DEF_DELIM_ENDED_DEFAULT;
private Supplier<Path> mRWorkingDir;
assert exportFormat != null;
mExportFormat = exportFormat;
+ }
+
+ public void setConcatenate( final boolean concatenate ) {
+ mConcatenate = concatenate;
}
assert themePath != null;
mThemePath = themePath;
- }
-
- /**
- * Sets the source for deriving the {@link Caret}. Typically, this is
- * the text editor that has focus.
- *
- * @param caret The source for the currently active caret.
- */
- public void setCaret( final Supplier<Caret> caret ) {
- assert caret != null;
- mCaret = caret;
}
}
- public void setConcatenate( final boolean concatenate ) {
- mConcatenate = concatenate;
+ public void setMetadata( final Supplier<Map<String, String>> metadata ) {
+ assert metadata != null;
+ mMetadata = metadata;
+ }
+
+ /**
+ * Sets the source for deriving the {@link Caret}. Typically, this is
+ * the text editor that has focus.
+ *
+ * @param caret The source for the currently active caret.
+ */
+ public void setCaret( final Supplier<Caret> caret ) {
+ assert caret != null;
+ mCaret = caret;
}
return map;
+ }
+
+ public Map<String, String> getMetadata() {
+ return mMutator.mMetadata.get();
}
src/main/java/com/keenwrite/processors/XhtmlProcessor.java
import com.whitemagicsoftware.keenquotes.Contractions;
import com.whitemagicsoftware.keenquotes.Converter;
-import javafx.beans.property.ListProperty;
import org.w3c.dom.Document;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Map.Entry;
import static com.keenwrite.Bootstrap.APP_TITLE_LOWERCASE;
import static com.keenwrite.dom.DocumentParser.createMeta;
import static com.keenwrite.dom.DocumentParser.visit;
import static com.keenwrite.events.StatusEvent.clue;
import static com.keenwrite.io.HttpFacade.httpGet;
-import static com.keenwrite.preferences.AppKeys.KEY_DOC_META;
import static com.keenwrite.util.ProtocolScheme.getProtocol;
import static com.whitemagicsoftware.keenquotes.Converter.CHARS;
*/
private Map<String, String> createMetaDataMap( final Document doc ) {
- final Map<String, String> result = new LinkedHashMap<>();
- final var metadata = getMetaData();
+ final var result = new LinkedHashMap<String, String>();
+ final var metadata = getMetadata();
final var map = mContext.getInterpolatedDefinitions();
- metadata.forEach( entry -> result.put(
- entry.getKey(), map.interpolate( entry.getValue() ) )
+ metadata.forEach(
+ ( key, value ) -> result.put( key, map.interpolate( value ) )
);
result.put( "count", wordCount( doc ) );
* @return The document metadata.
*/
- private ListProperty<Entry<String, String>> getMetaData() {
- return mContext.getWorkspace().listsProperty( KEY_DOC_META );
+ private Map<String, String> getMetadata() {
+ return mContext.getMetadata();
}
}
- private Locale locale() {
+ private Locale getLocale() {
return mContext.getLocale();
}
);
- return valueOf( WordCounter.create( locale() ).count( sb.toString() ) );
+ return valueOf( WordCounter.create( getLocale() ).count( sb.toString() ) );
}

Add metadata command-line argument

Author DaveJarvis <email>
Date 2022-01-03 23:08:41 GMT-0800
Commit 859933563de7904c14cbec7b0523793a0ce12a3b
Parent ee4b72c
Delta 55 lines added, 35 lines removed, 20-line increase