From b7ffe5865f44ee345d931b76ba84546e32615fbe Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 11 Jan 2023 09:55:33 -0800 Subject: [PATCH] Allow `--reference-doc` to take URL argument. Closes #8535. --- MANUAL.txt | 2 +- src/Text/Pandoc/Writers/Docx.hs | 3 ++- src/Text/Pandoc/Writers/ODT.hs | 3 ++- src/Text/Pandoc/Writers/Powerpoint/Output.hs | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MANUAL.txt b/MANUAL.txt index 7329073b4f2f..ceb3879d5024 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -1129,7 +1129,7 @@ header when requesting a document from a URL: user data directory (see `--data-dir`). If it is not found there, sensible defaults will be used. -`--reference-doc=`*FILE* +`--reference-doc=`*FILE*|*URL* : Use the specified file as a style reference in producing a docx or ODT file. diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index acefca360483..1f69d2fa9e68 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -134,7 +134,8 @@ writeDocx opts doc = do P.setUserDataDir oldUserDataDir let distArchive = toArchive $ BL.fromStrict res refArchive <- case writerReferenceDoc opts of - Just f -> toArchive <$> P.readFileLazy f + Just f -> toArchive . BL.fromStrict . fst + <$> P.fetchItem (T.pack f) Nothing -> toArchive . BL.fromStrict <$> readDataFile "reference.docx" diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 7f8a7df2ef02..3d343d804a4f 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -94,7 +94,8 @@ pandocToODT opts doc@(Pandoc meta _) = do lang <- toLang (getLang opts meta) refArchive <- case writerReferenceDoc opts of - Just f -> liftM toArchive $ lift $ P.readFileLazy f + Just f -> lift $ toArchive . B.fromStrict . fst <$> + (P.fetchItem (T.pack f)) Nothing -> lift $ toArchive . B.fromStrict <$> readDataFile "reference.odt" -- handle formulas and pictures diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs index d35930c7b63e..be7d169ca2b6 100644 --- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs +++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs @@ -578,7 +578,8 @@ presentationToArchive opts meta pres = do distArchive <- toArchive . BL.fromStrict <$> readDefaultDataFile "reference.pptx" refArchive <- case writerReferenceDoc opts of - Just f -> toArchive <$> P.readFileLazy f + Just f -> toArchive . BL.fromStrict . fst + <$> P.fetchItem (T.pack f) Nothing -> toArchive . BL.fromStrict <$> readDataFile "reference.pptx"