-
Notifications
You must be signed in to change notification settings - Fork 5
Support multiple bibliographies per topic (etc.) #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@tarleb (and others), any thoughts on this PR? Thanks. |
What I like about this PR is that reference numbers do not "reset" between bibliographies (see #6). This PR generally works, with a couple caveats:
|
Sorry for the delay in replying. I suspect that both of your caveats can be addressed. I'll take a look. Re your caveat 1 please note that there's already an attempt to address this problem, but it doesn't support ranges. |
Very cool! Could you split this up into separate PRs? Things that I'm definitely in favor of:
I'm a bit skeptical towards others:
|
@tarleb I'll take a look. And @jerome-white apologies for not doing what I said I'd do (perhaps on this upcoming iteration...). |
9c03af7
to
3195dc4
Compare
I've rebased against the latest |
@tarleb with which pandoc versions should we try to make this filter work? I installed
|
The full list of changes is: - Support multiple bibliographies per topic, i.e., in the 'bibliography' metadata, allow topic entries to be list-valued - Support the same topic structure for the 'references' metadata item, so can override references per topic - Ignore duplicate references, i.e. if the same reference exists in multiple topics (the first one encountered is used, but this is not satisfactory because the topic processing order is indeterminate). Note that something had to be done here, because these duplicates would have the same ids and therefore would be ambiguous - Fix an undefined 'orig_bib' bug (that probably caused no problems)
2587b69
to
821125f
Compare
821125f
to
f37ece6
Compare
The initial version is just code that has been removed from pandoc-ext#8.
@tarleb, I've removed everything relating to renumbering and hope that this PR is now acceptable, and can be merged. I've also created PR #18 with a separate
|
@tarleb and everyone, any thoughts on this? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I just added some minor comments.
for _, block in ipairs(blocks) do | ||
local identifier = block.attr.identifier | ||
if not identifiers:includes(identifier) then | ||
local new_block = pandoc.walk_block(block, {Span=_span}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line doesn't do anything, as _span
is nil
? Or does this just serve as a backwards-compatible way to block:clone()
?
local identifiers = List() | ||
|
||
-- ignore duplicate references (the first definition will win) | ||
local function ignore_duplicates(blocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A somewhat shorter implementation could be created when using pandoc.List.filter
, e.g.
local function ignore_duplicates(blocks)
local new_blocks =
blocks:filter(function (blk) return not identifiers:includes(blk.identifier) end)
identifiers:extend(new_blocks:map(function (blk) return blk.identifier end))
return new_blocks
end
Note: I'm creating this PR for discussion. I fully expect that further changes might be necessary before merging it.
The full list of changes is:
Also: