git.iko.soy/typeable/pandoc
on master help sign in
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.

commitb948ca6db2a02b73aae1f77535cc592fc7b80974 authorJesse Rosenthal <jrosenthal@jhu.edu> dateTue 17 Apr 2018, 09:08 (9 years ago) parent3443df6
1 file changed+4
src/Text/Pandoc/Readers/Docx/Combine.hs+4
src/Text/Pandoc/Readers/Docx/Combine.hs+4
@@ -135,6 +135,10 @@ combineBlocks bs cs
135135 | bs' :> BlockQuote bs'' <- viewr (unMany bs)
136136 , BlockQuote cs'' :< cs' <- viewl (unMany cs) =
137137 Many $ (bs' |> BlockQuote (bs'' <> cs'')) >< cs'
138+ | bs' :> CodeBlock attr codeStr <- viewr (unMany bs)
139+ , CodeBlock attr' codeStr' :< cs' <- viewl (unMany cs)
140+ , attr == attr' =
141+ Many $ (bs' |> CodeBlock attr (codeStr <> "\n" <> codeStr')) >< cs'
138142combineBlocks bs cs = bs <> cs
139143
140144instance (Monoid a, Eq a) => Eq (Modifier a) where