git.iko.soy/typeable/pandoc
on master help sign in
[odt] Infer tables' header props from rows (#3199)

ODT reader simply provided an empty header list which meant that the contents of the whole table, even if not empty, was simply ignored. While we still do not infer headers we at least have to provide default properties of columns.

commit01a21dd43fe170ba215b83179f6e10d51e77f3f5 authorhubertp-lshift <hubertp@lshift.de> dateTue 1 Nov 2016, 10:07 (10 years ago) parente08ffa5
2 files changed+10−3
src/Text/Pandoc/Readers/Odt/ContentReader.hs+9−2 tests/odt/native/simpleTable.native+1−1
src/Text/Pandoc/Readers/Odt/ContentReader.hs+9−2
@@ -695,7 +695,7 @@ read_citation = matchingElement NsText "bibliography-mark"
695695 ( findAttrWithDefault NsText "identifier" "" )
696696 ( readAttrWithDefault NsText "number" 0 )
697697 )
698− ( matchChildContent [] read_plain_text )
698+ ( matchChildContent [] read_plain_text )
699699 where
700700 makeCitation :: String -> Int -> [Citation]
701701 makeCitation citeId num = [Citation citeId [] [] NormalCitation num 0]
@@ -708,10 +708,17 @@ read_citation = matchingElement NsText "bibliography-mark"
708708--
709709read_table :: BlockMatcher
710710read_table = matchingElement NsTable "table"
711− $ liftA (simpleTable [])
711+ $ liftA simpleTable'
712712 $ matchChildContent' [ read_table_row
713713 ]
714714
715+-- | A simple table without a caption or headers
716+-- | Infers the number of headers from rows
717+simpleTable' :: [[Blocks]] -> Blocks
718+simpleTable' [] = simpleTable [] []
719+simpleTable' (x : rest) = simpleTable (fmap (const defaults) x) (x : rest)
720+ where defaults = fromList []
721+
715722--
716723read_table_row :: ElementMatcher [[Blocks]]
717724read_table_row = matchingElement NsTable "table-row"
tests/odt/native/simpleTable.native+1−1
@@ -1 +1 @@
1−[Table [] [] [] [] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []]
1+[Table [] [AlignDefault,AlignDefault] [0.0,0.0] [[],[]] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []]