diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/publ-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/publ-ini.mkiv | 1963 |
1 files changed, 1290 insertions, 673 deletions
diff --git a/Master/texmf-dist/tex/context/base/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/publ-ini.mkiv index fb0d00d03c0..a4452e45193 100644 --- a/Master/texmf-dist/tex/context/base/publ-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/publ-ini.mkiv @@ -11,6 +11,11 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. + +% TODO: s! vs v! for default and neutral key/values +% todo: too many refs in list + +% todo: tagging % todo: we cannot use 'default' as this wipes metadata names (maybe no longer do that) % todo: \v!cite => \s!cite % todo: interface with (ml)bibtex (export -> call -> import) @@ -38,171 +43,229 @@ \writestatus{loading}{ConTeXt Publication Support / Initialization} \registerctxluafile{publ-dat}{1.001} +\registerctxluafile{publ-ini}{1.001} +\registerctxluafile{publ-sor}{1.001} \registerctxluafile{publ-aut}{1.001} \registerctxluafile{publ-usr}{1.001} -\registerctxluafile{publ-ini}{1.001} \registerctxluafile{publ-oth}{1.001} % this could become an option - -\doiffileelse{publ-fnd.lua} - {\registerctxluafile{publ-fnd}{1.001}} % new method (for the moment only local) - {} +\registerctxluafile{publ-fnd}{1.001} % new method (for the moment only local) +\registerctxluafile{publ-jrn}{1.001} +\registerctxluafile{publ-reg}{1.001} \unprotect \startcontextdefinitioncode -\def\s!btx {btx} -\def\s!cite {cite} -\def\s!list {list} -\def\v!btxcite{btxcite} -\def\v!btxlist{btxlist} - -% a dedicated construction mechanism - -\installcorenamespace {btxlist} +\def\s!btx {btx} + +\def\v!btxcite {btxcite} +\def\v!btxlist {btxlist} +\def\v!btxrendering {btxrendering} + +\def\s!btxset {btxset} +\def\s!btxref {btxref} +\def\s!btxint {btxint} +\def\s!btxbck {btxbck} +\def\s!btxltx {btxltx} +\def\s!btxrtx {btxrtx} +\def\s!btxatx {btxatx} +\def\s!btxbtx {btxbtx} +\def\s!btxspc {btxspc} +\def\s!btxlst {btxlst} + +\definelabelclass[btxlabel][2] + +% It is not that trivial to come up with a proper organization of setup +% and control commands for publications. This is because we have complex +% inline as well as extensive list rendering. The rules are partially +% driven by somewhat archaic bibtex specifications and evolving journal +% (or field) specific demands. The logic in the standards is often so +% complex that it looks like manual rendering is assumed. But, we want to +% automate the process as much as possible. +% +% Another complication is that in manuals we want to demonstrate different +% properties of the implementation and therefore we need a way to handle +% independent standards, databases, etc. This has resulted in the following +% organization: +% +% - general setup (rather minimal) +% - list setup (rendering) +% - cite setup +% - dataset setup +% +% The rendering is mostly driven by setups. In there we can call for fields +% in the database but also for virtual fields or combinations. -\installcommandhandler \??btxlist {btxlist} \??btxlist +% The main rendering style (standard driven). -\unexpanded\setvalue{\??constructioninitializer\v!btxlist}% - {\let\currentbtxlist \currentconstruction - \let\constructionparameter \btxlistparameter - \let\detokenizedconstructionparameter\detokenizedbtxlistparameter - \let\letconstructionparameter \letbtxlistparameter - \let\useconstructionstyleandcolor \usebtxliststyleandcolor - \let\setupcurrentconstruction \setupcurrentbtxlist} +%D We assume that a specification is global or used grouped. It doesn't make much sense +%D to split between cite and list here as it only complicates matters (timing) and is +%D not clear either. -\expandafter\let\csname\??constructionmainhandler \v!btxlist\expandafter\endcsname\csname\??constructionmainhandler \v!construction\endcsname -\expandafter\let\csname\??constructioncommandhandler\v!btxlist\expandafter\endcsname\csname\??constructioncommandhandler\v!construction\endcsname -\expandafter\let\csname\??constructiontexthandler \v!btxlist\expandafter\endcsname\csname\??constructiontexthandler \v!construction\endcsname +\let\currentbtxspecification\empty -\unexpanded\setvalue{\??constructioncommandhandler\v!btxlist}% - {\csname\??constructionstarthandler\v!construction\endcsname - \csname\??constructionstophandler \v!construction\endcsname - \endgroup} +\unexpanded\def\startbtxrenderingdefinitions[#1]% + {\unprotect + \pushmacro\currentbtxspecification + \edef\currentbtxspecification{#1}} -\unexpanded\setvalue{\??constructionstarthandler\v!btxlist}% - {\csname\??constructionstarthandler\v!construction\endcsname} +\unexpanded\def\stopbtxrenderingdefinitions + {\popmacro\currentbtxspecification + \protect} -\unexpanded\setvalue{\??constructionstophandler\v!btxlist}% - {\csname\??constructionstophandler\v!construction\endcsname - \endgroup} +\unexpanded\def\loadbtxdefinitionfile [#1]{\clf_btxloaddefinitionfile {#1}} +\unexpanded\def\loadbtxreplacementfile[#1]{\clf_btxloadreplacementfile{#1}} -\unexpanded\def\startbtxlistentry#1% - {\begingroup - \strc_constructions_initialize{#1}% - \csname\??constructionstarthandler\currentconstructionhandler\endcsname} +\unexpanded\def\publ_specification_push#1% + {\pushmacro\currentbtxspecification + \pushmacro\currentbtxspecificationfallback + \edef\currentbtxspecification{#1}% + \edef\currentbtxspecificationfallback{\namedbtxparameter\currentbtxspecification\c!default}% + \ifx\currentbtxspecificationfallback\currentbtxspecification + \let\currentbtxspecificationfallback\empty + \fi + \clf_btxsetspecification{\currentbtxspecification}} + +\unexpanded\def\publ_specification_pop + {\popmacro\currentbtxspecificationfallback + \popmacro\currentbtxspecification + \clf_btxsetspecification{\currentbtxspecification}} + +\unexpanded\def\publ_specification_set#1% beware: is global + {\edef\currentbtxspecification{#1}% + \edef\currentbtxspecificationfallback{\namedbtxparameter\currentbtxspecification\c!default}% + \ifx\currentbtxspecificationfallback\currentbtxspecification + \let\currentbtxspecificationfallback\empty + \fi + % has to be done explicitly: \loadbtxdefinitionfile[\currentbtxspecification]% + \ifx\currentbtxspecification\empty + % we set default at the end + \else + \clf_btxsetspecification{\currentbtxspecification}% + \fi}% todo: ,true == also load -\unexpanded\def\stopbtxlistentry - {\csname\??constructionstophandler\currentconstructionhandler\endcsname} +\installcorenamespace {btx} -\unexpanded\setvalue{\??constructiontexthandler\v!btxlist}% - {\begingroup - \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext - \the\everyconstruction - \goto - {\strut\constructionparameter\c!text\btx_list_reference_inject}% -% [\s!btx:list:\the\numexpr\locationcount+\plusone]% \nextinternalreference - [internal(\the\numexpr\locationcount+\plusone)]% \nextinternalreference - \endgroup} +\installswitchcommandhandler \??btx {btx} \??btx -\unexpanded\def\strc_constructions_initialize#1% class instance - {\edef\currentconstruction{#1}% - \let\currentconstructionlistentry\!!zerocount - \expandafter\let\expandafter\currentconstructionmain \csname\??constructionmain \currentconstruction\endcsname - \expandafter\let\expandafter\currentconstructionlevel \csname\??constructionlevel\currentconstruction\endcsname - \expandafter\let\expandafter\currentconstructionhandler\csname\??constructionclass\currentconstruction\endcsname - \csname\??constructioninitializer\currentconstructionhandler\endcsname} +\appendtoks + \ifnum\btxsetupmode=\doingrootsetuproot + \publ_specification_set{\btxparameter\c!specification}% + \else\ifnum\btxsetupmode=\doingrootsetupnamed + \publ_specification_set{\btxparameter\c!specification}% + \fi\fi +\to \everysetupbtx \appendtoks - % \ifx\currentbtxlistparent\empty - % \defineconstruction[\currentbtxlist][\currentbtxlistparent][\s!handler=\v!btxlist,\c!level=1]% - % \else - % \defineconstruction[\currentbtxlist][\s!handler=\v!btxlist,\c!level=1]% - % \fi - \ifx\currentbtxlistparent\empty - \letvalue{\??constructionmain\currentbtxlist}\currentbtxlist - \else - \letvalue{\??constructionmain\currentbtxlist}\currentbtxlistparent + \ifnum\btxsetupmode=\doingrootsetuproot + \edef\currentbtxdataset{\clf_btxsetdataset{\btxparameter\c!dataset}{\currentbtxdataset}}% \fi - \setevalue{\??constructionlevel\currentbtxlist}{\number\btxlistparameter\c!level}% - \setevalue{\??constructionclass\currentbtxlist}{\btxlistparameter\s!handler}% -\to \everydefinebtxlist - -\setupbtxlist - [\s!handler=\v!btxlist, - \c!level=1] - -\setupbtxlist - [\c!alternative=\v!left, - \c!headstyle=, - \c!titlestyle=, - %\c!style=, - %\c!color=, - %\c!headcolor=, - %\c!titlecolor=, - \c!width=4\emwidth, - \c!distance=\emwidth, - %\c!titledistance=.5\emwidth, - %\c!hang=, - %\c!sample=, - %\c!align=, - %\c!headalign=, - \c!margin=\v!no, - \c!before=\blank, - \c!inbetween=\blank, - \c!after=\blank, - %\c!indentnext=\v!yes, - %\c!indenting=\v!never, - %\c!titleleft=(, - %\c!titleright=), - %\c!closesymbol=, - %\c!closecommand=\wordright, - \c!display=\v!yes, - \c!command=, - %\c!titlecommand=, - %\c!expansion=\v!no, - %\c!xmlsetup=, - %\s!catcodes=, - %\c!title=\v!yes, - %\c!text=, - ] +\to \everysetupbtx + +\appendtoks + \publ_specification_set{\btxparameter\c!specification}% +\to \everyjob + +\unexpanded\def\startusingbtxspecification[#1]% + {\publ_specification_push{#1}} + +\let\stopusingbtxspecification\publ_specification_pop + +% \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth] +% \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth,margin=2em] % useless +% \setupbtxlist[alternative=paragraph,width=fit,distance=\emwidth] +% \setupbtxlist[alternative=paragraph,width=fit,distance=\emwidth,margin=2em] % here starts the bib stuff \installcorenamespace {btxdataset} -\installcorenamespace {btxlistvariant} -\installcorenamespace {btxcitevariant} \installcorenamespace {btxrendering} +\installcorenamespace {btxregister} \installcorenamespace {btxcommand} -\installcorenamespace {btxnumbering} - -\installcommandhandler \??btxdataset {btxdataset} \??btxdataset -\installcommandhandler \??btxlistvariant {btxlistvariant} \??btxlistvariant -\installcommandhandler \??btxcitevariant {btxcitevariant} \??btxcitevariant -\installcommandhandler \??btxrendering {btxrendering} \??btxrendering +\installcorenamespace {btxrenderingdefinition} + +\installcommandhandler \??btxdataset {btxdataset} \??btxdataset +\installcommandhandler \??btxregister {btxregister} \??btxregister +\installcommandhandler \??btxrendering {btxrendering} \??btxrendering + +\let\currentbtxcitealternative\empty + +\let\currentbtxspecificationfallback\empty + +\unexpanded\def\setbtxparameterset#1#2% + {\edef\currentbtx + {\ifcsname\??btx\currentbtxspecification:#1:#2:\s!parent\endcsname + \currentbtxspecification:% + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:#1:#2:\s!parent\endcsname + \currentbtxspecificationfallback:% + \fi\fi\fi#1:#2}} + +\unexpanded\def\setbtxparametersetroot#1% + {\edef\currentbtx + {\ifcsname\??btx\currentbtxspecification:#1:\s!parent\endcsname + \currentbtxspecification:#1% + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:#1:\s!parent\endcsname + \currentbtxspecificationfallback:#1% + \fi\fi\fi}} + +\unexpanded\def\setbtxrendering + {\edef\currentbtxrendering + {\ifcsname\??btx\currentbtxspecification:\s!parent\endcsname + \currentbtxspecification + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:\s!parent\endcsname + \currentbtxspecificationfallback + \fi\fi\fi}} + +\unexpanded\def\setbtxlist % maybe simplify this one, always list=rendering? + {\edef\currentbtxlist + {\ifcsname\??btx\currentbtxrendering:\s!parent\endcsname + \currentbtxrendering + \else\ifcsname\??btx\currentbtxspecification:\s!parent\endcsname + \currentbtxspecification + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:\s!parent\endcsname + \currentbtxspecificationfallback + \fi\fi\fi\fi}% + \edef\currentlist{\s!btx:\currentbtxlist}} \unexpanded\def\usebtxdataset - {\dodoubleargument\publ_use_dataset} + {\begingroup + \dotripleempty\publ_use_dataset} -\def\publ_use_dataset[#1][#2]% - {\ifsecondargument - \ctxcommand{usebtxdataset("#1","#2")}% - \else - \ctxcommand{usebtxdataset("\v!standard","#1")}% - \fi} +\def\publ_use_dataset[#1][#2][#3]% + {\getdummyparameters[\c!specification=\currentbtxspecification,#3]% + \ifsecondargument + \clf_btxusedataset + specification {\dummyparameter\c!specification}% + dataset {#1}% + filename {#2}% + \relax + \else\iffirstargument + \clf_btxusedataset + specification {\dummyparameter\c!specification}% + dataset {\v!default}% + filename {#1}% + \relax + \fi\fi + \endgroup} \definebtxdataset - [\v!standard] + [\v!default] +% [\c!language=] % nothing set so use current % \usebtxdataset -% [standard] +% [default] % [mybibs.bib] +\let\startpublication\relax +\let\stoppublication \relax + \unexpanded\def\startpublication {\dodoubleempty\publ_set_publication} -\let\stoppublication\relax - \def\publ_set_publication[#1][#2]% {\begingroup \catcode\commentasciicode\othercatcode @@ -215,15 +278,15 @@ \fi\fi{#1}{#2}} \def\publ_set_publication_default#1#2% - {\publ_set_publication_indeed\v!standard{#1}} + {\publ_set_publication_indeed\v!default{#1}} \def\publ_set_publication_checked#1#2% - {\doifassignmentelse{#1} - {\publ_set_publication_indeed\v!standard{#1}} + {\doifelseassignment{#1} + {\publ_set_publication_indeed\v!default{#1}} {\publ_set_publication_indeed{#1}{}}} \def\publ_set_publication_indeed#1#2#3\stoppublication - {\ctxcommand{addbtxentry("#1",\!!bs#2\!!es,\!!bs\detokenize{#3}\!!es)}% + {\clf_btxaddentry{#1}{#2}{\detokenize{#3}}% \endgroup \ignorespaces} @@ -259,29 +322,45 @@ \unexpanded\def\definebtxcommand#1% {body} #1..#n{body} {\setuvalue{\??btxcommand\strippedcsname#1}}% +% tracing + +\installtextracker + {publications.crosslinks} + {\let\btx_trace_list_cross\strc_references_tracer} + {\let\btx_trace_list_cross\gobbletwoarguments} + +\let\btx_trace_list_cross\gobbletwoarguments + % access \let\currentbtxtag \empty -\let\currentbtxdataset\v!standard +\let\currentbtxdataset\v!default -\unexpanded\def\setbtxdataset[#1]% - {\edef\currentbtxdataset{\ctxcommand{setbtxdataset("#1")}}} - -\unexpanded\def\setbtxentry[#1]% - {\edef\currentbtxtag{\ctxcommand{setbtxentry("\currentbtxdataset","#1")}}} +\unexpanded\def\setbtxentry[#1]% or maybe btxsetentry + {\edef\currentbtxtag{\clf_btxsetentry{\currentbtxdataset}{#1}}} % \let\btxsetdataset\setbtxdataset % \let\btxsetentry \setbtxentry -\def\btxfield #1{\ctxcommand{btxfield("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdetail #1{\ctxcommand{btxdetail("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxflush #1{\ctxcommand{btxflush("\currentbtxdataset","\currentbtxtag","#1")}} -%def\btxrendering#1{\ctxcommand{btxrendering("\currentbtxdataset","\currentbtxtag","#1","\btxrenderingparameter\c!interaction")}} -\def\btxdoifelse #1{\ctxcommand{btxdoifelse("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdoif #1{\ctxcommand{btxdoif("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdoifnot #1{\ctxcommand{btxdoifnot("\currentbtxdataset","\currentbtxtag","#1")}} - -\let\btxsetup \directsetup +% todo: no need for the currents as we can keep them at the lua end so we will have +% +% \btxfield : current +% \btxspecificfield : dataset,tag,key + +\def\btxfield #1{\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxdetail #1{\clf_btxdetail {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxflush #1{\clf_btxflush {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxdirect #1{\clf_btxdirect {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxfieldname #1{\clf_btxfieldname {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxfieldtype #1{\clf_btxfieldtype {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxfoundname #1{\clf_btxfoundname {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxfoundtype #1{\clf_btxfoundtype {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxauthorfield#1{\clf_btxauthorfield \currentbtxauthorindex{#1}} +\def\btxdoifelse #1{\clf_btxdoifelse {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxdoif #1{\clf_btxdoif {\currentbtxdataset}{\currentbtxtag}{#1}} +\def\btxdoifnot #1{\clf_btxdoifnot {\currentbtxdataset}{\currentbtxtag}{#1}} + +\let\btxsetup\fastsetup %D How complex will we go? Can we assume that e.g. an apa style will not be mixed %D with another one? I think this assumption is okay. For manuals we might want to @@ -289,93 +368,280 @@ %D Rendering. -\unexpanded\def\btxspace {\removeunwantedspaces\space} -\unexpanded\def\btxperiod {\removeunwantedspaces.\space} -\unexpanded\def\btxcomma {\removeunwantedspaces,\space} -\unexpanded\def\btxlparent {\removeunwantedspaces\space(} -\unexpanded\def\btxrparent {\removeunwantedspaces)\space} -\unexpanded\def\btxlbracket{\removeunwantedspaces\space[} -\unexpanded\def\btxrbracket{\removeunwantedspaces]\space} +\unexpanded\def\btxspace {\removeunwantedspaces\space} +\unexpanded\def\btxnobreakspace {\removeunwantedspaces\nobreakspace} % these two are +\unexpanded\def\btxnbsp {\removeunwantedspaces\nbsp} % the same anyway +\unexpanded\def\btxperiod {\removeunwantedspaces.\space} +\unexpanded\def\btxcomma {\removeunwantedspaces,\space} +\unexpanded\def\btxcolon {\removeunwantedspaces:\space} +\unexpanded\def\btxsemicolon {\removeunwantedspaces;\space} +\unexpanded\def\btxlparent {\removeunwantedspaces\space(} % obsolete +\unexpanded\def\btxrparent {\removeunwantedspaces)\space} % obsolete +\unexpanded\def\btxleftparenthesis {\removeunwantedspaces\space(} +\unexpanded\def\btxrightparenthesis {\removeunwantedspaces)\space} +\unexpanded\def\btxrightparenthesisperiod{\removeunwantedspaces).\space} +\unexpanded\def\btxrightparenthesiscomma {\removeunwantedspaces),\space} +\unexpanded\def\btxleftbracket {\removeunwantedspaces\space[} +\unexpanded\def\btxrightbracket {\removeunwantedspaces]\space} +\unexpanded\def\btxrightbracketperiod {\removeunwantedspaces].\space} +\unexpanded\def\btxrightbracketcomma {\removeunwantedspaces],\space} + +%D Variables: + +\let\currentbtxbacklink \empty \unexpanded\def\btxsetbacklink {\def\currentbtxbacklink} +\let\currentbtxbacktrace \empty \unexpanded\def\btxsetbacktrace {\def\currentbtxbacktrace} +\let\currentbtxcategory \empty \unexpanded\def\btxsetcategory {\def\currentbtxcategory} +\let\currentbtxcombis \empty \unexpanded\def\btxsetcombis {\def\currentbtxcombis} +\let\currentbtxdataset \empty \unexpanded\def\btxsetdataset {\def\currentbtxdataset} +\let\currentbtxfirst \empty \unexpanded\def\btxsetfirst {\def\currentbtxfirst} +\let\currentbtxsecond \empty \unexpanded\def\btxsetsecond {\def\currentbtxsecond} +\let\currentbtxthird \empty \unexpanded\def\btxsetthird {\def\currentbtxthird} +\let\currentbtxinternal \empty \unexpanded\def\btxsetinternal {\def\currentbtxinternal} +\let\currentbtxlefttext \empty \unexpanded\def\btxsetlefttext {\def\currentbtxlefttext} +\let\currentbtxrighttext \empty \unexpanded\def\btxsetrighttext {\def\currentbtxrighttext} +\let\currentbtxbefore \empty \unexpanded\def\btxsetbefore {\def\currentbtxbefore} +\let\currentbtxafter \empty \unexpanded\def\btxsetafter {\def\currentbtxafter} +\let\currentbtxlanguage \empty \unexpanded\def\btxsetlanguage {\def\currentbtxlanguage} +\let\currentbtxtag \empty \unexpanded\def\btxsettag {\def\currentbtxtag} +\let\currentbtxnumber \empty \unexpanded\def\btxsetnumber {\def\currentbtxnumber} +\let\currentbtxauthorvariant\v!normal \unexpanded\def\btxsetauthorvariant{\def\currentbtxauthorvariant} + +\let\currentbtxfirstnames \empty \unexpanded\def\btxsetfirstnames{\let\currentbtxfirstnames\currentbtxfirstnames_indeed} +\let\currentbtxinitials \empty \unexpanded\def\btxsetinitials {\let\currentbtxinitials \currentbtxinitials_indeed } +\let\currentbtxjuniors \empty \unexpanded\def\btxsetjuniors {\let\currentbtxjuniors \currentbtxjuniors_indeed } +\let\currentbtxsurnames \empty \unexpanded\def\btxsetsurnames {\let\currentbtxsurnames \currentbtxsurnames_indeed } +\let\currentbtxvons \empty \unexpanded\def\btxsetvons {\let\currentbtxvons \currentbtxvons_indeed } + +\newconstant\currentbtxoverflow \unexpanded\def\btxsetoverflow #1{\currentbtxoverflow #1\relax} +\newconstant\currentbtxconcat \unexpanded\def\btxsetconcat #1{\currentbtxconcat #1\relax} +\newconstant\currentbtxcount \unexpanded\def\btxsetcount #1{\currentbtxcount #1\relax} +\newconstant\currentbtxauthorindex %unexpanded\def\btxsetauthorindex#1{\currentbtxauthorindex#1\relax} % passed directly +\newconstant\currentbtxauthorcount %unexpanded\def\btxsetauthorcount#1{\currentbtxauthorcount#1\relax} % passed directly +\newconstant\currentbtxauthorstate \unexpanded\def\btxsetauthorstate#1{\currentbtxauthorstate#1\relax} + +\unexpanded\def\currentbtxfirstnames_indeed{\clf_btxcurrentfirstnames\numexpr\currentbtxauthorindex\relax} +\unexpanded\def\currentbtxinitials_indeed {\clf_btxcurrentinitials \numexpr\currentbtxauthorindex\relax} +\unexpanded\def\currentbtxjuniors_indeed {\clf_btxcurrentjuniors \numexpr\currentbtxauthorindex\relax} +\unexpanded\def\currentbtxsurnames_indeed {\clf_btxcurrentsurnames \numexpr\currentbtxauthorindex\relax} +\unexpanded\def\currentbtxvons_indeed {\clf_btxcurrentvons \numexpr\currentbtxauthorindex\relax} + +\def\currentbtxauthorvariant{normal} + +\unexpanded\def\btxlistreset + {\let\currentbtxcombis \empty + \let\currentbtxcategory \empty + \let\currentbtxinternal \empty + \let\currentbtxlefttext \empty + \let\currentbtxrighttext\empty + \let\currentbtxbefore \empty + \let\currentbtxafter \empty + \let\currentbtxbacklink \empty + \let\currentbtxbacktrace\empty + \let\currentbtxlanguage \empty + \let\currentbtxtag \empty + \let\currentbtxnumber \empty + \let\currentbtxdataset \empty} + +\unexpanded\def\btxcitereset % check for less .. not all resets needed + {\let \currentbtxfirst \empty + \let \currentbtxsecond \empty + \let \currentbtxinternal \empty + \let \currentbtxlefttext \empty + \let \currentbtxrighttext \empty + \let \currentbtxbefore \empty + \let \currentbtxafter \empty + \let \currentbtxbacklink \empty + \let \currentbtxbacktrace \empty % not used here + \let \currentbtxlanguage \empty + \let \currentbtxdataset \empty + \let \currentbtxtag \empty + \let \currentbtxnumber \empty + \setconstant\currentbtxoverflow \zerocount + \setconstant\currentbtxconcat \zerocount + \setconstant\currentbtxcount \zerocount} + +%D Language: + +\def\mainbtxlanguage{\currentmainlanguage} + +\unexpanded\def\btx_check_language + {\let\mainbtxlanguage\currentlanguage + \ifx\currentbtxlanguage\empty + \let\currentbtxlanguage\currentlanguage + \else + \btx_check_language_indeed + \fi} -%D Rendering lists and citations. +\unexpanded\def\btx_check_language_indeed + {\edef\currentbtxlanguage{\reallanguagetag\currentbtxlanguage}% + \ifx\currentbtxlanguage\empty + \let\currentbtxlanguage\currentlanguage + \else\ifx\currentbtxlanguage\currentlanguage\else + \setcurrentlanguage\currentmainlanguage\currentbtxlanguage + \fi\fi} + +%D Tracing -\newconditional\c_btx_trace +\newconditional\c_btx_trace % not used yet \installtextracker {btxrendering} {\settrue \c_btx_trace} {\setfalse\c_btx_trace} -\unexpanded\def\startbtxrendering - {\begingroup - \dosingleempty\btx_start_rendering} - -\def\btx_start_rendering[#1]% - {\edef\currentbtxrendering{#1}} - -\unexpanded\def\stopbtxrendering - {\endgroup} +%D Rendering lists and citations. \unexpanded\def\btxtodo#1% {[#1]} -%D Specific rendering definitions (like apa): - -\unexpanded\def\loadbtxdefinitionfile[#1]% - {\ctxcommand{loadbtxdefinitionfile("#1")}} - %D Lists: \newdimen\d_publ_number_width %newdimen\d_publ_number_distance \ifdefined\btxblock \else \newcount\btxblock \fi \btxblock\plusone -\ifdefined\btxlistcounter \else \newcount\btxlistcounter \fi -\ifdefined\btxcitecounter \else \newcount\btxcitecounter \fi +\ifdefined\btxcitecounter \else \newcount\btxcitecounter \fi % maybe pass this to lua \newtoks \everysetupbtxlistplacement % name will change \newtoks \everysetupbtxciteplacement % name will change -% \def\publ_list_processor % bibref -> btx (old method, keep as reference) -% {\ctxcommand{btxaddtolist("\currentbtxrendering",\currentlistindex,"btxref")}} - \definelist % only used for selecting [\s!btx] \setuplist - [\s!btx]% - [\c!state=\v!start]% + [\s!btx] + [\c!prefixstopper=:, + \c!state=\v!start, + \c!alternative=\v!paragraph, + \c!before=\blank, + \c!after=\blank, + \c!width=\v!auto, + \c!distance=\emwidth] + +\unexpanded\def\setupbtxlist + {\dodoubleempty\publ_setup_list} + +\unexpanded\def\publ_setup_list[#1][#2]% + {\ifsecondargument + \setuplist[\s!btx:#1][#2]% + \else\iffirstargument + \setuplist[\s!btx][#1]% + \fi\fi} \appendtoks \ifx\currentbtxrenderingparent\empty - \definebtxlist - [\currentbtxrendering]% + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx]% + \else\ifx\currentbtxrenderingparent\s!btx + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx]% \else - \definebtxlist - [\currentbtxrendering]% - [\currentbtxrenderingparent]% - \fi + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx:\currentbtxrenderingparent]% + \fi\fi \to \everydefinebtxrendering -\let\currentbtxcombis\empty % goes into the setups +\newconditional\c_btx_list_texts + +\appendtoks + \doifelse{\btxrenderingparameter\c!textstate}\v!start + \settrue\setfalse\c_btx_list_texts +\to \everysetupbtxlistplacement + +% page stuff (for thomas) + +\let\currentbtxfirstpage \empty \unexpanded\def\btxsetfirstpage #1{\def\currentbtxfirstpage{\btx_page_number{#1}}} +\let\currentbtxlastpage \empty \unexpanded\def\btxsetlastpage #1{\def\currentbtxlastpage {\btx_page_number{#1}}} +\let\currentbtxfirstinternal\empty \unexpanded\def\btxsetfirstinternal {\def\currentbtxfirstinternal} +\let\currentbtxlastinternal \empty \unexpanded\def\btxsetlastinternal {\def\currentbtxlastinternal} + +\unexpanded\def\btx_page_number#1% + {\def\currentlistindex{#1}% + \structurelistpagenumber} + +\unexpanded\def\btxpagereset + {\let \currentbtxfirstpage \empty + \let \currentbtxlastpage \empty + \let \currentbtxfirstinternal\empty + \let \currentbtxlastinternal \empty + \setconstant\currentbtxoverflow \zerocount + \setconstant\currentbtxconcat \zerocount + \setconstant\currentbtxcount \zerocount} + +\newconditional\c_btx_list_pages + +\appendtoks + \doifelse{\btxrenderingparameter\c!pagestate}\v!start + \settrue\setfalse\c_btx_list_pages +\to \everysetupbtxlistplacement + +\unexpanded\def\btx_entry_inject_pages % for the moment only normal + {\dontleavehmode + \begingroup + \setbtxlist % probably already set + \btxpagereset + \setbtxparameterset\s!page\s!list + \btxparameter\c!command + {\usebtxstyleandcolor\c!style\c!color + \btxparameter\c!pageleft + \clf_btxflushpages{\currentbtxdataset}{\currentbtxtag}% + \btxparameter\c!pageright}% + \endgroup} + +\unexpanded\def\btxpagesetup + {\btxsetuptype\plusfour + \fastbtxsetup\s!page\s!list + \btxpagereset} + +% end of page stuff \unexpanded\def\btx_entry_inject {\begingroup \edef\currentbtxcategory{\btxfield{category}}% \ignorespaces - \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}% + \ifconditional\c_btx_list_texts + \currentbtxbefore + \fi + \begingroup + \usebtxstyleandcolor\c!style\c!color + \ignorespaces + \btxsetuptype\plusthree + \fastbtxsetup\s!list\currentbtxcategory \removeunwantedspaces + \endgroup + \ifconditional\c_btx_list_pages + \btx_entry_inject_pages + \fi \ifx\currentbtxcombis\empty \else \btxrenderingparameter\c!separator \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi \fi + \ifconditional\c_btx_list_texts + \currentbtxafter + \fi \endgroup} +\unexpanded\def\btxshowentryinline + {\dodoubleempty\btx_entry_show_inline} + +\unexpanded\def\btx_entry_show_inline[#1][#2]% + {\ifsecondargument + \ctxcommand{showbtxentry("#1","#2")} + \else\iffirstargument + \ctxcommand{showbtxentry("\currentbtxdataset","#1")} + \else + \ctxcommand{showbtxentry("\currentbtxdataset","\currentbtxtag")} + \fi\fi} + \def\btx_entry_inject_combi#1% {\begingroup \def\currentbtxtag{#1}% \ignorespaces - \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}% + \btxsetuptype\plusthree + \fastbtxsetup\s!list\currentbtxcategory \removeunwantedspaces \endgroup} @@ -385,183 +651,329 @@ \let\completelistofpublications\completebtxrendering \let\placelistofpublications \placebtxrendering -\def\publ_place_list_check_criterium - {\edef\currentbtxcriterium{\btxrenderingparameter\c!criterium}% \v!cite will become \s!cite - \ifx\currentbtxcriterium\empty - \let\currentbtxcriterium\v!previous - \else\ifx\currentbtxcriterium\v!cite - \let\currentbtxcriterium\v!here - \fi\fi} +\newtoks\everybtxlistrendering -\def\publ_place_list_complete[#1][#2]% title might become obsolete, just headtext - {\begingroup - \edef\currentbtxrendering{#1}% - \setupcurrentbtxrendering[#2]% - \let\currentlist\s!btx - \let\currentbtxlist\currentbtxrendering - \publ_place_list_check_criterium - \edef\currentbtxrenderingtitle{\btxrenderingparameter\c!title}% - \ifx\currentbtxrenderingtitle\empty - \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\headtext{\currentbtxrendering}}]}% - \else - \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\currentbtxrenderingtitle}]}% - \fi - \publ_place_list_indeed - \stopnamedsection - \endgroup} +\appendtoks + \setbtxlist + % + \edef\currentbtxcriterium{\btxrenderingparameter\c!criterium}% \v!cite will become \s!cite + \ifx\currentbtxcriterium\empty + \let\currentbtxcriterium\v!previous + \else\ifx\currentbtxcriterium\v!cite + \let\currentbtxcriterium\v!here + \fi\fi + % + \iflocation + \letinteractionparameter\c!style\empty + \fi +\to \everybtxlistrendering -\def\publ_place_list_standard[#1][#2]% - {\begingroup - \edef\currentbtxrendering{#1}% - \setupcurrentbtxrendering[#2]% - \let\currentlist\s!btx - \let\currentbtxlist\currentbtxrendering - \publ_place_list_check_criterium - \publ_place_list_indeed - \endgroup} +\def\nofbtxlistentries {0} +\def\currentbtxlistentry{0} +\def\currentbtxlistindex{0} % only for internal use (points back to big list) -\newconditional\c_publ_place_all -\newconditional\c_publ_place_register % to be interfaced -\newconditional\c_publ_place_check % to be interfaced +\newconditional\c_publ_prefixed -\appendtoks - \ifx\currentbtxcriterium\v!all % move this check to lua ... easier to test there anyway - \settrue\c_publ_place_all +\unexpanded\def\btxsetnoflistentries #1{\edef\nofbtxlistentries {#1}} +\unexpanded\def\btxsetcurrentlistentry#1{\edef\currentbtxlistentry{#1}} +\unexpanded\def\btxsetcurrentlistindex#1{\edef\currentbtxlistindex{#1}} + +\unexpanded\def\btxdoifelsesameaspreviouschecked#1#2% #1 == always | doublesided + {\clf_btxdoifelsesameasprevious + {\currentbtxdataset}% + \currentbtxlistentry% + {#2}% + \c_btx_list_reference + {#1}} + +\unexpanded\def\btxdoifelsesameasprevious + {\btxdoifelsesameaspreviouschecked\v!doublesided} + +\let\btxdoifsameaspreviouscheckedelse\btxdoifelsesameaspreviouschecked +\let\btxdoifsameaspreviouselse \btxdoifelsesameasprevious + +\def\publ_place_list_indeed#1[#2][#3]% + {\begingroup + \ifsecondargument + % [rendering] [settings] + \edef\currentbtxrendering{#2}% + \setupcurrentbtxrendering[#3]% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \fi + \else\iffirstargument + \doifelseassignment{#2} + {% [settings] + \let\currentbtxrendering\currentbtxspecification + \setupcurrentbtxrendering[#2]% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \let\currentbtxrendering\currentbtxspecification % tricky + \fi} + {\edef\currentbtxrendering{#2}% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \fi}% \else - \setfalse\c_publ_place_all + \let\currentbtxrendering\currentbtxspecification + \fi\fi + \setbtxparameterset\currentbtxspecification\s!list + \the\everybtxlistrendering + \ifconditional#1\relax + \edef\currentbtxrenderingtitle{\btxrenderingparameter\c!title}% + \ifx\currentbtxrenderingtitle\empty + \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\headtext{\currentbtxrendering}}]}% + \else + \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\currentbtxrenderingtitle}]}% + \fi \fi -\to \everysetupbtxlistplacement - -\def\publ_place_list_indeed - {\startbtxrendering[\currentbtxrendering]% - \directsetup{\btxrenderingparameter\c!setups}% - % \determinelistcharacteristics[\currentbtxrendering]% - \edef\currentbtxalternative{\btxrenderingparameter\c!alternative}% - \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% - \let\currentlist\s!btx - \let\currentbtxlist\currentbtxrendering - \the\everysetupbtxlistplacement - \forgetall - \ctxcommand{btxsetlistmethod("\currentbtxdataset","\btxrenderingparameter\c!method")}% + \ifx\currentbtxrendering\empty + \setbtxrendering % hm + \fi + \btxrenderingparameter\c!before + \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% + \uselanguageparameter\btxdatasetparameter % new + \setbtxlist + \the\everystructurelist + \the\everysetupbtxlistplacement + \forgetall + % why not pass this with collect .. todo + % here we just collect items + \clf_btxcollectlistentries + names {\s!btx}% + criterium {\currentbtxcriterium}% + reference {\btxrenderingparameter\c!reference}% + method {\btxrenderingparameter\c!method}% + dataset {\currentbtxdataset}% + keyword {\btxrenderingparameter\c!keyword}% + sorttype {\btxrenderingparameter\c!sorttype}% + repeated {\btxrenderingparameter\c!repeat}% + ignored {\btxrenderingparameter\c!ignore}% + group {\btxrenderingparameter\c!group}% + \relax + \ifnum\nofbtxlistentries>\zerocount \startpacked[\v!blank]% - % here we just collect items - \ctxcommand{btxcollectlistentries { - names = "btx", - criterium = "\currentbtxcriterium", - number = "\btxrenderingparameter\c!number", - btxdataset = "\currentbtxdataset", - keyword = "\btxrenderingparameter\c!keyword", - }}% - % next we analyze the width - \ifx\btx_list_reference_inject_indeed\relax - \else - \edef\p_width{\btxrenderingparameter\c!width}% - \ifx\p_width\v!auto - \scratchcounter\btxlistcounter - \setbox\scratchbox\vbox{\settrialtypesetting\ctxcommand{btxfetchlistentries("\currentbtxdataset")}}% - \d_publ_number_width\wd\scratchbox - \global\btxlistcounter\scratchcounter - \letbtxlistparameter\c!width\d_publ_number_width - \fi + % sorting and so + \clf_btxpreparelistentries{\currentbtxdataset}% could be put in collect + % next we analyze the width + \ifx\currentbtxnumbering\empty \else + \edef\p_width{\listparameter\c!width}% + \ifx\p_width\v!auto + \setbox\scratchbox\vbox \bgroup + \settrialtypesetting + \clf_btxfetchlistentries{\currentbtxdataset}% + \egroup + \d_publ_number_width\wd\scratchbox + \letlistparameter\c!width\d_publ_number_width \fi - % this actually typesets them - \ctxcommand{btxflushlistentries("\currentbtxdataset","\btxrenderingparameter\c!sorttype")}% + \fi + \doifelse{\listparameter\c!prefix}\v!yes\settrue\setfalse\c_publ_prefixed + % this actually typesets them, we loop here as otherwise the whole + % bunch gets flushed at once + \dorecurse\nofbtxlistentries + {\let\currentbtxlistentry\recurselevel + \clf_btxflushlistentry{\currentbtxdataset}\currentbtxlistentry\relax}% \stoppacked - \stopbtxrendering - \global\advance\btxblock\plusone} + \fi + \btxrenderingparameter\c!after + \global\advance\btxblock\plusone + \ifconditional#1\relax + \stopnamedsection + \fi + \endgroup} -\def\currentbtxblock{\number\btxblock} +\def\publ_place_list_complete{\publ_place_list_indeed\conditionaltrue} +\def\publ_place_list_standard{\publ_place_list_indeed\conditionalfalse} -\def\publ_place_list_entry_checked - {\ctxcommand{btxdoifelselistentryplaced("\currentbtxdataset","\currentbtxtag")}\donothing\publ_place_list_entry} +\def\currentbtxblock{\number\btxblock} -\def\publ_place_list_entry_register - {\ctxcommand{btxregisterlistentry("\currentbtxdataset","\currentbtxtag")}} +% called at the lua end, for determining the width -\unexpanded\def\btxhandlelistentry#1% called at the lua end +\unexpanded\def\btxchecklistentry {\begingroup - \edef\currentbtxtag{#1}% - \ifconditional\c_publ_place_all - \publ_place_list_entry - \else\ifconditional\c_publ_place_check - \publ_place_list_entry_checked - \else - \publ_place_list_entry - \fi\fi + % todo, switch to font + \hbox{\btx_reference_checked}% + \par \endgroup} -\unexpanded\def\publ_place_list_entry - {\global\advance\btxlistcounter\plusone - \ifconditional\c_publ_place_register - \publ_place_list_entry_register - \fi - \let\currentlist\s!btx - \startbtxlistentry\currentbtxrendering - \btx_entry_inject - \stopbtxlistentry} +% called at the lua end, the real rendering + +% we could have a yes and no where o nils the btx_reference_indeed ... saves a check there + +\installstructurelistprocessor{\s!btx} + {\let\currentlistentrynumber \btx_reference_indeed + \let\currentlistentrytitle \btx_entry_indeed + \let\currentlistentrypagenumber\btx_page_indeed + \strc_lists_apply_renderingsetup} + +\def\btx_entry_indeed + {\btx_list_reference_inject + \btx_entry_inject} -\unexpanded\def\btxchecklistentry#1% called at the lua end +\def\btx_page_indeed + {} + +\unexpanded\def\btxhandlelistentry + {\strc_lists_entry_process} + +\unexpanded\def\btxstartlistentry % maybe pass i {\begingroup - \edef\currentbtxtag{#1}% - \ifx\currentbtxcriterium\v!all % move this check to lua ... easier to test there anyway - \publ_check_list_entry - \else - \ctxcommand{btxdoifelselistentryplaced("\currentbtxdataset","\currentbtxtag")}\donothing\publ_check_list_entry + \global\advance\c_btx_list_reference\plusone} + +\unexpanded\def\btxstoplistentry + {\iftrialtypesetting + \global\advance\c_btx_list_reference\minusone \fi \endgroup} -\unexpanded\def\publ_check_list_entry - {\global\advance\btxlistcounter\plusone - % todo, switch to font - \hbox{\btx_reference_checked}% - \par} +\newtoks\everybtxlistentry -\unexpanded\def\btx_list_reference_inject % we can use a faster \reference - {\dontleavehmode\begingroup % no box - \iftrialtypesetting\else - \ctxcommand{btxlistreference("\currentbtxdataset","\currentbtxblock","\currentbtxtag","\number\btxlistcounter")}% - \fi - \btx_list_reference_inject_indeed +\unexpanded\def\btxlistsetup#1% used for the reference in the list + {\the\everybtxlistentry + \everybtxlistentry\emptytoks % so only once per entry to be sure + \btxsetuptype\plusthree + \fastbtxsetup\s!list{#1}} + +\appendtoks + \btx_check_language +\to \everybtxlistentry + +\unexpanded\def\btx_reference_indeed + {\begingroup + %let\currentbtxlistvariant\currentbtxnumbering + \setbtxparameterset\c!list\currentbtxnumbering + \ifx\currentbtxnumbering\empty + % nothing + \else\ifx\currentbtxnumbering\v!no + % nothing + \else + \usebtxstyleandcolor\c!style\c!color % new, needed? + % \btxparameter\c!left + \ifconditional\c_publ_prefixed\btxlistprefixednumber\fi + \clf_btxlistvariant % some can go + {\currentbtxdataset}% + {\currentbtxblock}% + {\currentbtxtag}% + {\currentbtxnumbering}% + {\currentbtxnumber}% + \relax + % \btxparameter\c!right + \fi\fi \endgroup} +\unexpanded\def\btxlistprefixednumber % hack but alan needs it + {\clf_listprefixednumber + {\currentlist}% + \currentbtxlistindex + {% + prefix {\listparameter\c!prefix}% + separatorset {\listparameter\c!prefixseparatorset}% + conversionset {\listparameter\c!prefixconversionset}% + starter {\listparameter\c!prefixstarter}% + stopper {\listparameter\c!prefixstopper}% + set {\listparameter\c!prefixset}% + segments {\listparameter\c!prefixsegments}% + connector {\listparameter\c!prefixconnector}% + }% + \relax} + \unexpanded\def\btx_reference_checked {\dontleavehmode\hbox\bgroup - \btx_list_reference_inject_indeed + \btx_reference_indeed \egroup} -\unexpanded\def\btx_cite_reference_inject % todo: wrap whole content? +\newcount\c_btx_list_reference + +\unexpanded\def\btx_list_reference_inject {\dontleavehmode\begingroup % no box \iftrialtypesetting\else -% \ifx\currentbtxinternal\empty\else - % \global\advance\btxcitecounter\plusone - \ctxcommand{btxcitereference(\number\currentbtxinternal)}% -% \fi + \btx_list_reference_inject_now \fi - % \btx_list_reference_inject_indeed + % \btx_reference_indeed % else double entry in list \endgroup} +\def\btx_list_reference_inject_now + {\btx_trace_list_cross\empty\currentbtxbacktrace + \strc_references_direct_full_user + {\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% + \s!btxref=\currentbtxtag,% + \s!btxspc=\currentbtxspecification,% + \s!btxlst=\number\c_btx_list_reference,% check if needed + \ifx\currentbtxbefore\empty\else\s!btxbtx={\currentbtxbefore},\fi% + \ifx\currentbtxafter \empty\else\s!btxatx={\currentbtxafter },\fi% + \ifx\currentbtxbacklink\currentbtxbacktrace\s!btxint=\currentbtxbacklink\else\s!btxbck=\currentbtxbacktrace\fi}% + {\s!btx::\v!list::\number\c_btx_list_reference}% + {\currentbtxnumber}} + +\newconditional\c_btx_cite_reference_injected + +\unexpanded\def\btx_cite_reference_inject + {\ifconditional\c_btx_cite_reference_injected + \else + \dontleavehmode + \iftrialtypesetting \else + \ifx\currentbtxbacklink\empty + % can be made empty when combining author / year + \else + \btx_cite_reference_inject_indeed + \settrue\c_btx_cite_reference_injected + \fi + \fi + \fi} + +\newtoks\t_btx_reference_inject + +% \def\btx_cite_reference_inject_indeed +% {\btx_trace_list_cross\currentbtxbacklink\empty +% \the\t_btx_reference_inject +% \normalexpanded{\writedatatolist % can be done faster .. just merge code here (not much) / also type btx +% [\s!btx]% +% [\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% +% \s!btxref=\currentbtxtag,% +% \ifx\currentbtxbefore\empty\else\s!btxbtx=\!!bs\currentbtxbefore\!!es,\fi% +% \ifx\currentbtxafter \empty\else\s!btxatx=\!!bs\currentbtxafter \!!es,\fi% +% \s!btxint=\number\currentbtxbacklink +% \ifx\currentbtxciteuservariables\empty\else,\currentbtxciteuservariables\fi]}} + +\def\btx_cite_reference_inject_indeed + {\btx_trace_list_cross\currentbtxbacklink\empty + \the\t_btx_reference_inject + \strc_lists_inject_direct % todo: make like \btx_list_reference_inject_now with { } + [\s!btx]% + [\c!type=\s!btx]% \c!location=\v!none + [\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% + \s!btxref=\currentbtxtag,% + \ifx\currentbtxbefore\empty\else\s!btxbtx=\!!bs\currentbtxbefore\!!es,\fi% + \ifx\currentbtxafter \empty\else\s!btxatx=\!!bs\currentbtxafter \!!es,\fi% + \s!btxint=\number\currentbtxbacklink + \ifx\currentbtxciteuservariables\empty\else,\currentbtxciteuservariables\fi]} + +\def\currentbtxuservariable #1{\clf_btxuservariable {\currentbtxdataset}{#1}} +\def\btxdoifelseuservariable#1{\clf_btxdoifelseuservariable{\currentbtxdataset}{#1}} + +\let\btxdoifuservariableelse\btxdoifelseuservariable + \let\btxcitereference\btx_cite_reference_inject -\setuvalue{\??btxnumbering\v!short }{\btxlistvariant{short}} % these will be setups -\setuvalue{\??btxnumbering\v!bib }{\btxlistvariant{num}} % these will be setups -\setuvalue{\??btxnumbering\s!unknown}{\btxlistvariant{num}} % these will be setups -\setuvalue{\??btxnumbering\v!yes }{\btxlistvariant{num}} % these will be setups +\let\currentbtxnumbering\empty \appendtoks - \edef\p_btx_numbering{\btxrenderingparameter\c!numbering}% - \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed - \ifx\p_btx_numbering\v!no - \letlistparameter\c!textcommand\outdented % needed? we can use titlealign - \letlistparameter\c!symbol \v!none - \letlistparameter\c!aligntitle \v!yes - \let\btx_list_reference_inject_indeed\relax - \else - \ifcsname\??btxnumbering\p_btx_numbering\endcsname \else - \let\p_btx_numbering\s!unknown - \fi - \letlistparameter\c!headnumber\v!always - \expandafter\let\expandafter\btx_list_reference_inject_indeed\csname\??btxnumbering\p_btx_numbering\endcsname - \fi + \edef\currentbtxnumbering{\btxrenderingparameter\c!numbering}% + \edef\p_numbering{\btxrenderingparameter\c!numbering}% link to headnumber + \ifx\p_numbering\v!no + \letlistparameter\c!headnumber\v!no + \let\currentbtxnumbering\empty + % \letlistparameter\c!textcommand\outdented % needed? we can use titlealign + \letlistparameter\c!symbol \v!none + \letlistparameter\c!aligntitle \v!yes + \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed + \else + \letlistparameter\c!headnumber\v!always + \fi + \let\currentlistmethod\s!btx \to \everysetupbtxlistplacement % \appendtoks @@ -569,135 +981,139 @@ % \to \everysetupbtxlistplacement \unexpanded\def\btxflushauthor - {\doifnextoptionalcselse\btx_flush_author_yes\btx_flush_author_nop} + {\doifelsenextoptionalcs\btx_flush_author_yes\btx_flush_author_nop} \def\btx_flush_author_yes[#1]{\btx_flush_author{#1}} -\def\btx_flush_author_nop {\btx_flush_author{\btxlistvariantparameter\c!author}} +\def\btx_flush_author_nop {\btx_flush_author{\btxparameter\c!authorconversion}} \unexpanded\def\btx_flush_author#1#2% - {\edef\currentbtxfield{#2}% - \let\currentbtxlistvariant\currentbtxfield - \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","\currentbtxfield",{ - combiner = "#1", - etallimit = \number\btxlistvariantparameter\c!etallimit, - etaldisplay = \number\btxlistvariantparameter\c!etaldisplay, - })}} + {\begingroup + \edef\currentbtxfield{#2}% + \setbtxparameterset\s!list\currentbtxfield + %let\currentbtxlistvariant\currentbtxfield + \clf_btxauthor + {\currentbtxdataset}% + {\currentbtxtag}% + {\currentbtxfield}% + {% + combiner {#1}% + kind {list}% + etallimit {\btxparameter\c!etallimit}% + etaldisplay {\btxparameter\c!etaldisplay}% + symbol {\btxparameter{\c!stopper:initials}}% + }% + \relax + \endgroup} + +% yes or no: maybe just \flushauthor{...}{...} +\unexpanded\def\btxflushauthorname {\btx_flush_author{name}} % #1 \unexpanded\def\btxflushauthornormal {\btx_flush_author{normal}} % #1 \unexpanded\def\btxflushauthornormalshort {\btx_flush_author{normalshort}} % #1 \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, - })}} + {\begingroup + \setbtxparameterset\s!cite\s!author + \clf_btxauthor + {\currentbtxdataset}% + {\currentbtxtag}% + {\s!author}% + {% + combiner {\btxparameter\c!authorconversion}% + kind {cite}% + etallimit {\btxparameter\c!etallimit}% + etaldisplay {\btxparameter\c!etaldisplay}% + symbol {\btxparameter{\c!stopper:initials}}% + }% + \relax + \endgroup} + +\unexpanded\def\btxstartauthor#1#2#3% a state > 0 signals that some authors can clash + {\begingroup + \currentbtxauthorindex#1\relax + \currentbtxauthorcount#2\relax + \currentbtxauthorstate#3\relax} + +\unexpanded\def\btxstopauthor + {\endgroup} + +\unexpanded\def\btxciteauthorsetup#1{\fastsetup{\s!btx:\s!cite:\s!author:#1}} +\unexpanded\def\btxlistauthorsetup#1{\fastsetup{\s!btx:\s!list:\s!author:#1}} % \btxflushauthor{author} -% \btxflushauthor{artauthor} % \btxflushauthor{editor} % +% \btxflushauthor[name]{author} % \btxflushauthor[normal]{author} % \btxflushauthor[normalshort]{author} % \btxflushauthor[inverted]{author} % \btxflushauthor[invertedshort]{author} -% Interaction: only list +% \btxflushauthor{author} +% \btxflushauthor{editor} +% +% \btxflushauthor[name]{author} +% \btxflushauthor[normal]{author} +% \btxflushauthor[normalshort]{author} +% \btxflushauthor[inverted]{author} +% \btxflushauthor[invertedshort]{author} + +% Interaction \newconditional\btxinteractive +\newconditional\btx_interactive -\unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments} +% of maybe modes? \appendtoks \iflocation - \edef\p_interaction{\btxlistvariantparameter\c!interaction}% + \edef\p_interaction{\btxparameter\c!interaction}% \ifx\p_interaction\v!stop - \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \else - \let\btxdoifelseinteraction\firstoftwoarguments \settrue\btxinteractive + \ifx\p_interaction\v!all + \settrue\btx_interactive + \else + \setfalse\btx_interactive + \fi \fi \else - \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive + \setfalse\btx_interactive \fi \to \everysetupbtxlistplacement \appendtoks \iflocation - \edef\p_interaction{\btxcitevariantparameter\c!interaction}% + \edef\p_interaction{\btxparameter\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 +% till here -\unexpanded\def\btxgotolink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}} -\unexpanded\def\btxatlink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\at [\bibrefprefix#1]}{#1}} -\unexpanded\def\btxinlink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\expanded{\goto{\currentreferencetext}}[\bibrefprefix#1]}{#1}} - -\unexpanded\def\btxdirectlink#1#2{\goto{#2 {\tttf[#1]}}[#1]} -\unexpanded\def\btxdirectlink#1#2{\goto{#2}[#1]} - -\let\gotobiblink\btxgotolink -\let\atbiblink \btxatlink -\let\inbiblink \btxinlink - -\unexpanded\def\btxnumberedreference[#1]% \bibtexnumref (replaced by \cite[num]) - {\dontleavehmode - \begingroup - \btxcitevariantparameter\v!left - \penalty\plustenthousand % todo - \ctxcommand{btxresolvelistreference("\currentbtxdataset","#1")}% todo: split dataset from #1, so another call - \btxcitevariantparameter\v!right - \endgroup} - -\appendtoks - % for old times sake, for a while at least - \let\maybeyear\gobbleoneargument - \let\noopsort \gobbleoneargument -\to \everysetupbtxlistplacement - -\appendtoks - % for old times sake, for a while at least - \let\maybeyear\gobbleoneargument - \let\noopsort \gobbleoneargument -\to \everysetupbtxciteplacement - -\appendtoks - \doifnot{\btxrenderingparameter\c!continue}\v!yes - {\global\btxlistcounter\zerocount}% -\to \everysetupbtxlistplacement +% \unexpanded\def\btxnumberedreference[#1]% \bibtexnumref (replaced by \cite[num]) +% {\dontleavehmode +% \begingroup +% \btxparameter\v!left +% \penalty\plustenthousand % todo +% \clf_btxresolvelistreference{\currentbtxdataset}{#1}% todo: split dataset from #1, so another call +% \btxparameter\v!right +% \endgroup} %D When a publication is cited, we need to signal that somehow. This is done with the %D following (not user) command. We could tag without injecting a node but this way %D we also store the location, which makes it possible to ask local lists. -\newconditional\c_publ_cite_write - -\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 @@ -716,98 +1132,120 @@ % [base::tags] % [settings|variant][base::tags] -\unexpanded\def\btxcite +% these need to be sort of protected: + +\let\p_publ_cite_before \empty +\let\p_publ_cite_after \empty +\let\p_publ_cite_lefttext \empty +\let\p_publ_cite_righttext\empty + +\let\currentbtxciteuservariables\empty + +\unexpanded\def\btxhybridcite % so one can alias the old {\dontleavehmode \begingroup - \strictdoifnextoptionalelse\publ_cite_tags_options\publ_cite_tags_indeed} + \strictdoifelsenextoptional\publ_cite_tags_options\publ_cite_tags_indeed} + +\unexpanded\def\publ_cite_tags_options[#1]% + {\strictdoifelsenextoptional{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}} \unexpanded\def\publ_cite_tags_indeed#1% {\letinteractionparameter\c!style\empty - \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% + \setbtxparametersetroot\s!cite % we need to get the default + \edef\currentbtxcitealternative{\btxparameter\c!alternative}% + \setbtxparameterset\s!cite\currentbtxcitealternative \edef\currentbtxcitetag{#1}% \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} -\let\publ_citation_tags_indeed\publ_cite_tags_indeed +\unexpanded\def\publ_cite_tags_options_indeed#1% + {\doifelseassignment{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}} -\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\publ_cite_tags_variants_indeed{#1}} - -\def\publ_cite_tags_settings_indeed#1% +\def\publ_cite_tags_settings_indeed#1[#2]% {\letinteractionparameter\c!style\empty %\letinteractionparameter\c!color\empty + \letdummyparameter\c!reference \empty + \letdummyparameter\c!alternative\empty \letdummyparameter\c!before \empty \letdummyparameter\c!after \empty - \letdummyparameter\c!extras \empty - \letdummyparameter\c!alternative\empty + \letdummyparameter\c!lefttext \empty + \letdummyparameter\c!righttext \empty \getdummyparameters[#1]% + \edef\p_reference{\dummyparameter\c!reference}% + \ifx\p_reference\empty + \edef\currentbtxcitetag{#2}% + \else + \let\currentbtxcitetag\p_reference + \edef\currentbtxciteuservariables{#2}% + \fi \edef\p_alternative{\dummyparameter\c!alternative}% \ifx\p_alternative\empty - \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% + \setbtxparametersetroot\s!cite + \edef\currentbtxcitealternative{\btxparameter\c!alternative}% \else - \let\currentbtxcitevariant\p_alternative + \let\currentbtxcitealternative\p_alternative \fi - \setupcurrentbtxcitevariant[#1]% - \edef\p_extras{\dummyparameter\c!extras}% - \ifx\p_extras\empty \else - \edef\p_right{\btxcitevariantparameter\c!right}% - \ifx\p_right\empty \else - \setexpandedbtxcitevariantparameter\p_right{\p_extras\p_right}% - \fi - \fi - \edef\p_before{\dummyparameter\c!before}% - \edef\p_after {\dummyparameter\c!after}% + \setbtxparameterset\s!cite\currentbtxcitealternative + \setupcurrentbtx[#1]% + % + \edef\p_publ_cite_before {\dummyparameter\c!before}% + \edef\p_publ_cite_after {\dummyparameter\c!after}% + \edef\p_publ_cite_lefttext {\dummyparameter\c!lefttext}% + \edef\p_publ_cite_righttext{\dummyparameter\c!righttext}% + % \the\everysetupbtxciteplacement - \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% +\def\publ_cite_tags_variants_indeed#1[#2]% {\letinteractionparameter\c!style\empty - \edef\currentbtxcitevariant{#1}% + \edef\currentbtxcitealternative{#1}% + \edef\currentbtxcitetag{#2}% + \setbtxparameterset\s!cite\currentbtxcitealternative \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} \newconditional\btxcitecompress +\let\currentbtxreference\empty + \def\publ_cite_variant {\begingroup - \settrue\c_publ_cite_write \publ_cite_handle_variant_indeed[\currentbtxcitetag]} \unexpanded\def\publ_cite_handle_variant#1% {\begingroup - \edef\currentbtxcitevariant{#1}% + \edef\currentbtxcitealternative{#1}% + \setbtxparameterset\s!cite\currentbtxcitealternative \the\everysetupbtxciteplacement \dosingleargument\publ_cite_handle_variant_indeed} +\unexpanded\def\publ_cite_handle_variant_blob + {%\btxparameter\v!left\relax + \clf_btxhandlecite + dataset {\currentbtxdataset}% + reference {\currentbtxreference}% + markentry \iftrialtypesetting\s!false\else\s!true\fi\space + variant {\currentbtxcitealternative}% + sorttype {\btxparameter\c!sorttype}% + compress {\btxparameter\c!compress}% + author {\btxparameter\c!author}% + lefttext {\p_publ_cite_lefttext}% + righttext {\p_publ_cite_righttext}% + before {\p_publ_cite_before}% + after {\p_publ_cite_after}% + \relax + \clf_btxflushmarked % maybe: \iftrialtypesetting\else ... \fi + }%\btxparameter\v!right\relax} + \def\publ_cite_handle_variant_indeed[#1]% - {\usebtxcitevariantstyleandcolor\c!style\c!color - \letbtxcitevariantparameter\c!alternative\currentbtxcitevariant - \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 + {\letbtxparameter\c!alternative\currentbtxcitealternative + \edef\currentbtxreference{#1}% + \usebtxstyleandcolor\c!style\c!color + \uselanguageparameter\btxdatasetparameter % new + \btxparameter\c!command{\publ_cite_handle_variant_blob}% \endgroup} \unexpanded\def\btxcitation @@ -822,281 +1260,460 @@ \publ_cite_tags_indeed{#1}% \fi} -\unexpanded\def\btxnocite +\unexpanded\def\btxnocitation {\dosingleempty\publ_cite_no} \unexpanded\def\publ_cite_no[#1]% {\iftrialtypesetting \else - \ctxcommand{btxhandlecite{% - dataset = "\currentbtxdataset",% - reference = "#1",% - markentry = \iftrialtypesetting false\else true\fi,% - }}% + \begingroup + \edef\currentbtxreference{#1}% + \clf_btxhandlenocite + dataset {\currentbtxdataset}% + reference {\currentbtxreference}% + markentry true% + \relax + % \clf_btxflushmarked + \endgroup \fi} \unexpanded\def\btxmissing#1% - {{\tttf<#1>}} + {\dontleavehmode{\tttf<#1>}} %D Compatibility: -\let\cite \btxcite +\let\cite \btxcitation \let\citation \btxcitation -\let\nocite \btxnocite -\let\nocitation \btxnocite -\let\usepublication\btxnocite +\let\nocite \btxnocitation +\let\nocitation \btxnocitation +%let\usepublication\btxnocitation + +%D Setup helpers, beware, we need to wrap this .. now we need to know +%D how setups are implemented. + +\setvalue{\??setup:\s!btx:\s!unknown}#1{\inframed{\tttf#1}} + +\def\fastbtxsetup_yes#1#2% + {\csname\??setup:\s!btx:% + \ifcsname\??setup:\s!btx:\currentbtxspecification:#1:#2\endcsname + \currentbtxspecification:#1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:#2\endcsname + \currentbtxspecificationfallback:#1:#2% + \else\ifcsname\??setup:\s!btx:#1:#2\endcsname + #1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecification:#1:\s!unknown\endcsname + \currentbtxspecification:#1:\s!unknown + \else\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:\s!unknown\endcsname + \currentbtxspecificationfallback:#1:\s!unknown + \else + #1:\s!unknown + \fi\fi\fi\fi\fi + \endcsname{#2}} + +\def\fastbtxsetup_nop#1#2% + {\csname\??setup:\s!btx:% + \ifcsname\??setup:\s!btx:\currentbtxspecification:#1:#2\endcsname + \currentbtxspecification:#1:#2% + \else\ifcsname\??setup:\s!btx:#1:#2\endcsname + #1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecification:#1:\s!unknown\endcsname + \currentbtxspecification:#1:\s!unknown + \else + #1:\s!unknown + \fi\fi\fi + \endcsname{#2}} + +\def\fastbtxsetup + {\ifx\currentbtxspecificationfallback\empty + \expandafter\fastbtxsetup_nop + \else + \expandafter\fastbtxsetup_yes + \fi} -%D Cite helpers: +\let\publ_fastbtxsetup_normal\fastbtxsetup + +\newconstant\btxsetuptype + +% 0 = unknown darkred +% 1 = cite darkblue +% 2 = subcite darkgreen +% 3 = list darkcyan +% 4 = page darkmagenta +% 5 = unknown darkred + +\unexpanded\def\publ_fastbtxsetup_chain_inbetween + {\allowbreak->\allowbreak} + +\unexpanded\def\publ_fastbtxsetup_chain_yes#1#2% + {\dontleavehmode\begingroup + \infofont + \ifcase\btxsetuptype\darkred\or\darkblue\or\darkgreen\or\darkcyan\or\darkmagenta\else\darkred\fi + [% + \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecificationfallback:#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecificationfallback:#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + unset\fi\fi\fi\fi\fi + ]% + \endgroup} -\newconstant\currentbtxconcat +\unexpanded\def\publ_fastbtxsetup_chain_nop#1#2% + {\dontleavehmode\begingroup + \infofont + \darkred + [% + \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + unset\fi\fi\fi + ]% + \endgroup} -\unexpanded\def\btxcitereset - {\let\currentbtxfirst \empty - \let\currentbtxsecond \empty - \let\currentbtxinternal\empty - \let\currentbtxtag \empty - \setconstant\currentbtxconcat\zerocount} +\unexpanded\def\publ_fastbtxsetup_chain + {\ifx\currentbtxspecificationfallback\empty + \expandafter\publ_fastbtxsetup_chain_nop + \else + \expandafter\publ_fastbtxsetup_chain_yes + \fi} -\btxcitereset +\unexpanded\def\publ_fastbtxsetup_visual#1#2% + {\publ_fastbtxsetup_chain{#1}{#2}% + \publ_fastbtxsetup_normal{#1}{#2}} -\unexpanded\def\btxcitesetup#1% - {\directsetup{btx:cite:#1}% - \btxcitereset} +\installtextracker + {publications.setups} + {\let\fastbtxsetup\publ_fastbtxsetup_visual} + {\let\fastbtxsetup\publ_fastbtxsetup_normal} -\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} +%D Cite helpers: -\unexpanded\def\btxsetlistreference#1#2% #3#4% - {\strc_references_direct_full_user{btxset="#1",btxref="#2"}} +\newtoks\everybtxciteentry -\unexpanded\def\btxsetcitereference#1#2% - {\ifx\currentbtxinternal\empty \else - \strc_references_direct_full_user{btxint=#2}{#1}\empty - \fi} +\prependtoks + \setfalse\c_btx_cite_reference_injected +\to \everybtxciteentry -\unexpanded\def\btxstartsubcite#1% - {\bgroup - \btxcitereset - \def\currentbtxcitevariant{#1}% - \btxcitevariantparameter\c!left} +\unexpanded\def\btxcitesetup#1% + {\the\everybtxciteentry + \btxsetuptype\plusone + \everybtxciteentry\emptytoks % tricky maybe not when subcites + \fastbtxsetup\s!cite{#1}} % no \btxcitereset as we loose dataset and such -\unexpanded\def\btxstopsubcite - {\btxcitevariantparameter\c!right - \egroup} +\unexpanded\def\btxsubcitesetup#1% + {\the\everybtxciteentry + \btxsetuptype\plustwo + \everybtxciteentry\emptytoks % tricky maybe not when subcites + \fastbtxsetup\s!cite{#1}} % no \btxcitereset as we loose dataset and such -%D List helpers: +\appendtoks + \btx_check_language +\to \everybtxciteentry -\def\currentbtxindex{0} +\unexpanded\def\btxstartsubcite#1% + {\begingroup + \btxcitereset % todo: limited set + \def\currentbtxcitealternative{#1}% + \setbtxparameterset\s!cite\currentbtxcitealternative + \usebtxstyleandcolor\c!style\c!color + % \btxparameter\c!left + \relax} + +\unexpanded\def\btxstopsubcite + {%\relax + % \btxparameter\c!right + \endgroup} -\unexpanded\def\btxlistvariant#1% was \currentbtxindex +\unexpanded\def\btxstartciterendering[#1]% {\begingroup - \edef\currentbtxlistvariant{#1}% - \btxlistvariantparameter\c!left - \ctxcommand{btxlistvariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1","\number\btxlistcounter")}% some can go - \btxlistvariantparameter\c!right + \edef\currentbtxcitealternative{#1}% + \setbtxparameterset\s!cite\currentbtxcitealternative + \usebtxstyleandcolor\c!style\c!color + % \btxparameter\c!left + }%\relax} + +\unexpanded\def\btxstopciterendering + {\relax + % \btxparameter\c!right \endgroup} +\let\btxstartcite \begingroup +\let\btxstopcite \endgroup +\let\btxstartciteauthor\begingroup +\let\btxstopciteauthor \endgroup + %D Whatever helpers: -\unexpanded\def\btxsingularplural#1% - {\ctxcommand{btxsingularorplural("\currentbtxdataset","\currentbtxtag","#1")}} +\unexpanded\def\btxsingularplural#1{\clf_btxsingularorplural{\currentbtxdataset}{\currentbtxtag}{#1}} +\unexpanded\def\btxoneorrange #1{\clf_btxoneorrange {\currentbtxdataset}{\currentbtxtag}{#1}} +\unexpanded\def\btxfirstofrange #1{\clf_btxfirstofrange {\currentbtxdataset}{\currentbtxtag}{#1}} \let\btxsingularorplural\btxsingularplural -%D Loading variants: +\stopcontextdefinitioncode + +%D Journals + +\unexpanded\def\btxloadjournallist [#1]{\clf_btxloadjournallist{#1}} +\unexpanded\def\btxsavejournallist [#1]{\clf_btxsavejournallist{#1}} +\unexpanded\def\btxaddjournal [#1][#2]{\clf_btxaddjournal{#1}{#2}} + \def\btxexpandedjournal #1{\clf_btxexpandedjournal{#1}} % \unexpanded ? + \def\btxabbreviatedjournal#1{\clf_btxabbreviatedjournal{#1}} % \unexpanded ? + +% \installcorenamespace{btxjournal} +% +% \letvalue{\s!btxjournal\v!long }\btxexpandedjournal +% \letvalue{\s!btxjournal\v!short }\btxabbreviatedjournal +% \letvalue{\s!btxjournal\v!normal}\firstofoneargument +% +% \unexpanded\def\btxcheckedjournal +% {\expandnamespaceparameter\s!btxjournal\btxrenderingparameter\c!journalconversion} + +% \btxloadjournallist[list.txt] % Foo Journal of Bars = FBJ \n .... +% +% \btxexpandedjournal[fbj] +% \btxabbreviatedjournal[foo journal of bars] + +%D Saving data: + +\unexpanded\def\savebtxdataset + {\dotripleargument\publ_save_dataset} + +\unexpanded\def\publ_save_dataset[#1][#2][#3]% + {\ifthirdargument + \publ_save_dataset_indeed[#1][#2][#3]% + \else\ifsecondargument + \doifelseassignment{#2}% + {\publ_save_dataset_indeed[\s!default][#1][#2]}% + {\publ_save_dataset_indeed[#1][#2][]}% + \else\iffirstargument + \doifelseassignment{#1}% + {\publ_save_dataset_indeed[\s!default][\jobname-saved.bib][#1]}% + {\publ_save_dataset_indeed[\s!default][#1][]}% + % \else + % % bad news + \fi\fi\fi} + +\unexpanded\def\publ_save_dataset_indeed[#1][#2][#3]% + {\begingroup + \getdummyparameters + [\c!criterium=\v!all,% + \c!type=,% + \c!dataset=#1,% + \c!file=#2,% + #3]% % all or used + \clf_btxsavedataset + dataset {\dummyparameter\c!dataset}% + filename {\dummyparameter\c!file}% + filetype {\dummyparameter\c!type}% + criterium {\dummyparameter\c!criterium}% + \relax + \endgroup} + +% \savebtxdataset[default][e:/tmp/foo.bib] +% \savebtxdataset[default][e:/tmp/foo.lua] +% \savebtxdataset[default][e:/tmp/foo.xml] + +%D In-text entries: + +\unexpanded\def\placecitation{\citation[entry]} % [#1] + +\unexpanded\def\btxhandleciteentry + {\dontleavehmode + \begingroup + \def\currentbtxcitealternative{entry}% + \setbtxparameterset\s!cite\currentbtxcitealternative % needs checking + \btxcitereference + \btx_entry_inject + \endgroup} + +%D Registers + +% \setupbtxregister +% [\c!state=\v!start, +% \c!dataset=\v!all, +% \c!method=\v!always] + +\unexpanded\def\publ_registers_set + {\ifx\currentbtxregister\empty \else + \clf_btxsetregister + specification {\currentbtxspecification}% + name {\currentbtxregister}% + state {\btxregisterparameter\c!state}% + dataset {\btxregisterparameter\c!dataset}% + field {\btxregisterparameter\c!field}% + register {\btxregisterparameter\c!register}% + method {\btxregisterparameter\c!method}% + alternative {\btxregisterparameter\c!alternative}% + \relax + \fi} \appendtoks - \loadbtxdefinitionfile[\btxrenderingparameter\c!alternative] -\to \everysetupbtxrendering + \publ_registers_set +\to \everydefinebtxregister -\stopcontextdefinitioncode +\appendtoks + \publ_registers_set +\to \everysetupbtxregister + +\appendtoks + \normalexpanded{% + \defineprocessor + [\s!btx:r:\currentbtxregister]% + [\c!style=\noexpand\namedbtxregisterparameter{\currentbtxregister}\noexpand\c!style, + \c!color=\noexpand\namedbtxregisterparameter{\currentbtxregister}\noexpand\c!color]}% +\to \everydefinebtxregister + +\appendtoks + \clf_btxtoregister{\currentbtxdataset}{\currentbtxtag}% +\to \t_btx_reference_inject + +\unexpanded\def\btxindexedauthor#1#2#3#4#5#6% alternative von last first junior + {\begingroup + \def\currentbtxcitealternative{#1}% + \ifx\currentbtxcitealternative\empty + \edef\currentbtxcitealternative{invertedshort}% maybe we need some default here too? + \fi + %let\currentbtxlistvariant\currentbtxcitealternative % we inherit + \the\everysetupbtxciteplacement + \def\currentbtxvons {#2}% + \def\currentbtxsurnames {#3}% + \def\currentbtxinitials {#4}% + \def\currentbtxfirstnames {#5}% + \def\currentbtxjuniors {#6}% + \setbtxparameterset\s!cite\currentbtxcitealternative + \fastsetup{\s!btx:\s!cite:\s!author:\currentbtxcitealternative}% + \endgroup} + +%D We hook some setters in the definition sets: + +% \installdefinitionsetmember \??btx {btxspecification} \??btxcitevariant {btxcitevariant} +% \installdefinitionsetmember \??btx {btxspecification} \??btxlistvariant {btxlistvariant} +% \installdefinitionsetmember \??btx {btxspecification} \??btxlist {btxlist} +% \installdefinitionsetmember \??btx {btxspecification} \??btxrendering {btxrendering} +% \installdefinitionsetmember \??btx {btxspecification} \??btx {btx} + +%D And more helpers ... a never ending story these publications: + +% \definebtx +% [btx:apa:list:article:title] +% [style=bolditalic, +% command=\WORD] +% +% \btxstartstyle[btx:apa:list:article:title] +% \btxusecommand[btx:apa:list:article:title]{foo} +% \btxstopstyle + +\let\savedcurrentbtx\empty + +\unexpanded\def\btxstartstyle[#1]% + {\begingroup + \let\savedcurrentbtx\currentbtx + \def\currentbtx{#1}% + \usebtxstyle\c!style + \let\currentbtx\savedcurrentbtx} + +\unexpanded\def\btxstartcolor[#1]% + {\begingroup + \let\savedcurrentbtx\currentbtx + \def\currentbtx{#1}% + \usebtxcolor\c!color + \let\currentbtx\savedcurrentbtx} + +\unexpanded\def\btxstartstyleandcolor[#1]% + {\begingroup + \let\savedcurrentbtx\currentbtx + \def\currentbtx{#1}% + \usebtxstyleandcolor\c!style\c!color + \let\currentbtx\savedcurrentbtx} + +\let\btxstopstyle \endgroup +\let\btxstopcolor \endgroup +\let\btxstopstyleandcolor\endgroup + +\unexpanded\def\btxusecommand[#1]% + {\namedbtxparameter{#1}\c!command} %D Defaults: \setupbtxrendering - [\c!dataset=\v!standard, + [\c!interaction=\v!start, % \v!all + \c!specification=\btxparameter\c!specification, + \c!dataset=\v!default, + \c!repeat=\v!no, + \c!continue=\v!no, \c!method=\v!global, - \c!setups=btx:rendering:\btxrenderingparameter\c!alternative, - \c!alternative=apa, - \c!sorttype=, - \c!criterium=, + % \c!setups=btx:\btxrenderingparameter\c!alternative:initialize, % not the same usage as cite ! + % \c!sorttype=authoryear, + \c!criterium=\v!text, \c!refcommand=authoryears, % todo \c!numbering=\v!yes, -% \c!autohang=\v!no, + %\c!saveinlist=\v!no, % maybe for before/after + \c!textstate=\v!start, \c!width=\v!auto, - \c!separator={; }, + %\c!pageright=, + %\c!pageleft=, + \c!separator={;\space}, \c!distance=1.5\emwidth] -\definebtxrendering - [\v!standard] +% Quite some interpunction and labels are the same of at least consistent within +% a standard when citations and list entries are involved. We assume that each +% standard defines its own set but it can fall back on these defaults. -\setupbtxcitevariant +\setupbtx [\c!interaction=\v!start, - \c!setups=btx:cite:\btxcitevariantparameter\c!alternative, - \c!alternative=num, - \c!andtext={ and }, - \c!otherstext={ et al.}, - \c!pubsep={, }, - \c!lastpubsep={ and }, - \c!finalpubsep={ and }, + \c!alternative=num, % default cite form + \c!inbetween=\space, + \c!range=\endash, % separator:range? \c!compress=\v!no, - \c!inbetween={ }, - \c!range=\endash, - \c!left=, - \c!middle=, - \c!right=] - -\definebtxcitevariant - [author] - [%c!sorttype=, - \c!left={(}, - \c!middle={, }, - \c!right={)}] - -\definebtxcitevariant - [authornum] - [author] - [\c!inbetween={ }] - -\definebtxcitevariant - [authoryear] - [\c!compress=\v!yes, - \c!inbetween={, }, - \c!left={(}, - \c!middle={, }, - \c!right={)}] - -\definebtxcitevariant - [authoryears] - [authoryear] - -\definebtxcitevariant - [author:num] - [authornum] - [\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 - [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 - [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!middle={, }, - \c!right=] - -\definebtxcitevariant - [num] - [\c!compress=\v!yes, - \c!left={[}, - \c!middle={, }, - \c!right={]}] - -\setupbtxlistvariant - [\c!namesep={, }, - \c!lastnamesep={ and }, - \c!finalnamesep={ and }, - \c!firstnamesep={ }, - \c!juniorsep={ }, - \c!vonsep={ }, - \c!surnamesep={, }, - \c!surnameinitialsep={, }, - \c!surnamefirstnamesep={, }, - \c!etallimit=5, - \c!etaldisplay=5, - \c!etaltext={ et al.}, - \c!monthconversion=\v!number, - \c!authorconversion=\v!normal] - -\definebtxlistvariant - [author] - [author=invertedshort] % we could also do this in the apa style itself - -\definebtxlistvariant - [editor] - [author] - -\definebtxlistvariant - [artauthor] - [author] - -\setupbtxcitevariant - [\c!author =\btxlistvariantparameter\c!author, - \c!etallimit =\btxlistvariantparameter\c!etallimit, - \c!etaldisplay =\btxlistvariantparameter\c!etaldisplay] + \c!etallimit=3, + \c!etaldisplay=\btxparameter\c!etallimit, + \c!otherstext={\space et al.}, + \c!separator:firstnames={\space}, + \c!separator:juniors={\space}, + \c!separator:vons={\space}, + \c!separator:initials={\space}, + \c!stopper:initials={.}, + %\c!surnamesep={,\space}, % is this used anywhere? + \c!separator:invertedinitials={,\space}, + \c!separator:invertedfirstnames={,\space}, + \c!separator:names:2={,\space}, % separates multiple names + \c!separator:names:3=\btxparameter{\c!separator:2}, % before last name in a list + \c!separator:names:4=\btxparameter{\c!separator:2}, % between only two names + \c!separator:2={;\space}, % aka pubsep - separates multiple objects + \c!separator:3=\btxparameter{separator:2}, % before last object in a list + \c!separator:4=\btxparameter{separator:2}] % between only two objects % Do we want these in the format? Loading them delayed is somewhat messy. -\loadbtxdefinitionfile[apa] -\loadbtxdefinitionfile[cite] \loadbtxdefinitionfile[commands] \loadbtxdefinitionfile[definitions] +\loadbtxdefinitionfile[cite] +\loadbtxdefinitionfile[list] +\loadbtxdefinitionfile[page] +\loadbtxdefinitionfile[author] + +% we assume that the users sets up the right specification and if not ... well, +% hope for the best that something shows up and consult the manual otherwise + +\unexpanded\def\usebtxdefinitions[#1]% + {\loadbtxdefinitionfile[#1]% % for hh + \setupbtx[\c!specification=#1]} % for ab + +\setupbtx + [\c!specification=\s!default, + \c!dataset=\v!default, + \c!default=\v!default] + +\loadbtxdefinitionfile + [\s!default] + \protect |