From dee30e2a1b455650dbbbec3bfab3dda43582a5fe Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 8 Sep 2021 09:29:46 -0700 Subject: Logging: add NotUTF8Encoded constructor to LogMessage. [API change] --- src/Text/Pandoc/Logging.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/Text/Pandoc/Logging.hs b/src/Text/Pandoc/Logging.hs index c49726040..bb2fb5d36 100644 --- a/src/Text/Pandoc/Logging.hs +++ b/src/Text/Pandoc/Logging.hs @@ -105,6 +105,7 @@ data LogMessage = | ATXHeadingInLHS Int Text | EnvironmentVariableUndefined Text | DuplicateAttribute Text Text + | NotUTF8Encoded FilePath deriving (Show, Eq, Data, Ord, Typeable, Generic) instance ToJSON LogMessage where @@ -244,6 +245,8 @@ instance ToJSON LogMessage where DuplicateAttribute attr val -> ["attribute" .= attr ,"value" .= val] + NotUTF8Encoded src -> + ["source" .= src] showPos :: SourcePos -> Text showPos pos = Text.pack $ sn ++ "line " ++ @@ -370,6 +373,9 @@ showLogMessage msg = "Undefined environment variable " <> var <> " in defaults file." DuplicateAttribute attr val -> "Ignoring duplicate attribute " <> attr <> "=" <> tshow val <> "." + NotUTF8Encoded src -> + Text.pack src <> + " is not UTF-8 encoded: falling back to latin1." messageVerbosity :: LogMessage -> Verbosity messageVerbosity msg = @@ -420,3 +426,4 @@ messageVerbosity msg = ATXHeadingInLHS{} -> WARNING EnvironmentVariableUndefined{}-> WARNING DuplicateAttribute{} -> WARNING + NotUTF8Encoded{} -> WARNING -- cgit v1.2.3