"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Text/Pandoc/Logging.hs" between
pandoc-2.11.1.1.tar.gz and pandoc-2.11.2.tar.gz

About: Pandoc converts files from one markup format into another.

Logging.hs  (pandoc-2.11.1.1):Logging.hs  (pandoc-2.11.2)
skipping to change at line 34 skipping to change at line 34
) where ) where
import Control.Monad (mzero) import Control.Monad (mzero)
import Data.YAML (withStr, FromYAML(..)) import Data.YAML (withStr, FromYAML(..))
import Data.Aeson import Data.Aeson
import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty', import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
keyOrder) keyOrder)
import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy as BL
import Data.Data (Data, toConstr) import Data.Data (Data, toConstr)
import qualified Data.Text as Text import qualified Data.Text as Text
import Data.Text (Text)
import Data.Typeable (Typeable) import Data.Typeable (Typeable)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Text.Pandoc.Definition import Text.Pandoc.Definition
import Text.Parsec.Pos import Text.Parsec.Pos
-- | Verbosity level. -- | Verbosity level.
data Verbosity = ERROR | WARNING | INFO data Verbosity = ERROR | WARNING | INFO
deriving (Show, Read, Eq, Data, Enum, Ord, Bounded, Typeable, Generic) deriving (Show, Read, Eq, Data, Enum, Ord, Bounded, Typeable, Generic)
instance ToJSON Verbosity where instance ToJSON Verbosity where
skipping to change at line 62 skipping to change at line 63
parseJSON _ = mzero parseJSON _ = mzero
instance FromYAML Verbosity where instance FromYAML Verbosity where
parseYAML = withStr "Verbosity" $ \case parseYAML = withStr "Verbosity" $ \case
"ERROR" -> return ERROR "ERROR" -> return ERROR
"WARNING" -> return WARNING "WARNING" -> return WARNING
"INFO" -> return INFO "INFO" -> return INFO
_ -> mzero _ -> mzero
data LogMessage = data LogMessage =
SkippedContent Text.Text SourcePos SkippedContent Text SourcePos
| IgnoredElement Text.Text | IgnoredElement Text
| DuplicateLinkReference Text.Text SourcePos | DuplicateLinkReference Text SourcePos
| DuplicateNoteReference Text.Text SourcePos | DuplicateNoteReference Text SourcePos
| NoteDefinedButNotUsed Text.Text SourcePos | NoteDefinedButNotUsed Text SourcePos
| DuplicateIdentifier Text.Text SourcePos | DuplicateIdentifier Text SourcePos
| ReferenceNotFound Text.Text SourcePos | ReferenceNotFound Text SourcePos
| CircularReference Text.Text SourcePos | CircularReference Text SourcePos
| UndefinedToggle Text.Text SourcePos | UndefinedToggle Text SourcePos
| ParsingUnescaped Text.Text SourcePos | ParsingUnescaped Text SourcePos
| CouldNotLoadIncludeFile Text.Text SourcePos | CouldNotLoadIncludeFile Text SourcePos
| MacroAlreadyDefined Text.Text SourcePos | MacroAlreadyDefined Text SourcePos
| InlineNotRendered Inline | InlineNotRendered Inline
| BlockNotRendered Block | BlockNotRendered Block
| DocxParserWarning Text.Text | DocxParserWarning Text
| IgnoredIOError Text.Text | IgnoredIOError Text
| CouldNotFetchResource Text.Text Text.Text | CouldNotFetchResource Text Text
| CouldNotDetermineImageSize Text.Text Text.Text | CouldNotDetermineImageSize Text Text
| CouldNotConvertImage Text.Text Text.Text | CouldNotConvertImage Text Text
| CouldNotDetermineMimeType Text.Text | CouldNotDetermineMimeType Text
| CouldNotConvertTeXMath Text.Text Text.Text | CouldNotConvertTeXMath Text Text
| CouldNotParseCSS Text.Text | CouldNotParseCSS Text
| Fetching Text.Text | Fetching Text
| Extracting Text.Text | Extracting Text
| NoTitleElement Text.Text | NoTitleElement Text
| NoLangSpecified | NoLangSpecified
| InvalidLang Text.Text | InvalidLang Text
| CouldNotHighlight Text.Text | CouldNotHighlight Text
| MissingCharacter Text.Text | MissingCharacter Text
| Deprecated Text.Text Text.Text | Deprecated Text Text
| NoTranslation Text.Text | NoTranslation Text
| CouldNotLoadTranslations Text.Text Text.Text | CouldNotLoadTranslations Text Text
| UnusualConversion Text.Text | UnusualConversion Text
| UnexpectedXmlElement Text.Text Text.Text | UnexpectedXmlElement Text Text
| UnknownOrgExportOption Text.Text | UnknownOrgExportOption Text
| CouldNotDeduceFormat [Text.Text] Text.Text | CouldNotDeduceFormat [Text] Text
| RunningFilter FilePath | RunningFilter FilePath
| FilterCompleted FilePath Integer | FilterCompleted FilePath Integer
| CiteprocWarning Text.Text | CiteprocWarning Text
| ATXHeadingInLHS Int Text
deriving (Show, Eq, Data, Ord, Typeable, Generic) deriving (Show, Eq, Data, Ord, Typeable, Generic)
instance ToJSON LogMessage where instance ToJSON LogMessage where
toJSON x = object $ toJSON x = object $
"verbosity" .= toJSON (messageVerbosity x) : "verbosity" .= toJSON (messageVerbosity x) :
"type" .= toJSON (show $ toConstr x) : "type" .= toJSON (show $ toConstr x) :
case x of case x of
SkippedContent s pos -> SkippedContent s pos ->
["contents" .= s, ["contents" .= s,
"source" .= sourceName pos, "source" .= sourceName pos,
skipping to change at line 227 skipping to change at line 229
CouldNotDeduceFormat exts format -> CouldNotDeduceFormat exts format ->
["extensions" .= exts ["extensions" .= exts
,"format" .= format] ,"format" .= format]
RunningFilter fp -> RunningFilter fp ->
["path" .= Text.pack fp ] ["path" .= Text.pack fp ]
FilterCompleted fp ms -> FilterCompleted fp ms ->
["path" .= Text.pack fp ["path" .= Text.pack fp
,"milliseconds" .= Text.pack (show ms) ] ,"milliseconds" .= Text.pack (show ms) ]
CiteprocWarning msg -> CiteprocWarning msg ->
["message" .= msg] ["message" .= msg]
ATXHeadingInLHS lvl contents ->
["level" .= lvl
,"contents" .= contents]
showPos :: SourcePos -> Text.Text showPos :: SourcePos -> Text
showPos pos = Text.pack $ sn ++ "line " ++ showPos pos = Text.pack $ sn ++ "line " ++
show (sourceLine pos) ++ " column " ++ show (sourceColumn pos) show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)
where sn = if sourceName pos == "source" || sourceName pos == "" where sn = if sourceName pos == "source" || sourceName pos == ""
then "" then ""
else sourceName pos ++ " " else sourceName pos ++ " "
encodeLogMessages :: [LogMessage] -> BL.ByteString encodeLogMessages :: [LogMessage] -> BL.ByteString
encodeLogMessages ms = encodeLogMessages ms =
encodePretty' defConfig{ confCompare = encodePretty' defConfig{ confCompare =
keyOrder [ "type", "verbosity", "contents", "message", "path", keyOrder [ "type", "verbosity", "contents", "message", "path",
"source", "line", "column" ] } ms "source", "line", "column" ] } ms
showLogMessage :: LogMessage -> Text.Text showLogMessage :: LogMessage -> Text
showLogMessage msg = showLogMessage msg =
case msg of case msg of
SkippedContent s pos -> SkippedContent s pos ->
"Skipped '" <> s <> "' at " <> showPos pos "Skipped '" <> s <> "' at " <> showPos pos
IgnoredElement s -> IgnoredElement s ->
"Ignored element " <> s "Ignored element " <> s
DuplicateLinkReference s pos -> DuplicateLinkReference s pos ->
"Duplicate link reference '" <> s <> "' at " <> showPos pos "Duplicate link reference '" <> s <> "' at " <> showPos pos
DuplicateNoteReference s pos -> DuplicateNoteReference s pos ->
"Duplicate note reference '" <> s <> "' at " <> showPos pos "Duplicate note reference '" <> s <> "' at " <> showPos pos
skipping to change at line 336 skipping to change at line 341
UnknownOrgExportOption option -> UnknownOrgExportOption option ->
"Ignoring unknown Org export option: " <> option "Ignoring unknown Org export option: " <> option
CouldNotDeduceFormat exts format -> CouldNotDeduceFormat exts format ->
"Could not deduce format from file extension " <> "Could not deduce format from file extension " <>
Text.intercalate " or " exts <> "\n" <> Text.intercalate " or " exts <> "\n" <>
"Defaulting to " <> format "Defaulting to " <> format
RunningFilter fp -> "Running filter " <> Text.pack fp RunningFilter fp -> "Running filter " <> Text.pack fp
FilterCompleted fp ms -> "Completed filter " <> Text.pack fp <> FilterCompleted fp ms -> "Completed filter " <> Text.pack fp <>
" in " <> Text.pack (show ms) <> " ms" " in " <> Text.pack (show ms) <> " ms"
CiteprocWarning ms -> "Citeproc: " <> ms CiteprocWarning ms -> "Citeproc: " <> ms
ATXHeadingInLHS lvl contents ->
"Rendering heading '" <> contents <> "' as a paragraph.\n" <>
"ATX headings cannot be used in literate Haskell, because " <>
"'#' is not\nallowed in column 1." <>
if lvl < 3
then " Consider using --markdown-headings=setext."
else ""
messageVerbosity :: LogMessage -> Verbosity messageVerbosity :: LogMessage -> Verbosity
messageVerbosity msg = messageVerbosity msg =
case msg of case msg of
SkippedContent{} -> INFO SkippedContent{} -> INFO
IgnoredElement{} -> INFO IgnoredElement{} -> INFO
DuplicateLinkReference{} -> WARNING DuplicateLinkReference{} -> WARNING
DuplicateNoteReference{} -> WARNING DuplicateNoteReference{} -> WARNING
NoteDefinedButNotUsed{} -> WARNING NoteDefinedButNotUsed{} -> WARNING
DuplicateIdentifier{} -> WARNING DuplicateIdentifier{} -> WARNING
skipping to change at line 381 skipping to change at line 393
Deprecated{} -> WARNING Deprecated{} -> WARNING
NoTranslation{} -> WARNING NoTranslation{} -> WARNING
CouldNotLoadTranslations{} -> WARNING CouldNotLoadTranslations{} -> WARNING
UnusualConversion {} -> WARNING UnusualConversion {} -> WARNING
UnexpectedXmlElement {} -> WARNING UnexpectedXmlElement {} -> WARNING
UnknownOrgExportOption {} -> WARNING UnknownOrgExportOption {} -> WARNING
CouldNotDeduceFormat{} -> WARNING CouldNotDeduceFormat{} -> WARNING
RunningFilter{} -> INFO RunningFilter{} -> INFO
FilterCompleted{} -> INFO FilterCompleted{} -> INFO
CiteprocWarning{} -> WARNING CiteprocWarning{} -> WARNING
ATXHeadingInLHS{} -> WARNING
 End of changes. 10 change blocks. 
36 lines changed or deleted 48 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)