summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/publications/publications-extensions.tex
blob: 262d5eb3ca901e0e3a5083f83ba1a5871b9969c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
\environment publications-style

\startcomponent publications-extensions

\startchapter[title=Extensions]

As \TEX\ and \LUA\ are both open and accessible in \CONTEXT\ it is possible to
extend the functionality of the bibliography related code. For instance, you
could add extra loaders, sketched as follows:

\startTEX
\startluacode
function publications.loaders.myformat(dataset,filename)
    local t = { }
    -- Load data from 'filename' and convert it to a Lua table 't' with
    -- the key as hash entry and fields conforming the luadata table
    -- format.
    loaders.lua(dataset,t)
end
\stopluacode
\stopTEX

This would then permit the loading a database (into a dataset) with the command:

\cindex{usebtxdataset}

\startTEX
\usebtxdataset[default][myfile.myformat]
\stopTEX

The \type {myformat} suffix is recognized automatically. If you want to use another
suffix, you can do this:

\cindex{usebtxdataset}

\startTEX
\usebtxdataset[default][myformat::myfile.txt]
\stopTEX

%% NO SETUP BTX:APA:LEFTTEXT SO THE FOLLOWING DOES NOT WORK:
%%
%% If you want to add information to an entry at runtime you can pass so called user
%% variables with the \type {\cite} command. The following example demonstrates
%% this. First we define a dataset:
%%
%% \startbuffer
%% \startbuffer [knuth]
%% @Book{knuth-texbook,
%%     title     = {The TeXbook},
%%     author    = {Knuth, Donald Ervin},
%%     isbn      = {0-201-13447-0},
%%     series    = {Computers {\&} Typesetting},
%%     volume    = {A},
%%     year      = {1986},
%%     publisher = {Addison Wesley},
%%     address   = {Reading, MA},
%% }
%% \stopbuffer
%%
%% \definebtxdataset[knuth]
%% \usebtxdataset [knuth] [knuth.buffer]
%% \definebtxrendering[knuth][dataset=knuth]
%% \stopbuffer
%%
%% \typeTEXbuffer
%% \getbuffer
%%
%% \startbuffer[setup]
%% \startsetups btx:apa:lefttext
%%     \currentbtxlefttext
%%     \btxspace
%%     \btxdoifelseuservariable {notabene} {
%%         {\bs \currentbtxuservariable{notabene}}
%%     } {
%%         % nothing
%%     }
%%     \btxspace
%% \stopsetups
%% \stopbuffer
%%
%% \getbuffer[setup]
%%
%% \startbuffer
%% We all know the \TeX book by Don Knuth \citation [reference=knuth::knuth-texbook,
%% lefttext={\bf >}] [notabene=Well known to \TEX\ users:].
%% \stopbuffer
%%
%% We use this example where we use \type {\citation} instead of \type {\cite} because
%% it is more tolerant with spaces. Because we pass user variables as second argument
%% the first argument also has to be a key|/|value set.
%%
%% \typeTEXbuffer
%%
%% \getbuffer
%%
%% The list is typeset using:
%%
%% \startbuffer
%% \placelistofpublications [knuth] [criterium=all]
%% \stopbuffer
%%
%% \typeTEXbuffer
%%
%% and looks like this:
%%
%% \getbuffer
%%
%% The injection of the user variables is up to you. Here we hooked it into an
%% existing setup that we overload:
%%
%% \typeTEXbuffer [setup]
%%
%% The \type {lefttext} and \type {righttext} variables are also kept with the
%% entry but these are checked for automatically. In this case it means that
%% when no \type {lefttext} is specified, the \type {notabene} doesn't show up.

\stopchapter

\stopcomponent