publ-imp-default.mkvi / last modification: 2020-01-30 14:16
%D \module
%D   [       file=publ-imp-default,
%D        version=2014.02.06,
%D          title=Default bibliography style,
%D       subtitle=Publications,
%D         author=Alan Braslau and 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 therefore copyrighted
%D by \PRAGMA. See mreadme.pdf for details.

%D This default style defines only a few categories: book and article.
%D If you want more, you need to load a more complete style such as \type {apa},
%D \type {aps}, etc. The default style is used in the manuals that ship with
%D \CONTEXT. This file is always loaded.

\startbtxrenderingdefinitions[\s!default]

\definebtxrendering
  [\s!default]
  [\c!specification=\s!default,
   \c!sorttype=\v!default,
   \c!numbering=num]

\setupbtxlist
  [default]
  [\c!align={normal,verytolerant,stretch}]

\definebtx
  [\s!default]
  [\c!default=, % we do not want to fall|-|back on ourself.
   \c!otherstext={\btxspace\btxlabeltext{default:others}},
   %c!journalconversion=\v!normal,
   \c!monthconversion=\v!number,
   \c!separator:names:2={\btxcomma},
   \c!separator:names:3={\btxspace\btxlabeltext{default:and}\space},
   \c!separator:names:4={\btxspace\btxlabeltext{default:and}\space}]

\definebtx
  [\s!default:\s!list]
  [\s!default]
  [\c!authorconversion=normalshort]

\definebtx
  [\s!default:\s!cite]
  [\s!default]
  [\c!alternative=num,
   \c!compress=\v!yes,
   \c!sorttype=normal,
   \c!authorconversion=\v!name]

\definebtx
  [\s!default:\s!cite:name]
  [\s!default:\s!cite]
  [\c!authorconversion=\v!name]

\definebtx
  [\s!default:\s!cite:inverted]
  [\s!default:\s!cite]
  [\c!authorconversion=\v!invertedshort]

\definebtx
  [\s!default:\s!cite:invertedshort]
  [\s!default:\s!cite]
  [\c!authorconversion=\v!invertedshort]

\definebtx
  [\s!default:\s!cite:normalshort]
  [\s!default:\s!cite]
  [\c!authorconversion=\v!normalshort]

\definebtx
  [\s!default:\s!cite:normal]
  [\s!default:\s!cite]
  [\c!authorconversion=\v!normal]

% List variants, some having specific settings:

\definebtx
  [\s!default:\s!list:\s!page]
  [\s!default:\s!list]
  [\c!separator:2={\btxcomma},
   \c!separator:3={\btxcomma\btxlabeltext{default:and}\space},
   \c!separator:4={\btxspace\btxlabeltext{default:and}\space},
   \c!left={\btxleftparenthesis},
   \c!right={\btxrightparenthesis}]

\definebtx
  [\s!default:\s!list:numbering]
  [\s!default:\s!list]

\definebtx
  [\s!default:\s!list:numbering:default]
  [\s!default:\s!list:numbering]

\definebtx
  [\s!default:\s!list:numbering:num]
  [\s!default:\s!list:numbering]

\definebtx
  [\s!default:\s!list:numbering:short]
  [\s!default:\s!list:numbering:num]

\definebtx
  [\s!default:\s!list:numbering:tag]
  [\s!default:\s!list:numbering:num]

\definebtx
  [\s!default:\s!list:numbering:index]
  [\s!default:\s!list:numbering:num]

\definebtx
  [\s!default:\s!list:author]
  [\s!default:\s!list]

\definebtx
  [\s!default:\s!list:editor]
  [\s!default:\s!list:author]

\definebtx
  [\s!default:\s!list:url]
  [\s!default:\s!list]

\definebtx
  [\s!default:\s!list:doi]
  [\s!default:\s!list]

\definebtx
  [\s!default:\s!list:short]
  [\s!default:\s!list]

\definebtx
  [\s!default:\s!list:journal]
  [\s!default:\s!list]
  [\c!style=\v!italic]

\definebtx
  [\s!default:\s!list:title]
  [\s!default:\s!list]
  [\c!style=\v!italic,
   \c!command=\Word]

\definebtx
  [\s!default:\s!list:title:article]
  [\s!default:\s!list:title]
  [\c!style=, % journal is set in italics
   \c!command=\quotation] % alan, you can't do \quotation\Word

\definebtx
  [\s!default:\s!list:title:book]
  [\s!default:\s!list:title]

% Citation variants, some having specific settings :

\definebtx
  [\s!default:\s!cite:author]
  [\s!default:\s!cite]

\definebtx
  [\s!default:\s!cite:authornum]
  [\s!default:\s!cite:author]
  [\c!left={(},
   \c!right={)}]

\definebtx
  [\s!default:\s!cite:authoryear]
  [\s!default:\s!cite:author]
  [\c!left={(},
   \c!right={)},
   \c!inbetween={\btxcomma}]

\definebtx
  [\s!default:\s!cite:authoryears]
  [\s!default:\s!cite:author]

\definebtx
  [\s!default:\s!cite:author:num] % todo
  [\s!default:\s!cite:authornum]
  [\c!left={\btxleftbracket},
   \c!right={]}]

