diff options
| author | Tuong Nguyen Manh <tuongnm88@gmail.com> | 2022-01-02 11:28:38 +0100 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-01-02 15:05:09 -0800 |
| commit | 32297d56772e97ce39f54f6879ae2f69f3c4c6dd (patch) | |
| tree | f9d20aa3b8b9baf4b8bed2d1ff4dca948bab5c49 | |
| parent | 808bcb5d3b87825b1f67ca8b2cad76e1952a503d (diff) | |
Odt: Add list-header
The list-header is a type of list-item.
Therefore, it will be treated exactly like one.
| -rw-r--r-- | src/Text/Pandoc/Readers/Odt/ContentReader.hs | 21 | ||||
| -rw-r--r-- | test/Tests/Readers/Odt.hs | 2 | ||||
| -rw-r--r-- | test/odt/native/orderedListHeader.native | 80 | ||||
| -rw-r--r-- | test/odt/native/unorderedListHeader.native | 50 | ||||
| -rw-r--r-- | test/odt/odt/orderedListHeader.odt | bin | 0 -> 11565 bytes | |||
| -rw-r--r-- | test/odt/odt/unorderedListHeader.odt | bin | 0 -> 9920 bytes |
6 files changed, 146 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Odt/ContentReader.hs b/src/Text/Pandoc/Readers/Odt/ContentReader.hs index 5520d039f..998999d25 100644 --- a/src/Text/Pandoc/Readers/Odt/ContentReader.hs +++ b/src/Text/Pandoc/Readers/Odt/ContentReader.hs @@ -661,16 +661,23 @@ read_list = matchingElement NsText "list" $ constructList -- $ liftA bulletList $ matchChildContent' [ read_list_item + , read_list_header ] -- read_list_item :: ElementMatcher [Blocks] -read_list_item = matchingElement NsText "list-item" - $ liftA (compactify.(:[])) - ( matchChildContent' [ read_paragraph - , read_header - , read_list - ] - ) +read_list_item = read_list_element "list-item" + +read_list_header :: ElementMatcher [Blocks] +read_list_header = read_list_element "list-header" + +read_list_element :: ElementName -> ElementMatcher [Blocks] +read_list_element listElement = matchingElement NsText listElement + $ liftA (compactify.(:[])) + ( matchChildContent' [ read_paragraph + , read_header + , read_list + ] + ) ---------------------- diff --git a/test/Tests/Readers/Odt.hs b/test/Tests/Readers/Odt.hs index f731dacdc..8dcd7b29b 100644 --- a/test/Tests/Readers/Odt.hs +++ b/test/Tests/Readers/Odt.hs @@ -171,6 +171,7 @@ namesOfTestsComparingToNative = [ "blockquote" , "orderedListMixed" , "orderedListRoman" , "orderedListSimple" + , "orderedListHeader" , "referenceToChapter" , "referenceToListItem" , "referenceToText" @@ -182,4 +183,5 @@ namesOfTestsComparingToNative = [ "blockquote" , "tableWithContents" , "unicode" , "unorderedList" + , "unorderedListHeader" ] diff --git a/test/odt/native/orderedListHeader.native b/test/odt/native/orderedListHeader.native new file mode 100644 index 000000000..926eb5957 --- /dev/null +++ b/test/odt/native/orderedListHeader.native @@ -0,0 +1,80 @@ +[ OrderedList + ( 1 , Decimal , Period ) + [ [ Plain + [ Str "A" + , Space + , Str "list" + , Space + , Str "item" + , Space + , Str "(list-header)" + ] + ] + , [ Plain [ Str "A" , Space , Str "second" ] ] + , [ Para [ Str "A" , Space , Str "third" ] + , OrderedList + ( 1 , Decimal , Period ) + [ [ Para + [ Str "New" + , Space + , Str "level!" + , Space + , Str "(list-header)" + ] + , OrderedList + ( 1 , Decimal , Period ) + [ [ Plain + [ Str "And" + , Space + , Str "another!" + , Space + , Str "(list-header)" + ] + ] + , [ Plain + [ Str "It's" + , Space + , Str "great" + , Space + , Str "up" + , Space + , Str "here!" + ] + ] + ] + ] + , [ Plain [ Str "Oh" , Space , Str "noes" ] ] + , [ Plain [ Str "We" , Space , Str "fell!" ] ] + ] + ] + , [ Plain [ Str "Maybe" , Space , Str "someone" ] ] + , [ Plain [ Str "Pushed" , Space , Str "us?" ] ] + ] +, Para [] +, OrderedList + ( 4 , Decimal , Period ) + [ [ Plain + [ Str "Start" + , Space + , Str "new" + , Space + , Str "list," + , Space + , Str "but" + , Space + , Str "a" + , Space + , Str "different" + , Space + , Str "starting" + , Space + , Str "point." + , Space + , Str "(list-header)" + ] + ] + , [ Plain + [ Str "Because" , Space , Str "we" , Space , Str "can." ] + ] + ] +] diff --git a/test/odt/native/unorderedListHeader.native b/test/odt/native/unorderedListHeader.native new file mode 100644 index 000000000..05db5838b --- /dev/null +++ b/test/odt/native/unorderedListHeader.native @@ -0,0 +1,50 @@ +[ BulletList + [ [ Plain + [ Str "A" + , Space + , Str "list" + , Space + , Str "item" + , Space + , Str "(list-header)" + ] + ] + , [ Plain [ Str "A" , Space , Str "second" ] ] + , [ Para [ Str "A" , Space , Str "third" ] + , BulletList + [ [ Para + [ Str "New" + , Space + , Str "level!" + , Space + , Str "(list-header)" + ] + , BulletList + [ [ Plain + [ Str "And" + , Space + , Str "another!" + , Space + , Str "(list-header)" + ] + ] + , [ Plain + [ Str "It's" + , Space + , Str "great" + , Space + , Str "up" + , Space + , Str "here!" + ] + ] + ] + ] + , [ Plain [ Str "Oh" , Space , Str "noes" ] ] + , [ Plain [ Str "We" , Space , Str "fell!" ] ] + ] + ] + , [ Plain [ Str "Maybe" , Space , Str "someone" ] ] + , [ Plain [ Str "Pushed" , Space , Str "us?" ] ] + ] +] diff --git a/test/odt/odt/orderedListHeader.odt b/test/odt/odt/orderedListHeader.odt Binary files differnew file mode 100644 index 000000000..e99a898c8 --- /dev/null +++ b/test/odt/odt/orderedListHeader.odt diff --git a/test/odt/odt/unorderedListHeader.odt b/test/odt/odt/unorderedListHeader.odt Binary files differnew file mode 100644 index 000000000..3f5980ef7 --- /dev/null +++ b/test/odt/odt/unorderedListHeader.odt |
