summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/publ-imp-definitions.mkvi
blob: 4b6e8d6ae46d4ae26238906bb8628e3b3e1a2bd3 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
%D \module
%D   [       file=publ-imp-def,
%D        version=2013.12.24,
%D          title=\CONTEXT\ Publication Support,
%D       subtitle=Definitions,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Here we collect some helper setups. We assume that checking of a field
%D happens in the calling setup, if only because that is the place where
%D fences are also dealt with.

% These will become texdefinitions

\unprotect

\startxmlsetups btx:format:crossref
    \cite[\btxfield{crossref}]
\stopxmlsetups

\startxmlsetups btx:format:key
    \btxfield{short}
\stopxmlsetups

\starttexdefinition mutable protected btx:format:gotointernal #content
    \ifx\currentbtxinternal\empty
        #content
    \else\ifnum\currentbtxinternal=\zerocount
        #content
    \else\ifconditional\btxinteractive
        \goto {#content} [\s!internal(\currentbtxinternal)]
    \else
        #content
    \fi\fi\fi
\stoptexdefinition

\starttexdefinition mutable protected btx:format:goto #link #content
    \ifconditional\btxinteractive
        \goto {#content} [#link]
    \else
        #content
    \fi
\stoptexdefinition

\startxmlsetups btx:format:doi
    \edef\currentbtxfielddoi{\btxfield{doi}}
    \ifx\currentbtxfielddoi\empty
        {\tttf no-doi}
    \else
        \texdefinition {btx:format:goto} {
            url(http://dx.doi.org/\currentbtxfielddoi)
        } {
            \hyphenatedurl{\currentbtxfielddoi}
        }
    \fi
\stopxmlsetups

\startxmlsetups btx:format:url
    \edef\currentbtxfieldurl{\btxfield{url}}
    \ifx\currentbtxfieldurl\empty
        {\tttf no-url}
    \else
        \texdefinition {btx:format:goto} {
            url(\currentbtxfieldurl)
        } {
            \hyphenatedurl{\currentbtxfieldurl}
        }
    \fi
\stopxmlsetups

\startxmlsetups btx:format:year
    \edef\currentbtxfieldyear{\btxfield{year}}
    \ifx\currentbtxfieldyear\empty
        \btxlabeltext{\currentbtxspecification:nd}
    \fi
\stopxmlsetups

\startxmlsetups btx:format:month
    \edef\currentbtxfieldmonth{\btxfield{month}}
    \ifx\currentbtxfieldmonth\empty
        {\tttf no-month}
    \else
        \edef\p_monthconversion{\btxparameter\c!monthconversion}
        \ifx\p_monthconversion\empty % month month:mnem
            \currentbtxfieldmonth
        \else
            \doifelsenumber \currentbtxfieldmonth {
                \convertnumber\p_monthconversion\currentbtxfieldmonth
            } {
                \currentbtxfieldmonth
            }
        \fi
    \fi
\stopxmlsetups

% macros:

\starttexdefinition mutable protected btx:style:italic #content
    \dontleavehmode
    \begingroup
        \it
        #content
        \italiccorrection
    \endgroup
\stoptexdefinition

\starttexdefinition mutable protected btx:style:bold #content
    \dontleavehmode
    \begingroup
        \bf
        #content
    \endgroup
\stoptexdefinition

\starttexdefinition mutable protected btx:style:quote #content
    \dontleavehmode
    \startquote
        #content
    \stopquote
\stoptexdefinition

\starttexdefinition mutable protected btx:style #style #content
    \doifelsedefined {btx:style:#style} {
        \texdefinition{btx:style:#style} {
            #content
        }
    } {
        #content
    }
\stoptexdefinition

\protect