Docx reader: Combine codeBlocks

This prevents a multiline codeblock in word from being read as
different paragraphs. This takes place in the Combine module to occur
during the normal combining of divs during conversion.

Note that this specifies that the attributes of the `CodeBlock`s must
be the same. The docx reader creates codeBlocks without attrs, so this
is trivially satisified.
This commit is contained in:
Jesse Rosenthal
2018-04-17 09:29:47 -04:00
parent 3443df6068
commit b948ca6db2
+4
View File
@@ -135,6 +135,10 @@ combineBlocks bs cs
| bs' :> BlockQuote bs'' <- viewr (unMany bs)
, BlockQuote cs'' :< cs' <- viewl (unMany cs) =
Many $ (bs' |> BlockQuote (bs'' <> cs'')) >< cs'
| bs' :> CodeBlock attr codeStr <- viewr (unMany bs)
, CodeBlock attr' codeStr' :< cs' <- viewl (unMany cs)
, attr == attr' =
Many $ (bs' |> CodeBlock attr (codeStr <> "\n" <> codeStr')) >< cs'
combineBlocks bs cs = bs <> cs
instance (Monoid a, Eq a) => Eq (Modifier a) where