From 7df29e495f17b239f0e4b239fda849a1f27d2cf2 Mon Sep 17 00:00:00 2001 From: Even Brenden Date: Fri, 21 Jan 2022 21:00:45 +0100 Subject: Search for metadata files in $DATADIR/metadata (#7851) If files specified with `--metadata-file` are not found in the working directory, look in `$DATADIR/metadata`. Expose new `readMetadataFile` function from Text.Pandoc.Class [API change]. Expose new `PandocCouldNotFindMetadataFileError` constructor for `PandocError` from Text.Pandoc.Error [API change]. Closes #5876. --- test/command/5876.md | 58 ++++++++++++++++++++++++++++ test/command/5876.yaml | 3 ++ test/command/5876/metadata/5876.yaml | 3 ++ test/command/5876/metadata/command/5876.yaml | 3 ++ 4 files changed, 67 insertions(+) create mode 100644 test/command/5876.md create mode 100644 test/command/5876.yaml create mode 100644 test/command/5876/metadata/5876.yaml create mode 100644 test/command/5876/metadata/command/5876.yaml (limited to 'test/command') diff --git a/test/command/5876.md b/test/command/5876.md new file mode 100644 index 000000000..7671a89cf --- /dev/null +++ b/test/command/5876.md @@ -0,0 +1,58 @@ +``` +% pandoc -s -t native --data-dir=command/5876 --metadata-file=5876.yaml +Hello +^D +Pandoc + Meta + { unMeta = + fromList + [ ( "desc" + , MetaInlines + [ Str "Found" + , Space + , Str "in" + , Space + , Str "metadata" + , Space + , Str "directory." + ] + ) + ] + } + [ Para [ Str "Hello" ] ] +``` +``` +% pandoc -s -t native --data-dir=command/5876 --metadata-file=command/5876.yaml +Hello +^D +Pandoc + Meta + { unMeta = + fromList + [ ( "desc" + , MetaInlines + [ Str "Found" + , Space + , Str "in" + , Space + , Str "working" + , Space + , Str "directory." + ] + ) + ] + } + [ Para [ Str "Hello" ] ] +``` +``` +% pandoc -s -t native --data-dir=command/5876 --metadata-file=does-not-exist.yaml +Hello +^D +Could not find metadata file does-not-exist.yaml +``` +``` +% pandoc -s -t native --metadata-file=does-not-exist.yaml +Hello +^D +Could not find metadata file does-not-exist.yaml +``` diff --git a/test/command/5876.yaml b/test/command/5876.yaml new file mode 100644 index 000000000..9e6604922 --- /dev/null +++ b/test/command/5876.yaml @@ -0,0 +1,3 @@ +--- +desc: Found in working directory. +--- diff --git a/test/command/5876/metadata/5876.yaml b/test/command/5876/metadata/5876.yaml new file mode 100644 index 000000000..d52de910f --- /dev/null +++ b/test/command/5876/metadata/5876.yaml @@ -0,0 +1,3 @@ +--- +desc: Found in metadata directory. +--- diff --git a/test/command/5876/metadata/command/5876.yaml b/test/command/5876/metadata/command/5876.yaml new file mode 100644 index 000000000..6bb46d51e --- /dev/null +++ b/test/command/5876/metadata/command/5876.yaml @@ -0,0 +1,3 @@ +--- +desc: Should not be loaded. +--- -- cgit v1.2.3