From 3f4e2bf4d3288c1d9a6463e602b978cf8b1ad776 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 23 Sep 2010 13:34:56 +0200 Subject: bib stuff (bib module and citator) --- rst_context.lua | 84 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 12 deletions(-) (limited to 'rst_context.lua') diff --git a/rst_context.lua b/rst_context.lua index 288df02..1ea681f 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -63,6 +63,11 @@ rst_context.lastitemnumber = 0 -- enumerations in RST allow arbitrary ski rst_context.current_footnote_number = 0 rst_context.current_symbolnote_number = 0 +function rst_context.addsetups(item) + state.addme[item] = state.addme[item] or true + return 0 +end + function rst_context.footnote_reference (label) local tf = state.footnotes if label:match("^%d+$") then -- all digits @@ -86,21 +91,11 @@ function rst_context.footnote_reference (label) rst_context.current_symbolnote_number = rc return [[\\symbolnote{\\getbuffer[__footnote_symbol_]].. rc .."]}" else -- “citation reference” for now treating them like footnotes - local rc = rst_context.current_footnote_number - rc = rc + 1 - --rst_context.current_footnote_number = rst_context.current_footnote_number + 1 - --print("creating footnote nr " .. rc) - rst_context.current_footnote_number = rc - return [[\\footnote{\\getbuffer[__footnote_number_]].. rc .."]}" - --return [[\\cite{]] .. label .. "}" + rst_context.addsetups("citations") + return [[\\cite{]] .. label .. [[}]] end end -function rst_context.addsetups(item) - state.addme[item] = state.addme[item] or true - return 0 -end - do local w = S" \v\t\n" / "_" local wp = Cs((w + 1)^1) @@ -134,6 +129,8 @@ function rst_context.literal (str) --return [[\\starttyping ]] .. str .. [[\\stoptyping]] end +--- ROLES for interpreted text + rst_context.roles = {} rst_context.roles.emphasis = rst_context.emphasis rst_context.roles.strong_emphasis = rst_context.strong_emphasis @@ -165,6 +162,69 @@ rst_context.roles.color = function(color, str) return string.format([[\\colored[%s]{%s}]], definition, str) end +--- Inofficial text roles for my private bib + +-- Afterthought: +-- Different citation commands are essentially typographical instructions: +-- they are concerned with the final representation of the data with respect to +-- a concrete implementation. Not the thing at all that would make reST +-- portable. But then its support for Python-style string escaping &c. ain’t at +-- all portable either. The problem is the same with XML written to be +-- processed with ConTeXt -- when processing the text directly in MkIV you’ll +-- always find yourself adding setups that allow fine-grained control of the +-- typeset output. At the same time those instructions directly contradict the +-- main reason for XML: to provide an application-independent data markup. +-- Typesetting XML (and now reST) with TeX, you will always end up writing TeX +-- code disguised in XML brackets. (Btw. the docutils reST specification has +-- the same kind of inclination to HTML -- some of its components don’t even +-- have a meaning save in HTML peculiarities.) If you strive to avoid this +-- *and* would like to have decent typesetting, you should use the +-- automatically generated TeX code as a starting point for the actual +-- typesetting job. Wish it was possible to have both -- the data in a +-- universal form and the output in the Optimal Typesetting System -- but +-- that’s a dream for now. If you really read these musings, then prove me +-- wrong if you can! Or go tell those digital publishers and their willing +-- subordinates, the authors, who think they can save a few pennys, +-- substituting the typesetter and editor by some fancy software. Keep in mind +-- that zapf.tex is not just random dummy text. Now, where was I? + +function rst_context.roles.ctsh(str) -- shorthand + rst_context.addsetups("citator") + return [[\\ctsh{]] .. str .. [[}]] +end + +function rst_context.roles.ctas(str) -- short cite + rst_context.addsetups("citator") + return [[\\ctas{]] .. str .. [[}]] +end + +function rst_context.roles.ctau(str) -- author only + rst_context.addsetups("citator") + return [[\\ctau{]] .. str .. [[}]] +end + +function rst_context.roles.cttt(str) -- title only + rst_context.addsetups("citator") + return [[\\cttt{]] .. str .. [[}]] +end + +function rst_context.roles.ctay(str) -- author year + rst_context.addsetups("citator") + return [[\\ctay{]] .. str .. [[}]] +end + +function rst_context.roles.ctfu(str) -- full cite + rst_context.addsetups("citator") + return [[\\ctfu{]] .. str .. [[}]] +end + +function rst_context.roles.nocite(str) -- nocite + rst_context.addsetups("citator") + return [[\\nocite[]] .. str .. [=[]]=] +end + +--- End citator roles + function rst_context.interpreted_text (...) local tab = { ... } local role, str -- cgit v1.2.3