git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: Start adding comment to combine module

This module is one of the most opaque parts of the docx reader: it deals with the fact that runs have non-nesting formatting, so we have to figure out the nesting on the fly as we combine them. We start adding commenting, so new developers can understand and, if necessary, modify this module. Specific function comments will be added in the future, but this offers a global description of the purpose of the module.

commit69d433d37a2b50b2d07f588603a6fbc03041c0af authorJesse Rosenthal <jrosenthal@jhu.edu> dateThu 21 Feb 2019, 08:32 (8 years ago) parentba065cb
1 file changed+40
src/Text/Pandoc/Readers/Docx/Combine.hs+40
src/Text/Pandoc/Readers/Docx/Combine.hs+40
@@ -14,6 +14,46 @@
1414
1515Flatten sequences of elements.
1616-}
17+
18+{-
19+The purpose of this module is to combine the formatting of separate
20+runs, which have *non-nesting* formatting. Because the formatting
21+doesn't nest, you can't actually tell the nesting order until you
22+combine with the runs that follow.
23+
24+For example, say you have a something like `<em><strong>foo</strong>
25+bar</em>`. Then in ooxml, you'll get these two runs:
26+
27+~~~
28+<w:r>
29+ <w:rPr>
30+ <w:b />
31+ <w:i />
32+ </w:rPr>
33+ <w:t>Foo</w:t>
34+</w:r>
35+<w:r>
36+ <w:rPr>
37+ <w:i />
38+ </w:rPr>
39+ <w:t> Bar</w:t>
40+</w:r>
41+~~~
42+
43+Note that this is an ideal situation. In practice, it will probably be
44+more---if, for example, the user turned italics
45+off and then on.
46+
47+So, when you get the first run, which is marked as both bold and italic,
48+you have no idea whether it's `Strong [Emph [Str "Foo"]]` or `Emph
49+[Strong [Str "Foo"]]`.
50+
51+We combine two runs, then, by taking off the formatting that modifies an
52+inline, seeing what is shared between them, and rebuilding an inline. We
53+fold this to combine the inlines.
54+
55+-}
56+
1757module Text.Pandoc.Readers.Docx.Combine ( smushInlines
1858 , smushBlocks
1959 )