-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
references variable in templates #771
Comments
Instead of using two variables, I'd probably just use one,
This could be customized if desired, and writers could opt to include a subject heading in the template rather than at the end of the document. |
Of course, using one variable is better. |
This change would not be easy, since currently the bibliography is added in the readers. The types of the reader functions would have to be changed to return a pair |
I just realized that the new metadata changes make it possible to add this feature without further API changes. (Though I'm not positive this is a good way to do it.) One could simply add a new |
The one potential drawback I see is that, in formats that print some representation of all of the metadata (e.g. reST, markdown), you'd get an extra copy of the bibliography in the metadata, which seems undesirable. Perhaps this could be avoided by adding a special case for |
Actually, for non-reused bibliographic databases, wouldn't the ability to specify the bibliography inline with the document be considered a feature? |
Experimented with implementing this, but found some rough edges. (This approach is difficult for epub, OPML, and some other formats.) My work is preserved in the branch issue771, but I think for now I'll stick to the present system. |
@jgm, how about enabling a This is much easier to use for the final user. And I think way more powerful. |
Injecting the bibliography under a header with a special id (say, |
@jgm, excuse me, but I can’t refrain from asking: are header with special titles technically easier to implement than variables in templates? |
Somewhat relevant pandoc-discuss thread: https://groups.google.com/forum/#!topic/pandoc-discuss/HxmpFK-Ydus To answer @ousia, not necessarily, no. But for some particular cases, like epub, template is actually a section template, and not a document template (since epub is basically a collection of html pages). So this becomes a bit more difficult if handled with a template variable -- after all, we don't need references in every section. |
@lierdakil "after all, we don't need references in every section." It might not be the case where pandoc focuses on, but it is common for books to have references after each chapter. In latex chapterbib and biblatex can handle this. |
Let me rephrase this then: we don't need ALL references in every section. And pandoc does have support for biblatex for latex/pdf output. And it's 2015-04-10 11:50 GMT+03:00 Alick Zhao [email protected]:
|
Since we are already using pandoc-citeproc to construct the references, can we just have another filter that deals with this issue, instead of having it as a Pandoc problem? EG:
Now, what would be the best approach? append the references after a header with |
What @sergiocorreia suggests is similar to the approach I took when I ran into this problem. I made a import panflute as pf
def prepare(doc):
doc.references = None
def action(el, doc):
if isinstance(el, pf.Div) and el.identifier == "refs":
doc.references = list(el.content)
return []
def finalize(doc):
if doc.references:
doc.metadata["references"] = pf.MetaBlocks(*doc.references)
del doc.references
if __name__ == "__main__":
pf.toJSONFilter(action, prepare, finalize) This works fine, and I think inserting after specific headers is reasonable for a more general approach. |
Pandoc-citeproc already allows you to insert a div with id refs, and in this case puts the references there. Can this issue be closed, or is there something I'm missing? |
Yes, I agree that this can be closed. |
In case someone is looking for a quick copy & paste example: This is some text [@item1]
This is more text [@item2]
# References
<div id="refs"></div>
# appendix |
Aditya Mahajan suggests on pandoc-discuss:
Is it possible to change the way bibliography is handled? Can you add$if(bibliography)$ check for the template file, and a $references$
a
tag for the list of references. Then, I can use the following in my
ConTeXt template:
This may also circumvent the need to explicitly write
#References
inthe markdown file (but I don't know how other writers would handle
this).
The text was updated successfully, but these errors were encountered: