Skip to content

Commit 886e796

Browse files
author
Alexander Krotov
committed
ODT reader: parse endnotes
Converted ODT tests for notes from markdown to native, because markdown does not differentiate between foot- and end-notes.
1 parent f2624fd commit 886e796

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/Text/Pandoc/Readers/Odt/ContentReader.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,12 @@ read_link = matchingElement NsText "a"
694694

695695
read_note :: InlineMatcher
696696
read_note = matchingElement NsText "note"
697-
$ liftA note
698-
$ matchChildContent' [ read_note_body ]
697+
$ liftA2 (\nt -> singleton . Note nt . toList)
698+
(liftA makeNoteType (findAttrWithDefault NsText "note-class" "footnote"))
699+
(matchChildContent' [ read_note_body ])
700+
where
701+
makeNoteType :: String -> NoteType
702+
makeNoteType x = if x == "endnote" then EndNote else FootNote
699703

700704
read_note_body :: BlockMatcher
701705
read_note_body = matchingElement NsText "note-body"

test/Tests/Readers/Odt.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ testMediaBag name odtFile = buildTest $ testMediaBagIO name odtFile
135135
namesOfTestsComparingToMarkdown :: [ String ]
136136
namesOfTestsComparingToMarkdown = [ "bold"
137137
-- , "citation"
138-
, "endnote"
139138
, "externalLink"
140-
, "footnote"
141139
, "headers"
142140
-- , "horizontalRule"
143141
, "italic"
@@ -150,6 +148,8 @@ namesOfTestsComparingToMarkdown = [ "bold"
150148

151149
namesOfTestsComparingToNative :: [ String ]
152150
namesOfTestsComparingToNative = [ "blockquote"
151+
, "endnote"
152+
, "footnote"
153153
, "image"
154154
, "imageIndex"
155155
, "imageWithCaption"

test/odt/markdown/endnote.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/odt/markdown/footnote.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/odt/native/endnote.native

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Para [Str "Some",Space,Str "text",Note EndNote [Para [Str "Endnote",Space,Str "text"]],Space,Str "with",Space,Str "an",Space,Str "endnote."]]

test/odt/native/footnote.native

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Para [Str "Some",Space,Str "text",Note FootNote [Para [Str "Footnote",Space,Str "text"]],Space,Str "with",Space,Str "a",Space,Str "footnote."]]

0 commit comments

Comments
 (0)