From 0d1ba3dce33b8d5d30d7cf8febfa8ea3060b5dfd Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Thu, 13 Jan 2022 11:58:33 -0800 Subject: [PATCH] When reading defaults file, stop at a line `...`. This line signals the end of a YAML document. This restores the behavior we got with HsYaml. yaml complains about content past this line. See https://github.com/jgm/pandoc/issues/4627#issuecomment-1012438765 --- src/Text/Pandoc/App/Opt.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs index e1d9edcc9..4f5474c4f 100644 --- a/src/Text/Pandoc/App/Opt.hs +++ b/src/Text/Pandoc/App/Opt.hs @@ -52,6 +52,7 @@ import Data.Text (Text, unpack) import Data.Default (def) import qualified Data.Text as T import qualified Data.Map as M +import qualified Data.ByteString.Char8 as B8 import Text.Pandoc.Definition (Meta(..), MetaValue(..)) import Data.Aeson (defaultOptions, Options(..), Result(..), fromJSON, camelTo2) import Data.Aeson.TH (deriveJSON) @@ -692,7 +693,7 @@ applyDefaults opt file = do setVerbosity $ optVerbosity opt modify $ \defsState -> defsState{ curDefaults = Just file } inp <- readFileStrict file - case decodeEither' inp of + case decodeEither' (B8.unlines . takeWhile (/= "...") . B8.lines $ inp) of Right f -> f opt Left err' -> throwError $ PandocParseError