diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-02-04 22:20:51 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-02-04 22:20:51 -0800 |
| commit | f48890eff0aa3ca6c12b6e7abbc2b7ec1f4d56a3 (patch) | |
| tree | 987e8a062fcd4c469127be5fc1803ef007ce9f6c | |
| parent | 19cfe6a907351d40ecf316e6f2fc1c3773cbf62d (diff) | |
Support Prefix, Suffix, Pages in endnote ADDINs.
| -rw-r--r-- | src/Text/Pandoc/Readers/EndNote.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/EndNote.hs b/src/Text/Pandoc/Readers/EndNote.hs index 5ced9415c..0ad5a117e 100644 --- a/src/Text/Pandoc/Readers/EndNote.hs +++ b/src/Text/Pandoc/Readers/EndNote.hs @@ -90,19 +90,29 @@ toCitationItem :: Element -> Citeproc.CitationItem Text toCitationItem el = Citeproc.CitationItem{ Citeproc.citationItemId = maybe mempty referenceId mbref - , Citeproc.citationItemLabel = Nothing -- TODO - , Citeproc.citationItemLocator = Nothing -- TODO + , Citeproc.citationItemLabel = Nothing + , Citeproc.citationItemLocator = mbpages , Citeproc.citationItemType = Citeproc.NormalCite - , Citeproc.citationItemPrefix = Nothing -- TODO - , Citeproc.citationItemSuffix = Nothing -- TODO + , Citeproc.citationItemPrefix = mbprefix + , Citeproc.citationItemSuffix = mbsuffix , Citeproc.citationItemData = mbref } where mbref = recordToReference <$> filterChildName (name "record") el + mbprefix = getText <$> filterChildName (name "Prefix") el + mbsuffix = getText <$> filterChildName (name "Suffix") el + mbpages = getText <$> filterChildName (name "Pages") el name :: Text -> (QName -> Bool) name t = (== t) . qName +getText :: Element -> Text +getText el = getText' (Elem el) + where + getText' (Elem el') = mconcat $ map getText' $ elContent el' + getText' (Text cd) = cdData cd + getText' (CRef _) = mempty + recordToReference :: Element -> Reference Text recordToReference e = Reference{ referenceId = ItemId refid, @@ -112,10 +122,6 @@ recordToReference e = where -- get strContent, recursing inside style elements: - getText el = getText' (Elem el) - getText' (Elem el) = mconcat $ map getText' $ elContent el - getText' (Text cd) = cdData cd - getText' (CRef _) = mempty refid = maybe mempty (T.strip . strContent) (filterElementName (name "key") e <|> filterElementName (name "rec-number") e) |