\definebtx
  [\s!default:\s!cite:author:year] % todo
  [\s!default:\s!cite:authoryear]
  [\c!left=,
   \c!right=]

\definebtx
  [\s!default:\s!cite:author:years] % todo
  [\s!default:\s!cite:authoryears]
  [\c!inbetween=,
   \c!left={\btxleftparenthesis},
   \c!right={)}]

\definebtx
  [\s!default:\s!cite:year]
  [\s!default:\s!cite]

\definebtx
  [\s!default:\s!cite:title]
  [\s!default:\s!cite]
  [\c!command={\language[\currentbtxlanguage]}, % BAH
   \c!style=\v!italic]

\definebtx
  [\s!default:\s!cite:tag]
  [\s!default:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [\s!default:\s!cite:index]
  [\s!default:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [\s!default:\s!cite:page]
  [\s!default:\s!cite]
  [\c!left=,
   \c!right=]

\definebtx
  [\s!default:\s!cite:pages]
  [\s!default:\s!cite:page]

\definebtx
  [\s!default:\s!cite:keywords]
  [\s!default:\s!cite]
  [\c!left={(},
   \c!right={)}]

\definebtx
  [\s!default:\s!cite:short]
  [\s!default:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [\s!default:\s!cite:category]
  [\s!default:\s!cite]

\definebtx
  [\s!default:\s!cite:url]
  [\s!default:\s!cite]
  [\c!left={[},
   \c!right={]}]

\definebtx
  [\s!default:\s!cite:doi]
  [\s!default:\s!cite:url]

\definebtx
  [\s!default:\s!cite:num]
  [\s!default:\s!cite]
  [\c!left={[},
   \c!right={]},
   \c!separator:2=\btxcommabreak,
   \c!separator:3=\btxparameter{\c!separator:2},
   \c!separator:4=\btxparameter{\c!separator:2}]

\definebtx
  [\s!default:\s!cite:default]
  [\s!default:\s!cite:num]

\definebtx
  [\s!default:\s!cite:textnum]
  [\s!default:\s!cite:num]
  [\c!left=, % in apa: {Ref.\nbsp} or so
   \c!right=,
   \c!separator:2={\btxcomma},
   \c!separator:3={\btxcomma\btxlabeltext{default:and}\space},
   \c!separator:4={\btxspace\btxlabeltext{default:and}\space}]

\definebtx
  [\s!default:\s!cite:entry]
  [\s!default:\s!cite]
  [\c!left={(},
   \c!right={)}]

\definebtx
  [\s!default:\s!cite:lefttext]
  [\s!default:\s!cite]
  [\c!left=,
   \c!right=]

\definebtx
  [\s!default:\s!cite:righttext]
  [\s!default:\s!cite]
  [\c!left=,
   \c!right=]

% Multilingual text strings

\setupbtxlabeltext
  [en]
  [\s!default:and=and,
   \s!default:number={no.},
   \s!default:edition={ed.},
   \s!default:Editor=Editor, % Ed./Eds.
   \s!default:Editors=Editors,
   \s!default:Volume={Vol.},
   \s!default:Volumes={Vols.},
   \s!default:others={et al.}]

\setupbtxlabeltext
  [nl]
  [\s!default:and=en,
   \s!default:number={nr.},
   \s!default:edition={ed.}, % editie
   \s!default:Editor=Editor, % Ed./Eds.
   \s!default:Editors=Editors,
   \s!default:Volume={Vol.},
   \s!default:Volumes={Vols.},
   \s!default:others={et al.}]

\setupbtxlabeltext
  [fr]
  [\s!default:and=et,
   \s!default:others={et al.},
   \s!default:number={n\high{o}},
   \s!default:edition={édition},
   \s!default:Editor=Éditeur,
   \s!default:Editors=Éditeurs,
   \s!default:Volume=Volume,
   \s!default:Volumes=Volumes,
   \s!default:others={et al.}]

\setupbtxlabeltext
  [de]
  [\s!default:and=und,
   \s!default:number={nr.},
   \s!default:edition=Auf\/lage,
   \s!default:Editor=Herausgeber, % Hrsg./Hg.
   \s!default:Editors=Herausgeber,
   \s!default:Volume=Band,        % Bd.
   \s!default:Volumes={Bände},
   \s!default:others={et al.}]

\setupbtxlabeltext
  [it]
  [\s!default:and=e,
   \s!default:number={},
   \s!default:edition={ed.},      % edizione
   \s!default:Editor={A cura di},
   \s!default:Editors={A cura di},
   \s!default:Volume={Vol.},      % Volume
   \s!default:Volumes={Vol.},     % Volumi
   \s!default:others={et al.}]

\setupbtxlabeltext
  [es]
  [\s!default:and=y,
   \s!default:number={},
   \s!default:edition={ed.},   % edición
   \s!default:Editor=Editor,   % Ed./Eds.
   \s!default:Editors=Editores,
   \s!default:Volume={Vol.},   % Volumen
   \s!default:Volumes={Vols.}, % Volúmenes
   \s!default:others={et al.}]

\setupbtxlabeltext
  [sv]
  [\s!default:and=och,
   \s!default:number={nr.},
   \s!default:edition={Utgåva},
   \s!default:Editor=Redaktör, 
   \s!default:Editors=Redaktörer,
   \s!default:Volume=Band,
   \s!default:Volumes=Band,
   \s!default:others={et al.}]


% First some helpers:

\starttexdefinition btx:default:composed-title
    \begingroup
        \language[\currentbtxlanguage]
        \btxflush{title}
        \btxdoif {subtitle} {
            \btxcolon
            \btxflush{subtitle}
        }
    \endgroup
\stoptexdefinition

\starttexdefinition btx:default:title
    \btxdoif {title} {
        \btxspace
        \btxstartstyleandcolor [default:list:title:\currentbtxcategory]
            \btxusecommand [default:list:title:\currentbtxcategory] {
                \texdefinition{btx:default:composed-title}
            }
        \btxstopstyleandcolor
        \btxcomma
    }
\stoptexdefinition

\starttexdefinition btx:default:author
    \btxdoif {author} {
        \btxflush{author}
        \doif {\btxfoundname{author}} {editor} {
            \btxcomma
            \btxsingularorplural {editor} {
                \btxlabeltext{default:Editor}
            } {
                \btxlabeltext{default:Editors}
            }
        }
        \btxcomma
    }
\stoptexdefinition

\starttexdefinition btx:default:year
    \btxflush{year}
    \btxflushsuffix
\stoptexdefinition

\starttexdefinition btx:default:journal
    \btxdoif {journal} {
        \btxspace
        \btxstartstyleandcolor [default:list:journal]
            \btxusecommand [default:list:journal] {
                \btxflush{journal}
            }
        \btxstopstyleandcolor
        \btxdoifelse {volume} {
            \btxspace
            \btxflush{volume}
            \btxdoif {number} {
                \ignorespaces % brrr
                \btxleftparenthesis
                \btxflush{number}
                \btxrightparenthesis
            }

        } {
            \btxdoif {number} {
                \btxlabeltext{default:number}
                \btxspace
                \btxflush{number}
            }
        }
        \btxdoif {pages} {
            \btxcomma
            \btxflush{pages}
        }
        \btxcomma
    }
\stoptexdefinition

\starttexdefinition btx:default:editionset
    \btxdoif {editionset} {
        \removeunwantedspaces
        \removepunctuation
        \btxleftparenthesis
        \doif {\btxfoundname{editionset}} {edition} {
            \btxflush{edition}
            \btxspace
            \btxlabeltext{default:edition}
            \btxcomma
        }
        \btxdoif {volume} {
            \btxoneorrange {volume} {
                \btxlabeltext{default:Volume}
            } {
                \btxlabeltext{default:Volumes}
            }
            \btxspace
            \btxflush{volume}
            \btxcomma
        }
        \btxdoifelse {number} {
            \btxlabeltext{default:number}
            \btxspace
            \btxflush{number}
        } {
            \removeunwantedspaces
            \removepunctuation
        }
        \btxrightparenthesiscomma
    }
\stoptexdefinition

\starttexdefinition btx:default:publisher
    \btxdoif {publisher} {
        \btxflush{publisher}
        \btxcomma
    }
    \btxdoif {address} {
        \btxflush{address}
        \btxcomma
    }
\stoptexdefinition

% Then a minimal number of setups:

\startsetups btx:default:list:article
    \texdefinition{btx:default:author}
    \texdefinition{btx:default:title}
    \texdefinition{btx:default:journal}
    \texdefinition{btx:default:year}
    \removeunwantedspaces
    \removepunctuation
    \btxperiod
\stopsetups

\startsetups btx:default:list:book
    \texdefinition{btx:default:author}
    \texdefinition{btx:default:title}
    \texdefinition{btx:default:editionset}
    \texdefinition{btx:default:publisher}
    \texdefinition{btx:default:year}
    \removeunwantedspaces
    \removepunctuation
    \btxperiod
\stopsetups

\startsetups btx:default:list:unknown
    \currentbtxcategory\btxcolon
    \btxshowentryinline
\stopsetups

%D Experiment:

%D See publ-imp-cite.mkvi
%
%\startsetups btx:default:cite:lefttext
%    \currentbtxlefttext
%\stopsetups

%\startsetups btx:default:cite:righttext
%    \currentbtxrighttext
%\stopsetups

\stopbtxrenderingdefinitions