diff options
| author | John MacFarlane <[email protected]> | 2025-09-06 19:49:58 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-09-06 19:54:00 +0200 |
| commit | 8aa665a33dd07ff7edbb296b8718a1ded4b91b33 (patch) | |
| tree | 00d39a037a4621b8e5365c9e5f7fc8ddbe07b238 /src/Text | |
| parent | 5328d4f9d0a798ac280daec7d01d2d8c9a4b812d (diff) | |
Citeproc: put bibliography in a div with id `.*__refs`
as well as `refs`. Reason: when `--file-scope` is used, a Div
with id `refs` gets a prefix attached, derived from the filename.
The prefix ends in `__`.
Closes #11072.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 199eb9d48..f10761136 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -485,7 +485,10 @@ isYesValue _ = False -- if document contains a Div with id="refs", insert -- references as its contents. Otherwise, insert references --- at the end of the document in a Div with id="refs" +-- at the end of the document in a Div with id="refs" or +-- id=".*__refs" (where .* stands for any string -- this is +-- because --file-scope will add such a prefix based on the filename, +-- see #11072.) insertRefs :: [(Text,Text)] -> [Text] -> [Block] -> Pandoc -> Pandoc insertRefs _ _ [] d = d insertRefs refkvs refclasses refs (Pandoc meta bs) = @@ -510,12 +513,13 @@ insertRefs refkvs refclasses refs (Pandoc meta bs) = refDiv = Div ("refs", refclasses, refkvs) refs addUnNumbered cs = "unnumbered" : [c | c <- cs, c /= "unnumbered"] go :: Block -> State Bool Block - go (Div ("refs",cs,kvs) xs) = do - put True - -- refHeader isn't used if you have an explicit references div - let cs' = nubOrd $ cs ++ refclasses - let kvs' = nubOrd $ kvs ++ refkvs - return $ Div ("refs",cs',kvs') (xs ++ refs) + go (Div (ident,cs,kvs) xs) + | ident == "refs" || "__refs" `T.isSuffixOf` ident = do + put True + -- refHeader isn't used if you have an explicit references div + let cs' = nubOrd $ cs ++ refclasses + let kvs' = nubOrd $ kvs ++ refkvs + return $ Div (ident,cs',kvs') (xs ++ refs) go x = return x refTitle :: Meta -> Maybe [Inline] |
