Skip to content

Commit

Permalink
Logging: Add UnclosedDiv constructor for LogMessage.
Browse files Browse the repository at this point in the history
[API change]
  • Loading branch information
jgm committed Apr 11, 2024
1 parent 4b5409a commit 820e371
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Text/Pandoc/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ data LogMessage =
| NotUTF8Encoded FilePath
| MakePDFInfo Text Text
| MakePDFWarning Text
| UnclosedDiv SourcePos SourcePos
deriving (Show, Eq, Data, Ord, Typeable, Generic)

instance ToJSON LogMessage where
Expand Down Expand Up @@ -260,6 +261,16 @@ instance ToJSON LogMessage where
,"contents" .= contents]
MakePDFWarning message ->
["message" .= message]
UnclosedDiv openpos closepos ->
["openpos" .= object
[ "source" .= sourceName openpos,
"line" .= toJSON (sourceLine openpos),
"column" .= toJSON (sourceColumn openpos)]
,"closepos" .= object
[ "source" .= sourceName closepos,
"line" .= toJSON (sourceLine closepos),
"column" .= toJSON (sourceColumn closepos)]
]

showPos :: SourcePos -> Text
showPos pos = Text.pack $ sn ++ "line " ++
Expand Down Expand Up @@ -400,6 +411,8 @@ showLogMessage msg =
then mempty
else "\n" <> contents
MakePDFWarning message -> "[makePDF] " <> message
UnclosedDiv openpos closepos -> "Div at " <> showPos openpos <>
" unclosed at " <> showPos closepos <> ", closing implicitly."

messageVerbosity :: LogMessage -> Verbosity
messageVerbosity msg =
Expand Down Expand Up @@ -455,3 +468,4 @@ messageVerbosity msg =
NotUTF8Encoded{} -> WARNING
MakePDFInfo{} -> INFO
MakePDFWarning{} -> WARNING
UnclosedDiv{} -> WARNING

0 comments on commit 820e371

Please sign in to comment.