@@ -52,31 +52,35 @@ instance ToJSON Verbosity where
5252 toJSON x = toJSON (show x)
5353
5454data LogMessage =
55− SkippedInput String SourcePos
56− | YamlSectionNotAnObject SourcePos
55+ SkippedContent String SourcePos
56+ | CouldNotParseYamlMetadata String SourcePos
5757 | DuplicateLinkReference String SourcePos
5858 | DuplicateNoteReference String SourcePos
59+ | ReferenceNotFound String SourcePos
5960 | ParsingUnescaped String SourcePos
61+ | CouldNotLoadIncludeFile String SourcePos
62+ | ParsingTrace String SourcePos
6063 | InlineNotRendered Inline
6164 | BlockNotRendered Block
62− | DocxCommentWillNotRetainFormatting String
65+ | DocxParserWarning String
6366 | CouldNotFetchResource String String
64− | CouldNotDetermineImageSize String
67+ | CouldNotDetermineImageSize String String
6568 | CouldNotDetermineMimeType String
66− | CouldNotConvertTeXMath String
69+ | CouldNotConvertTeXMath String String
6770 deriving (Show, Eq, Data, Ord, Typeable, Generic)
6871
6972instance ToJSON LogMessage where
7073 toJSON x = object $ "verbosity" .= toJSON (messageVerbosity x) :
7174 case x of
72− SkippedInput s pos ->
73− ["type" .= String "SkippedInput",
75+ SkippedContent s pos ->
76+ ["type" .= String "SkippedContent",
7477 "contents" .= Text.pack s,
7578 "source" .= Text.pack (sourceName pos),
7679 "line" .= sourceLine pos,
7780 "column" .= sourceColumn pos]
78− YamlSectionNotAnObject pos ->
81+ CouldNotParseYamlMetadata s pos ->
7982 ["type" .= String "YamlSectionNotAnObject",
83+ "message" .= Text.pack s,
8084 "source" .= Text.pack (sourceName pos),
8185 "line" .= toJSON (sourceLine pos),
8286 "column" .= toJSON (sourceColumn pos)]
@@ -92,75 +96,114 @@ instance ToJSON LogMessage where
9296 "source" .= Text.pack (sourceName pos),
9397 "line" .= toJSON (sourceLine pos),
9498 "column" .= toJSON (sourceColumn pos)]
99+ ReferenceNotFound s pos ->
100+ ["type" .= String "ReferenceNotFound",
101+ "contents" .= Text.pack s,
102+ "source" .= Text.pack (sourceName pos),
103+ "line" .= toJSON (sourceLine pos),
104+ "column" .= toJSON (sourceColumn pos)]
95105 ParsingUnescaped s pos ->
96106 ["type" .= String "ParsingUnescaped",
97107 "contents" .= Text.pack s,
98108 "source" .= Text.pack (sourceName pos),
99109 "line" .= toJSON (sourceLine pos),
100110 "column" .= toJSON (sourceColumn pos)]
111+ CouldNotLoadIncludeFile fp pos ->
112+ ["type" .= String "CouldNotLoadIncludeFile",
113+ "path" .= Text.pack fp,
114+ "source" .= Text.pack (sourceName pos),
115+ "line" .= toJSON (sourceLine pos),
116+ "column" .= toJSON (sourceColumn pos)]
117+ ParsingTrace s pos ->
118+ ["type" .= String "ParsingTrace",
119+ "contents" .= Text.pack s,
120+ "source" .= Text.pack (sourceName pos),
121+ "line" .= sourceLine pos,
122+ "column" .= sourceColumn pos]
101123 InlineNotRendered il ->
102124 ["type" .= String "InlineNotRendered",
103125 "contents" .= toJSON il]
104126 BlockNotRendered bl ->
105127 ["type" .= String "BlockNotRendered",
106128 "contents" .= toJSON bl]
107− DocxCommentWillNotRetainFormatting s ->
108− ["type" .= String "DocxCommentWillNotRetainFormatting",
109− "commentId" .= Text.pack s]
129+ DocxParserWarning s ->
130+ ["type" .= String "DocxParserWarning",
131+ "contents" .= Text.pack s]
110132 CouldNotFetchResource fp s ->
111133 ["type" .= String "CouldNotFetchResource",
112134 "path" .= Text.pack fp,
113135 "message" .= Text.pack s]
114− CouldNotDetermineImageSize fp ->
136+ CouldNotDetermineImageSize fp s ->
115137 ["type" .= String "CouldNotDetermineImageSize",
116− "path" .= Text.pack fp]
138+ "path" .= Text.pack fp,
139+ "message" .= Text.pack s]
117140 CouldNotDetermineMimeType fp ->
118141 ["type" .= String "CouldNotDetermineMimeType",
119142 "path" .= Text.pack fp]
120− CouldNotConvertTeXMath s ->
143+ CouldNotConvertTeXMath s msg ->
121144 ["type" .= String "CouldNotConvertTeXMath",
122− "contents" .= Text.pack s]
145+ "contents" .= Text.pack s,
146+ "message" .= Text.pack msg]
147+
148+showPos :: SourcePos -> String
149+showPos pos = sn ++ "line " ++
150+ show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)
151+ where sn = if sourceName pos == "source" || sourceName pos == ""
152+ then ""
153+ else sourceName pos ++ " "
123154
124155showLogMessage :: LogMessage -> String
125156showLogMessage msg =
126157 case msg of
127− SkippedInput s pos ->
128− "Skipped '" ++ s ++ "' at " ++ show pos
129− YamlSectionNotAnObject pos ->
130− "YAML metadata section is not an object at " ++ show pos
158+ SkippedContent s pos ->
159+ "Skipped '" ++ s ++ "' at " ++ showPos pos
160+ CouldNotParseYamlMetadata s pos ->
161+ "Could not parse YAML metadata at " ++ showPos pos ++
162+ if null s then "" else (": " ++ s)
131163 DuplicateLinkReference s pos ->
132− "Duplicate link reference '" ++ s ++ "' at " ++ show pos
164+ "Duplicate link reference '" ++ s ++ "' at " ++ showPos pos
133165 DuplicateNoteReference s pos ->
134− "Duplicate note reference '" ++ s ++ "' at " ++ show pos
166+ "Duplicate note reference '" ++ s ++ "' at " ++ showPos pos
167+ ReferenceNotFound s pos ->
168+ "Reference not found for '" ++ s ++ "' at " ++ showPos pos
135169 ParsingUnescaped s pos ->
136− "Parsing unescaped '" ++ s ++ "' at " ++ show pos
170+ "Parsing unescaped '" ++ s ++ "' at " ++ showPos pos
171+ CouldNotLoadIncludeFile fp pos ->
172+ "Could not load include file '" ++ fp ++ "' at " ++ showPos pos
173+ ParsingTrace s pos ->
174+ "Parsing trace at " ++ showPos pos ++ ": " ++ s
137175 InlineNotRendered il ->
138176 "Not rendering " ++ show il
139177 BlockNotRendered bl ->
140178 "Not rendering " ++ show bl
141− DocxCommentWillNotRetainFormatting s ->
142− "Docx comment with id '" ++ s ++ "' will not retain formatting"
179+ DocxParserWarning s ->
180+ "Docx parser warning: " ++ s
143181 CouldNotFetchResource fp s ->
144182 "Could not fetch resource '" ++ fp ++ "'" ++
145183 if null s then "" else (": " ++ s)
146− CouldNotDetermineImageSize fp ->
147− "Could not determine image size for '" ++ fp ++ "'"
184+ CouldNotDetermineImageSize fp s ->
185+ "Could not determine image size for '" ++ fp ++ "'" ++
186+ if null s then "" else (": " ++ s)
148187 CouldNotDetermineMimeType fp ->
149188 "Could not determine mime type for '" ++ fp ++ "'"
150− CouldNotConvertTeXMath s ->
151− "Could not convert TeX math '" ++ s ++ "', rendering as TeX"
189+ CouldNotConvertTeXMath s m ->
190+ "Could not convert TeX math '" ++ s ++ "', rendering as TeX" ++
191+ if null m then "" else (':':'\n':m)
152192
153193messageVerbosity:: LogMessage -> Verbosity
154194messageVerbosity msg =
155195 case msg of
156− SkippedInput{} -> INFO
157− YamlSectionNotAnObject{} -> WARNING
196+ SkippedContent{} -> INFO
197+ CouldNotParseYamlMetadata{} -> WARNING
158198 DuplicateLinkReference{} -> WARNING
159199 DuplicateNoteReference{} -> WARNING
200+ ReferenceNotFound{} -> WARNING
201+ CouldNotLoadIncludeFile{} -> WARNING
160202 ParsingUnescaped{} -> INFO
203+ ParsingTrace{} -> DEBUG
161204 InlineNotRendered{} -> INFO
162205 BlockNotRendered{} -> INFO
163− DocxCommentWillNotRetainFormatting{} -> INFO
206+ DocxParserWarning{} -> WARNING
164207 CouldNotFetchResource{} -> WARNING
165208 CouldNotDetermineImageSize{} -> WARNING
166209 CouldNotDetermineMimeType{} -> WARNING