aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-09-08 09:29:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-09-08 09:29:46 -0700
commitdee30e2a1b455650dbbbec3bfab3dda43582a5fe (patch)
treee0666e8f04a01f66f5ba87bb6bcc418adbf2fae5 /src
parent395d65fdbe398e42270acfe6a76ad98a00ecb35d (diff)
downloadpandoc-dee30e2a1b455650dbbbec3bfab3dda43582a5fe.tar.gz
Logging: add NotUTF8Encoded constructor to LogMessage.
[API change]
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Logging.hs7
1 files changed, 7 insertions, 0 deletions
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