summaryrefslogtreecommitdiff
path: root/tex/context/bib/t-bib.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/bib/t-bib.mkiv')
-rw-r--r--tex/context/bib/t-bib.mkiv64
1 files changed, 64 insertions, 0 deletions
diff --git a/tex/context/bib/t-bib.mkiv b/tex/context/bib/t-bib.mkiv
new file mode 100644
index 000000000..4316d380e
--- /dev/null
+++ b/tex/context/bib/t-bib.mkiv
@@ -0,0 +1,64 @@
+%D Note by HH:
+%D
+%D We use a still somewhat experimental extension to the list
+%D mechanism. Eventually the bibtex module will use the bibl loader
+%D and access the data by means of lpath expressions. In that case we
+%D don't need to process the bibliography but still need to track
+%D usage as done here.
+
+\unprotect
+
+\startluacode
+local list = { }
+
+bibtexhacks = {
+ reset = function() list = { } end,
+ add = function(str) list[#list+1] = str end,
+ flush = function() tex.sprint(table.concat(list,",")) end,
+}
+\stopluacode
+
+\unprotect
+
+% HACK WILL GO:
+
+\def\namedlistparameter#1#2{\csname\dolistparameter{\??li#1}#2\endcsname}
+
+% TILL HERE
+
+\let\bibrefprefixcounter\!!plusone
+\def\bibrefprefix {\bibrefprefixcounter:}
+\let\preparebibrefprefix\relax
+\let\preparebibreflist \gobbleoneargument
+\let\bibreflist \empty
+
+\setuplist[pubs][\c!state=\s!start]
+
+\installstructurelistprocessor{pubs:userdata}
+ {\ctxlua{bibtexhacks.add(structure.lists.uservalue("\currentlist",\currentlistindex,"bibref"))}}
+
+\def\docitation#1%
+ {\expanded{\writedatatolist[pubs][bibref=#1]}}
+
+\def\filllocalpublist
+ {\edef\currentlist{pubs}%
+ \doif{\listparameter\c!criterium}{cite}{\setuplist[pubs][\c!criterium=\v!here]}%
+ \ctxlua{bibtexhacks.reset()}%
+ \placestructurelist{pubs}{\listparameter\c!criterium}{\listparameter\c!number}%
+ \edef\localpublist{\ctxlua{bibtexhacks.flush()}}}
+
+\def\gotobiblink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{\unknownreference{#2}}}
+\def\atbiblink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\at [\bibrefprefix#1]}{\unknownreference{#1}}}
+\def\inbiblink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\at [\bibrefprefix#1]}{\unknownreference{#1}}}
+
+\ifdefined\normaldodoplacepublications \else % just in case we load twice
+
+ \let\normaldodoplacepublications\dodoplacepublications
+
+ \def\dodoplacepublications
+ {\normaldodoplacepublications
+ \doglobal\increment\bibrefprefixcounter}
+
+\fi
+
+\protect \endinput