Muse writer: join strings during inline normalization

This commit is contained in:
Alexander Krotov 2018-03-02 01:39:16 +03:00
parent 177c5120a5
commit 9dbd59a7c1
2 changed files with 3 additions and 0 deletions

View file

@ -294,6 +294,8 @@ conditionalEscapeString s =
normalizeInlineList :: [Inline] -> [Inline]
normalizeInlineList (x : Str "" : xs)
= normalizeInlineList (x:xs)
normalizeInlineList (Str x1 : Str x2 : xs)
= normalizeInlineList $ Str (x1 ++ x2) : xs
normalizeInlineList (Emph x1 : Emph x2 : ils)
= normalizeInlineList $ Emph (x1 ++ x2) : ils
normalizeInlineList (Strong x1 : Strong x2 : ils)

View file

@ -297,6 +297,7 @@ tests = [ testGroup "block elements"
, "escape hash to avoid accidental anchors" =: text "#foo bar"
=?> "<verbatim>#foo</verbatim> bar"
, "escape definition list markers" =: str "::" =?> "<verbatim>::</verbatim>"
, "normalize strings before escaping" =: fromList [Str ":", Str ":"] =?> "<verbatim>::</verbatim>"
-- We don't want colons to be escaped if they can't be confused
-- with definition list item markers.
, "do not escape colon" =: str ":" =?> ":"