diff --git a/internals/xmldoc2txt/xmldoc2txt.hs b/internals/xmldoc2txt/xmldoc2txt.hs index 76679bd..d3fcddb 100644 --- a/internals/xmldoc2txt/xmldoc2txt.hs +++ b/internals/xmldoc2txt/xmldoc2txt.hs @@ -21,6 +21,10 @@ data PotentiallyColorizedString = PCS removeParagraphTags :: [TS.TagTree String] -> [TS.TagTree String] removeParagraphTags (TS.TagLeaf (TS.TagClose "para") : TS.TagLeaf (TS.TagOpen "para" []) : rest) = TS.TagLeaf (TS.TagText "\n") : removeParagraphTags rest + -- In this case, it will be directly followed by a branch +removeParagraphTags (TS.TagLeaf (TS.TagClose "para") : rest) = removeParagraphTags rest + -- In this case, it is directly behind by a branch +removeParagraphTags (TS.TagLeaf (TS.TagOpen "para" _) : rest) = removeParagraphTags rest removeParagraphTags (x : y : rest) = x : removeParagraphTags (y : rest) removeParagraphTags x = x @@ -46,6 +50,11 @@ replaceTagColor (TS.TagLeaf (TS.TagText s)) = { colorized = putStr s, nonColorized = s } +replaceTagColor (TS.TagBranch "para" _ inner) = + PCS + { colorized = mapM_ (colorized . replaceTagColor) inner, + nonColorized = concat $ map (nonColorized . replaceTagColor) inner + } replaceTagColor (TS.TagBranch "code" _ [TS.TagLeaf (TS.TagText content)]) = PCS { colorized = wrapSGR bold $ concat ["`", content, "`"],