diff --git a/MANUAL.txt b/MANUAL.txt index bb8a3364f..ba2335714 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -3472,6 +3472,11 @@ native pandoc citations. [org-cite]: https://orgmode.org/manual/Citations.html [org-ref]: https://github.com/jkitchin/org-ref +When `citations` is enabled in `docx`, Zotero-inserted +citations will be parsed as native pandoc citations. +(Otherwise, the Zotero-generated citation text and +bibliography will be parsed as regular text.) + #### Extension: `fancy_lists` {#org-fancy-lists} Some aspects of [Pandoc's Markdown fancy lists](#extension-fancy_lists) are also diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs index f82ac631b..a6b6739d4 100644 --- a/src/Text/Pandoc/Extensions.hs +++ b/src/Text/Pandoc/Extensions.hs @@ -488,6 +488,7 @@ getAllExtensions f = universalExtensions <> getAll f [ Ext_empty_paragraphs , Ext_native_numbering , Ext_styles + , Ext_citations ] getAll "opendocument" = extensionsFromList [ Ext_empty_paragraphs diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 169f52b31..85539f9a2 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -458,25 +458,34 @@ parPartToInlines' (Field info children) = PagerefField fieldAnchor True -> parPartToInlines' $ InternalHyperLink fieldAnchor children ZoteroItem t -> do formattedCite <- smushInlines <$> mapM parPartToInlines' children - let bs = fromTextLazy $ TL.fromStrict t - case eitherDecode bs of - Left _err -> return formattedCite - Right citation -> do - let toPandocCitation item = - Citation{ citationId = unItemId (citationItemId item) - , citationPrefix = maybe [] (toList . text) $ - citationItemPrefix item - , citationSuffix = (toList . text) $ - maybe mempty (<> " ") - (citationItemLabel item) <> - maybe mempty (<> " ") - (citationItemLocator item) <> - maybe mempty id (citationItemSuffix item) - , citationMode = NormalCitation -- TODO for now - , citationNoteNum = 0 - , citationHash = 0 } - let cs = map toPandocCitation $ citationItems citation - return $ cite cs formattedCite + opts <- asks docxOptions + if isEnabled Ext_citations opts + then do + let bs = fromTextLazy $ TL.fromStrict t + case eitherDecode bs of + Left _err -> return formattedCite + Right citation -> do + let toPandocCitation item = + Citation{ citationId = unItemId (citationItemId item) + , citationPrefix = maybe [] (toList . text) $ + citationItemPrefix item + , citationSuffix = (toList . text) $ + maybe mempty (<> " ") + (citationItemLabel item) <> + maybe mempty (<> " ") + (citationItemLocator item) <> + fromMaybe mempty (citationItemSuffix item) + , citationMode = NormalCitation -- TODO for now + , citationNoteNum = 0 + , citationHash = 0 } + let cs = map toPandocCitation $ citationItems citation + return $ cite cs formattedCite + else return formattedCite + ZoteroBibliography -> do + opts <- asks docxOptions + if isEnabled Ext_citations opts + then return mempty -- omit Zotero-generated bibliography + else smushInlines <$> mapM parPartToInlines' children _ -> smushInlines <$> mapM parPartToInlines' children isAnchorSpan :: Inline -> Bool