aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2018-04-17 09:08:28 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2018-04-17 09:29:47 -0400
commitb948ca6db2a02b73aae1f77535cc592fc7b80974 (patch)
tree6457e09954ed08a34812cddf7d7731bd8793452a
parent3443df6068a7a1cc2ec7ece62c2fe948592f1b1b (diff)
downloadpandoc-b948ca6db2a02b73aae1f77535cc592fc7b80974.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Readers/Docx/Combine.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Combine.hs b/src/Text/Pandoc/Readers/Docx/Combine.hs
index dfd2b5666..108c4bbe5 100644
--- a/src/Text/Pandoc/Readers/Docx/Combine.hs
+++ b/src/Text/Pandoc/Readers/Docx/Combine.hs
@@ -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