Enable citations
extension for docx reader.
When enabled, Zotero citations are parsed as native pandoc citations. (When disabled, the Zotero-generated citation text is passed through as regular text.) In addition, the Zotero-generated bibliography is suppressed. Locators still need some work.
This commit is contained in:
parent
04d365623b
commit
1c2f0fe1d2
3 changed files with 34 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue