git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1370 from jkr/fix-zero-indent

Docx reader: Ignore zero (or negative) indent

commit5ba47605276cf52aeef06043b47a04ca05bd0339 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 24 Jun 2014, 13:41 (12 years ago) parent98ca2e569743cd
1 file changed+8−5
src/Text/Pandoc/Readers/Docx.hs+8−5
src/Text/Pandoc/Readers/Docx.hs+8−5
@@ -132,7 +132,6 @@ runStyleToContainers rPr =
132132
133133
134134divAttrToContainers :: [String] -> [(String, String)] -> [Container Block]
135−divAttrToContainers [] [] = []
136135divAttrToContainers (c:cs) _ | isJust (isHeaderClass c) =
137136 let n = fromJust (isHeaderClass c)
138137 in
@@ -151,10 +150,14 @@ divAttrToContainers (c:cs) kvs | c `elem` listParagraphDivs =
151150divAttrToContainers (c:cs) kvs | c `elem` blockQuoteDivs =
152151 (Container BlockQuote) : (divAttrToContainers (cs \\ blockQuoteDivs) kvs)
153152divAttrToContainers (_:cs) kvs = divAttrToContainers cs kvs
154−divAttrToContainers [] (kv:kvs) | fst kv == "indent" =
155− (Container BlockQuote) : divAttrToContainers [] kvs
156−divAttrToContainers [] (_:kvs) =
157− divAttrToContainers [] kvs
153+divAttrToContainers [] kvs | isJust (lookup "indent" kvs) =
154+ let kvs' = filter (\(k,_) -> k /= "indent") kvs
155+ in
156+ case fromJust (lookup "indent" kvs) of
157+ "0" -> divAttrToContainers [] kvs'
158+ ('-' : _) -> divAttrToContainers [] kvs'
159+ _ -> (Container BlockQuote) : divAttrToContainers [] kvs'
160+divAttrToContainers _ _ = []
158161
159162
160163parStyleToContainers :: ParagraphStyle -> [Container Block]