From 01a21dd43fe170ba215b83179f6e10d51e77f3f5 Mon Sep 17 00:00:00 2001 From: hubertp-lshift Date: Tue, 1 Nov 2016 10:07:39 +0100 Subject: [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. --- src/Text/Pandoc/Readers/Odt/ContentReader.hs | 11 +++++++++-- tests/odt/native/simpleTable.native | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/Odt/ContentReader.hs b/src/Text/Pandoc/Readers/Odt/ContentReader.hs index 42f018157..8093cc779 100644 --- a/src/Text/Pandoc/Readers/Odt/ContentReader.hs +++ b/src/Text/Pandoc/Readers/Odt/ContentReader.hs @@ -695,7 +695,7 @@ read_citation = matchingElement NsText "bibliography-mark" ( findAttrWithDefault NsText "identifier" "" ) ( readAttrWithDefault NsText "number" 0 ) ) - ( matchChildContent [] read_plain_text ) + ( matchChildContent [] read_plain_text ) where makeCitation :: String -> Int -> [Citation] makeCitation citeId num = [Citation citeId [] [] NormalCitation num 0] @@ -708,10 +708,17 @@ read_citation = matchingElement NsText "bibliography-mark" -- read_table :: BlockMatcher read_table = matchingElement NsTable "table" - $ liftA (simpleTable []) + $ liftA simpleTable' $ matchChildContent' [ read_table_row ] +-- | A simple table without a caption or headers +-- | Infers the number of headers from rows +simpleTable' :: [[Blocks]] -> Blocks +simpleTable' [] = simpleTable [] [] +simpleTable' (x : rest) = simpleTable (fmap (const defaults) x) (x : rest) + where defaults = fromList [] + -- read_table_row :: ElementMatcher [[Blocks]] read_table_row = matchingElement NsTable "table-row" diff --git a/tests/odt/native/simpleTable.native b/tests/odt/native/simpleTable.native index f94026bd5..0a9b380a5 100644 --- a/tests/odt/native/simpleTable.native +++ b/tests/odt/native/simpleTable.native @@ -1 +1 @@ -[Table [] [] [] [] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []] \ No newline at end of file +[Table [] [AlignDefault,AlignDefault] [0.0,0.0] [[],[]] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []] -- cgit v1.2.3