summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/publ-ini.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/publ-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/publ-ini.mkiv264
1 files changed, 210 insertions, 54 deletions
diff --git a/Master/texmf-dist/tex/context/base/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/publ-ini.mkiv
index adbf8f7fcf0..68e185f2375 100644
--- a/Master/texmf-dist/tex/context/base/publ-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/publ-ini.mkiv
@@ -15,6 +15,7 @@
% todo: \v!cite => \s!cite
% todo: interface with (ml)bibtex (export -> call -> import)
% todo: check if 'all' etc are ok ... either use list or use other criterium
+% todo: \the\everysetupbtxciteplacement probably too often
% \definecolor[btx:field] [darkred]
% \definecolor[btx:crossref][darkblue]
@@ -44,7 +45,10 @@
\unprotect
-\def\s!btx{btx}
+\startcontextdefinitioncode
+
+\def\s!btx {btx}
+\def\s!cite {cite}
\def\v!btxlist{btxlist}
% a dedicated construction mechanism
@@ -346,12 +350,34 @@
\fi
\to \everydefinebtxrendering
+% \unexpanded\def\btx_entry_inject
+% {\begingroup
+% \edef\currentbtxcategory{\btxfield{category}}%
+% \ignorespaces
+% \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
+% \removeunwantedspaces
+% \endgroup}
+
+\let\currentbtxcombis\empty % goes into the setups
+
\unexpanded\def\btx_entry_inject
{\begingroup
\edef\currentbtxcategory{\btxfield{category}}%
\ignorespaces
\directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
\removeunwantedspaces
+ \ifx\currentbtxcombis\empty \else
+ ;\space % todo .. parameter .. what is a good name .. problem: what if ends with .
+ \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi
+ \fi
+ \endgroup}
+
+\def\btx_entry_inject_combi#1%
+ {\begingroup
+ \def\currentbtxtag{#1}%
+ \ignorespaces
+ \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
+ \removeunwantedspaces
\endgroup}
\unexpanded\def\completebtxrendering{\dodoubleempty\publ_place_list_complete}
@@ -428,7 +454,8 @@
keyword = "\btxrenderingparameter\c!keyword",
}}%
% next we analyze the width
- \ifx\btx_reference_inject_indeed\relax \else
+ \ifx\btx_reference_inject_indeed\relax
+ \else
\edef\p_width{\btxrenderingparameter\c!width}%
\ifx\p_width\v!auto
\scratchcounter\btxcounter
@@ -484,6 +511,13 @@
\fi
\endgroup}
+\unexpanded\def\btxchecklistcombi#1% called at the lua end
+ {\begingroup
+ \edef\currentbtxtag{#1}%
+ ; % todo
+ \publ_check_list_entry
+ \endgroup}
+
\unexpanded\def\publ_check_list_entry
{\global\advance\btxcounter\plusone
% todo, switch to font
@@ -549,6 +583,13 @@
\unexpanded\def\btxflushauthorinverted {\btx_flush_author{inverted}} % #1
\unexpanded\def\btxflushauthorinvertedshort{\btx_flush_author{invertedshort}} % #1
+\unexpanded\def\currentbtxciteauthor % always author
+ {\ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","author",{
+ combiner = "\btxcitevariantparameter\c!author",
+ etallimit = \number\btxcitevariantparameter\c!etallimit,
+ etaldisplay = \number\btxcitevariantparameter\c!etaldisplay,
+ })}}
+
% \btxflushauthor{author}
% \btxflushauthor{artauthor}
% \btxflushauthor{editor}
@@ -558,38 +599,44 @@
% \btxflushauthor[inverted]{author}
% \btxflushauthor[invertedshort]{author}
-% Interaction
+% Interaction: only list
\newconditional\btxinteractive
-\unexpanded\def\btxdoifelseinteraction
- {\iflocation
- \edef\p_interaction{\btxcitevariantparameter\c!interaction}%
- \ifx\p_interaction\v!stop
- \doubleexpandafter\secondoftwoarguments
- \else
- \doubleexpandafter\firstoftwoarguments
- \fi
- \else
- \expandafter\secondoftwoarguments
- \fi}
+\unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments}
\appendtoks
\iflocation
\edef\p_interaction{\btxlistvariantparameter\c!interaction}%
\ifx\p_interaction\v!stop
- \let\doifelsebtxinteractionelse\secondoftwoarguments
+ \let\btxdoifelseinteraction\secondoftwoarguments
\setfalse\btxinteractive
\else
- \let\doifelsebtxinteractionelse\firstoftwoarguments
+ \let\btxdoifelseinteraction\firstoftwoarguments
\settrue\btxinteractive
\fi
\else
- \let\doifelsebtxinteractionelse\secondoftwoarguments
+ \let\btxdoifelseinteraction\secondoftwoarguments
\setfalse\btxinteractive
\fi
\to \everysetupbtxlistplacement
+\appendtoks
+ \iflocation
+ \edef\p_interaction{\btxcitevariantparameter\c!interaction}%
+ \ifx\p_interaction\v!stop
+ \let\btxdoifelseinteraction\secondoftwoarguments
+ \setfalse\btxinteractive
+ \else
+ \let\btxdoifelseinteraction\firstoftwoarguments
+ \settrue\btxinteractive
+ \fi
+ \else
+ \let\btxdoifelseinteraction\secondoftwoarguments
+ \setfalse\btxinteractive
+ \fi
+\to \everysetupbtxciteplacement
+
% bib -> btx
\unexpanded\def\btxgotolink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}}
@@ -651,15 +698,21 @@
% \iftrialtypesetting \else
% \processcommacommand[\currentbtxtag]{\publ_cite_indeed\currentbtxrendering}%
% \fi}
+%
+% \def\publ_cite_indeed#1#2%
+% {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}}
-\def\publ_cite_indeed#1#2%
- {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}}
-
-\def\btxdomarkcitation#1#2% called from lua end
- {\iftrialtypesetting \else
- \writedatatolist[btx][btxset=#1,btxref=#2]% \c!location=\v!here
+\unexpanded\def\btxdomarkcitation % called from lua end
+ {\iftrialtypesetting
+ \expandafter\gobbletwoarguments
+ \else
+ \expandafter\publ_cite_mark_citation
\fi}
+\def\publ_cite_mark_citation#1#2% called from lua end
+ {\dontleavehmode
+ \writedatatolist[btx][btxset=#1,btxref=#2]} % \c!location=\v!here
+
%D \macros{cite,nocite,citation,nocitation,usecitation}
%D
%D The inline \type {\cite} command creates a (often) short reference to a publication
@@ -687,6 +740,7 @@
{\letinteractionparameter\c!style\empty
\edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}%
\edef\currentbtxcitetag{#1}%
+ \the\everysetupbtxciteplacement
\publ_cite_variant
\endgroup}
@@ -695,21 +749,31 @@
\unexpanded\def\publ_cite_tags_options[#1]%
{\strictdoifnextoptionalelse{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}}
+% \unexpanded\def\publ_cite_tags_options_indeed#1[#2]%
+% {\edef\currentbtxcitetag{#2}%
+% \doifassignmentelse{#1}
+% {\publ_cite_tags_settings_indeed{#1}}
+% {\publ_cite_tags_variants_indeed{#1}}}
+
\unexpanded\def\publ_cite_tags_options_indeed#1[#2]%
{\edef\currentbtxcitetag{#2}%
- \doifassignmentelse{#1}
- {\publ_cite_tags_settings_indeed{#1}}
- {\publ_cite_tags_variants_indeed{#1}}}
+ \doifassignmentelse{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}}
\def\publ_cite_tags_settings_indeed#1%
{\letinteractionparameter\c!style\empty
%\letinteractionparameter\c!color\empty
- \getdummyparameters[\c!alternative=,\c!extras=,#1]%
+ \letdummyparameter\c!before \empty
+ \letdummyparameter\c!after \empty
+ \letdummyparameter\c!extras \empty
+ \letdummyparameter\c!alternative\empty
+ \getdummyparameters[#1]%
\edef\p_alternative{\dummyparameter\c!alternative}%
- \ifx\p_alternative\empty \else
+ \ifx\p_alternative\empty
+ \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}%
+ \else
\let\currentbtxcitevariant\p_alternative
\fi
- \setupcurrentbtxcitevariantparameters[#1]%
+ \setupcurrentbtxcitevariant[#1]%
\edef\p_extras{\dummyparameter\c!extras}%
\ifx\p_extras\empty \else
\edef\p_right{\btxcitevariantparameter\c!right}%
@@ -717,45 +781,53 @@
\setexpandedbtxcitevariantparameter\p_right{\p_extras\p_right}%
\fi
\fi
+ \edef\p_before{\dummyparameter\c!before}%
+ \edef\p_after {\dummyparameter\c!after}%
+ \ifx\p_before\empty \else
+ \p_before
+ \space
+ \fi
\publ_cite_variant
+ \ifx\p_after\empty \else
+ \optionalspace
+ \p_after
+ \fi
\endgroup}
\def\publ_cite_tags_variants_indeed#1%
{\letinteractionparameter\c!style\empty
\edef\currentbtxcitevariant{#1}%
+ \the\everysetupbtxciteplacement
\publ_cite_variant
\endgroup}
\newconditional\btxcitecompress
\def\publ_cite_variant
- {\edef\p_compress{\btxcitevariantparameter\c!compress}%
- % \ifx\p_compress\v!no
- % \setfalse\btxcitecompress
- % \else
- % \settrue\btxcitecompress
- % \fi
- \begingroup
+ {\begingroup
\settrue\c_publ_cite_write
\publ_cite_handle_variant_indeed[\currentbtxcitetag]}
\unexpanded\def\publ_cite_handle_variant#1%
{\begingroup
- \the\everysetupbtxciteplacement
\edef\currentbtxcitevariant{#1}%
+ \the\everysetupbtxciteplacement
\dosingleargument\publ_cite_handle_variant_indeed}
\def\publ_cite_handle_variant_indeed[#1]%
{\usebtxcitevariantstyleandcolor\c!style\c!color
\letbtxcitevariantparameter\c!alternative\currentbtxcitevariant
- \ctxcommand{btxhandlecite(%
- "\currentbtxdataset",%
- "#1",%
- \iftrialtypesetting false\else true\fi,%
- "\currentbtxcitevariant",%
- "\btxcitevariantparameter\c!sorttype",%
- "\btxcitevariantparameter\c!setups"%
- )}%
+ \btxcitevariantparameter\v!left
+ \ctxcommand{btxhandlecite{%
+ dataset = "\currentbtxdataset",%
+ reference = "#1",%
+ markentry = \iftrialtypesetting false\else true\fi,%
+ variant = "\currentbtxcitevariant",%
+ sorttype = "\btxcitevariantparameter\c!sorttype",%
+ compress = "\btxcitevariantparameter\c!compress",%
+ author = "\btxcitevariantparameter\c!author",%
+ }}%
+ \btxcitevariantparameter\v!right
\endgroup}
\unexpanded\def\btxcitation
@@ -775,9 +847,16 @@
\unexpanded\def\publ_cite_no[#1]%
{\iftrialtypesetting \else
- \ctxcommand{btxhandlenocite("\currentbtxdataset","#1",true)}%
+ \ctxcommand{btxhandlecite{%
+ dataset = "\currentbtxdataset",%
+ reference = "#1",%
+ markentry = \iftrialtypesetting false\else true\fi,%
+ }}%
\fi}
+\unexpanded\def\btxmissing#1%
+ {{\tttf<#1>}}
+
%D Compatibility:
\let\cite \btxcite
@@ -788,8 +867,42 @@
%D Cite helpers:
-\unexpanded\def\btxcitevariant#1%
- {\ctxcommand{btxcitevariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1")}}
+\newconstant\currentbtxconcat
+
+% \unexpanded\def\btxcitevariant#1%
+% {\ctxcommand{btxcitevariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1")}}
+
+\unexpanded\def\btxcitereset
+ {\let\currentbtxfirst \empty
+ \let\currentbtxsecond \empty
+ \let\currentbtxinternal\empty
+ \let\currentbtxtag \empty
+ \setconstant\currentbtxconcat\zerocount}
+
+\btxcitereset
+
+\unexpanded\def\btxcitesetup#1%
+ {\directsetup{btx:cite:#1}%
+ \btxcitereset}
+
+\unexpanded\def\btxsetfirst {\def\currentbtxfirst}
+\unexpanded\def\btxsetsecond {\def\currentbtxsecond}
+\unexpanded\def\btxsettag {\def\currentbtxtag}
+\unexpanded\def\btxsetinternal{\def\currentbtxinternal}
+\unexpanded\def\btxsetconcat#1{\setconstant\currentbtxconcat#1\relax}
+
+\unexpanded\def\btxsetreference#1#2% #3#4%
+ {\strc_references_direct_full_user{btxset="#1",btxref="#2"}}
+
+\unexpanded\def\btxstartsubcite#1%
+ {\bgroup
+ \btxcitereset
+ \def\currentbtxcitevariant{#1}%
+ \btxcitevariantparameter\c!left}
+
+\unexpanded\def\btxstopsubcite
+ {\btxcitevariantparameter\c!right
+ \egroup}
%D List helpers:
@@ -816,6 +929,8 @@
\loadbtxdefinitionfile[\btxrenderingparameter\c!alternative]
\to \everysetupbtxrendering
+\stopcontextdefinitioncode
+
%D Defaults:
\setupbtxrendering
@@ -842,9 +957,12 @@
\c!otherstext={ et al.},
\c!pubsep={, },
\c!lastpubsep={ and },
+ \c!finalpubsep={ and },
\c!compress=\v!no,
\c!inbetween={ },
+ \c!range=\endash,
\c!left=,
+ \c!middle=,
\c!right=]
\definebtxcitevariant
@@ -855,6 +973,11 @@
\c!right={)}]
\definebtxcitevariant
+ [authornum]
+ [author]
+ [\c!inbetween={ }]
+
+\definebtxcitevariant
[authoryear]
[\c!compress=\v!yes,
\c!inbetween={, },
@@ -867,62 +990,90 @@
[authoryear]
\definebtxcitevariant
+ [author:num]
[authornum]
- [author]
[\c!left={[},
\c!right={]}]
\definebtxcitevariant
+ [author:year]
+ [authoryear]
+ [\c!left={(},
+ \c!right={)}]
+
+\definebtxcitevariant
+ [author:years]
+ [authoryears]
+ [\c!left=,
+ \c!right=]
+
+\definebtxcitevariant
[year]
[\c!left={(},
+ \c!middle={, }, % is middle used?
\c!right={)}]
\definebtxcitevariant
- [key]
+ [tag]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
+ [key]
+ [tag]
+
+\definebtxcitevariant
[serial]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[page]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[short]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
- [type]
+ [category]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
+ [type]
+ [category]
+
+\definebtxcitevariant
[doi]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[url]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[page]
[\c!left=,
- \c!right=,
- \c!inbetween=\endash]
+ \c!middle={, },
+ \c!right=]
\definebtxcitevariant
[num]
[\c!compress=\v!yes,
- \c!inbetween={--},
\c!left={[},
+ \c!middle={, },
\c!right={]}]
\setupbtxlistvariant
@@ -953,6 +1104,11 @@
[artauthor]
[author]
+\setupbtxcitevariant
+ [\c!author =\btxlistvariantparameter\c!author,
+ \c!etallimit =\btxlistvariantparameter\c!etallimit,
+ \c!etaldisplay =\btxlistvariantparameter\c!etaldisplay]
+
% Do we want these in the format? Loading them delayed is somewhat messy.
\loadbtxdefinitionfile[apa]