@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717-}
1818
1919{- |
20− Module : Text.Pandoc.Readers.DocX
20+ Module : Text.Pandoc.Readers.Docx
2121 Copyright : Copyright (C) 2014 Jesse Rosenthal
2222 License : GNU GPL, version 2 or above
2323
@@ -25,11 +25,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2525 Stability : alpha
2626 Portability : portable
2727
28−Conversion of DocX type (defined in Text.Pandoc.Readers.DocX.Parse)
28+Conversion of Docx type (defined in Text.Pandoc.Readers.Docx.Parse)
2929to 'Pandoc' document. -}
3030
3131{-
32−Current state of implementation of DocX entities ([x] means
32+Current state of implementation of Docx entities ([x] means
3333implemented, [-] means partially implemented):
3434
3535* Blocks
@@ -68,8 +68,8 @@ implemented, [-] means partially implemented):
6868 - [X] Note (Footnotes and Endnotes are silently combined.)
6969-}
7070
71−module Text.Pandoc.Readers.DocX
72− ( readDocX
71+module Text.Pandoc.Readers.Docx
72+ ( readDocx
7373 ) where
7474
7575import Codec.Archive.Zip
@@ -79,8 +79,8 @@ import Text.Pandoc.Builder (text, toList)
7979import Text.Pandoc.Generic (bottomUp)
8080import Text.Pandoc.MIME (getMimeType)
8181import Text.Pandoc.UTF8 (toString)
82−import Text.Pandoc.Readers.DocX.Parse
83−import Text.Pandoc.Readers.DocX.Lists
82+import Text.Pandoc.Readers.Docx.Parse
83+import Text.Pandoc.Readers.Docx.Lists
8484import Data.Maybe (mapMaybe, isJust, fromJust)
8585import Data.List (delete, isPrefixOf, (\\), intersect)
8686import qualified Data.ByteString as BS
@@ -88,11 +88,11 @@ import qualified Data.ByteString.Lazy as B
8888import Data.ByteString.Base64 (encode)
8989import System.FilePath (combine)
9090
91−readDocX :: ReaderOptions
91+readDocx :: ReaderOptions
9292 -> B.ByteString
9393 -> Pandoc
94−readDocX opts bytes =
95− case archiveToDocX (toArchive bytes) of
94+readDocx opts bytes =
95+ case archiveToDocx (toArchive bytes) of
9696 Just docx -> Pandoc nullMeta (docxToBlocks opts docx)
9797 Nothing -> error $ "couldn't parse docx file"
9898
@@ -148,8 +148,8 @@ strNormalize (Str "" : ils) = strNormalize ils
148148strNormalize ((Str s) : (Str s') : l) = strNormalize ((Str (s++s')) : l)
149149strNormalize (il:ils) = il : (strNormalize ils)
150150
151−runToInlines :: ReaderOptions -> DocX -> Run -> [Inline]
152−runToInlines _ _ (Run rs runElems)
151+runToInlines :: ReaderOptions -> Docx -> Run -> [Inline]
152+runToInlines _ _ (Run rs runElems)
153153 | isJust (rStyle rs) && (fromJust (rStyle rs)) `elem` codeSpans =
154154 case runStyleToSpanAttr rs == ("", [], []) of
155155 True -> [Str (runElemsToString runElems)]
@@ -157,30 +157,30 @@ runToInlines _ _ (Run rs runElems)
157157 | otherwise = case runStyleToSpanAttr rs == ("", [], []) of
158158 True -> concatMap runElemToInlines runElems
159159 False -> [Span (runStyleToSpanAttr rs) (concatMap runElemToInlines runElems)]
160−runToInlines opts docx@(DocX _ notes _ _ _ ) (Footnote fnId) =
160+runToInlines opts docx@(Docx _ notes _ _ _ ) (Footnote fnId) =
161161 case (getFootNote fnId notes) of
162162 Just bodyParts ->
163163 [Note [Div ("", ["footnote"], []) (map (bodyPartToBlock opts docx) bodyParts)]]
164164 Nothing ->
165165 [Note [Div ("", ["footnote"], []) []]]
166−runToInlines opts docx@(DocX _ notes _ _ _) (Endnote fnId) =
166+runToInlines opts docx@(Docx _ notes _ _ _) (Endnote fnId) =
167167 case (getEndNote fnId notes) of
168168 Just bodyParts ->
169169 [Note [Div ("", ["endnote"], []) (map (bodyPartToBlock opts docx) bodyParts)]]
170170 Nothing ->
171171 [Note [Div ("", ["endnote"], []) []]]
172172
173−parPartToInlines :: ReaderOptions -> DocX -> ParPart -> [Inline]
173+parPartToInlines :: ReaderOptions -> Docx -> ParPart -> [Inline]
174174parPartToInlines opts docx (PlainRun r) = runToInlines opts docx r
175175parPartToInlines _ _ (BookMark _ anchor) =
176176 [Span (anchor, ["anchor"], []) []]
177−parPartToInlines _ (DocX _ _ _ rels _) (Drawing relid) =
177+parPartToInlines _ (Docx _ _ _ rels _) (Drawing relid) =
178178 case lookupRelationship relid rels of
179179 Just target -> [Image [] (combine "word" target, "")]
180180 Nothing -> [Image [] ("", "")]
181181parPartToInlines opts docx (InternalHyperLink anchor runs) =
182182 [Link (concatMap (runToInlines opts docx) runs) ('#' : anchor, "")]
183−parPartToInlines opts docx@(DocX _ _ _ rels _) (ExternalHyperLink relid runs) =
183+parPartToInlines opts docx@(Docx _ _ _ rels _) (ExternalHyperLink relid runs) =
184184 case lookupRelationship relid rels of
185185 Just target ->
186186 [Link (concatMap (runToInlines opts docx) runs) (target, "")]
@@ -208,9 +208,9 @@ makeHeaderAnchors h@(Header n (_, classes, kvs) ils) =
208208 False -> Header n (ident, classes, kvs) (ils \\ (x:xs))
209209 _ -> h
210210makeHeaderAnchors blk = blk
211−
212211
213−parPartsToInlines :: ReaderOptions -> DocX -> [ParPart] -> [Inline]
212+
213+parPartsToInlines :: ReaderOptions -> Docx -> [ParPart] -> [Inline]
214214parPartsToInlines opts docx parparts =
215215 --
216216 -- We're going to skip data-uri's for now. It should be an option,
@@ -222,16 +222,16 @@ parPartsToInlines opts docx parparts =
222222 bottomUp spanReduce $
223223 concatMap (parPartToInlines opts docx) parparts
224224
225−cellToBlocks :: ReaderOptions -> DocX -> Cell -> [Block]
225+cellToBlocks :: ReaderOptions -> Docx -> Cell -> [Block]
226226cellToBlocks opts docx (Cell bps) = map (bodyPartToBlock opts docx) bps
227227
228−rowToBlocksList :: ReaderOptions -> DocX -> Row -> [[Block]]
228+rowToBlocksList :: ReaderOptions -> Docx -> Row -> [[Block]]
229229rowToBlocksList opts docx (Row cells) = map (cellToBlocks opts docx) cells
230230
231−bodyPartToBlock :: ReaderOptions -> DocX -> BodyPart -> Block
231+bodyPartToBlock :: ReaderOptions -> Docx -> BodyPart -> Block
232232bodyPartToBlock opts docx (Paragraph pPr parparts) =
233233 Div (parStyleToDivAttr pPr) [Para (parPartsToInlines opts docx parparts)]
234−bodyPartToBlock opts docx@(DocX _ _ numbering _ _) (ListItem pPr numId lvl parparts) =
234+bodyPartToBlock opts docx@(Docx _ _ numbering _ _) (ListItem pPr numId lvl parparts) =
235235 let
236236 kvs = case lookupLevel numId lvl numbering of
237237 Just (_, fmt, txt, Just start) -> [ ("level", lvl)
@@ -240,7 +240,7 @@ bodyPartToBlock opts docx@(DocX _ _ numbering _ _) (ListItem pPr numId lvl parpa
240240 , ("text", txt)
241241 , ("start", (show start))
242242 ]
243−
243+
244244 Just (_, fmt, txt, Nothing) -> [ ("level", lvl)
245245 , ("num-id", numId)
246246 , ("format", fmt)
@@ -262,7 +262,7 @@ bodyPartToBlock opts docx (Tbl cap _ look (r:rs)) =
262262 Just r' -> rowToBlocksList opts docx r'
263263 Nothing -> []
264264 cells = map (rowToBlocksList opts docx) rows
265−
265+
266266 size = case null hdrCells of
267267 True -> length $ head cells
268268 False -> length $ hdrCells
@@ -277,8 +277,8 @@ bodyPartToBlock opts docx (Tbl cap _ look (r:rs)) =
277277 in
278278 Table caption alignments widths hdrCells cells
279279
280−makeImagesSelfContained :: DocX -> Inline -> Inline
281−makeImagesSelfContained (DocX _ _ _ _ media) i@(Image alt (uri, title)) =
280+makeImagesSelfContained :: Docx -> Inline -> Inline
281+makeImagesSelfContained (Docx _ _ _ _ media) i@(Image alt (uri, title)) =
282282 case lookup uri media of
283283 Just bs -> case getMimeType uri of
284284 Just mime -> let data_uri =
@@ -289,11 +289,11 @@ makeImagesSelfContained (DocX _ _ _ _ media) i@(Image alt (uri, title)) =
289289 Nothing -> i
290290makeImagesSelfContained _ inline = inline
291291
292−bodyToBlocks :: ReaderOptions -> DocX -> Body -> [Block]
292+bodyToBlocks :: ReaderOptions -> Docx -> Body -> [Block]
293293bodyToBlocks opts docx (Body bps) =
294294 bottomUp removeEmptyPars $
295− bottomUp strNormalize $
296− bottomUp spanRemove $
295+ bottomUp strNormalize $
296+ bottomUp spanRemove $
297297 bottomUp divRemove $
298298 map (makeHeaderAnchors) $
299299 bottomUp divCorrect $
@@ -303,8 +303,8 @@ bodyToBlocks opts docx (Body bps) =
303303 blocksToBullets $
304304 map (bodyPartToBlock opts docx) bps
305305
306−docxToBlocks :: ReaderOptions -> DocX -> [Block]
307−docxToBlocks opts d@(DocX (Document _ body) _ _ _ _) = bodyToBlocks opts d body
306+docxToBlocks :: ReaderOptions -> Docx -> [Block]
307+docxToBlocks opts d@(Docx (Document _ body) _ _ _ _) = bodyToBlocks opts d body
308308
309309spanReduce :: [Inline] -> [Inline]
310310spanReduce [] = []
@@ -460,7 +460,7 @@ divRemove' blk = [blk]
460460
461461divRemove :: [Block] -> [Block]
462462divRemove = concatMap divRemove'
463−
463+
464464divCorrect' :: Block -> [Block]
465465divCorrect' b@(Div (ident, classes, kvs) blks)
466466 | (not . null) (blockQuoteDivs `intersect` classes) =