Just to bounce some ideas around …
So I’m (very) slowly working on citeproc-py, with the goal to make it
as simple as possible to maintain, extend, and debug.
http://github.com/bdarcus/citeproc-py
The approach I’m taking is explained in this function:
def process_bibliography(style, reference_list):
""“
With a Style and the list of References produce the FormattedOutput
for the bibliography.
”""
processed_bibliography = [[process_node(style_node, reference) for
style_node in style.bibliography.layout]
for reference in reference_list]
return(processed_bibliography)
So I have a nested list comprehension that iterates through style
nodes and reference items, and passes them on to a process_node
function, which returns a FormattedNode object. This object merges the
style node (formatting instructions) and the reference content.
Does this make sense?
Does it make sense to consider a macro call as in turn generating a
sublist of these FormattedNode objects?
So, in other words, if you have a style with three nodes: the first
and last we’ll call ‘a’ and ‘d’. The second is a macro call that in
turn has two text nodes, which we’ll call ‘b’ and c’.
My thought is the processed list looks like:
[a, [b, c], d]
Hence, to generate the final output, you flatten the list, and spit
out the pieces.
I ask because I haven’t even started on the difficult stuff (names and
such), but am assuming a broadly similar approach.
Bruce