diff options
author | Karl Berry <karl@freefriends.org> | 2022-09-18 19:43:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-09-18 19:43:14 +0000 |
commit | e1c8dfe96e04abdaaa9715bd0035ee0cd1b89c3f (patch) | |
tree | 91e6aadae65eb8a73144f623ea35e9f7516f1b5d /Master/texmf-dist/tex/latex/citation-style-language | |
parent | f363d563b7b3a861e98f2667feb590123944d67b (diff) |
citation-style-language (18sep22)
git-svn-id: svn://tug.org/texlive/trunk@64429 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/citation-style-language')
-rw-r--r-- | Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty | 133 |
1 files changed, 79 insertions, 54 deletions
diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty index 87165c4be28..bc4acd29e23 100644 --- a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty @@ -9,7 +9,7 @@ \RequirePackage{expl3} \RequirePackage{xparse} -\ProvidesExplPackage {citation-style-language} {2022-08-18} {v0.2.0} +\ProvidesExplPackage {citation-style-language} {2022-09-18} {v0.2.1} {Citation Style Language for LaTeX} \RequirePackage { l3keys2e } @@ -293,8 +293,8 @@ % #1: citation info "{<citationID>}{{id=ITEM-1},{id=ITEM-2}}{<noteIndex>}" { \if@filesw - \iow_now:Nn \@auxout - { \citation { #1 } } + \iow_now:Nx \@auxout + { \token_to_str:N \citation { #1 } } \fi } @@ -398,7 +398,7 @@ { \bibcite {#1} {#2} % \if@filesw - % \iow_now:Nn \@auxout { \bibcite {#1} {#2} } + % \iow_now:Nx \@auxout { \token_to_str:N \bibcite {#1} {#2} } % \fi } @@ -418,17 +418,15 @@ { \msg_warning:nnn { citation-style-language } { bibliography / empty } } } { - \tl_if_empty:NTF \l__csl_bibliography_tl - { - \file_if_exist_input:nF { \jobname .bbl } - { - \msg_warning:nnx { citation-style-language } { file / non-exist} { \jobname .bbl } - } - } - { \exp_args:NV \__csl_print_bibliography:n \l__csl_bibliography_tl } + \tl_if_empty:NTF \g__csl_bibliography_tl + { \msg_warning:nnn { citation-style-language } { bibliography / empty } } + { \exp_args:NV \__csl_print_bibliography:n \g__csl_bibliography_tl } } } +\msg_new:nnn { citation-style-language } { bibliography / empty } + { The~ bibliography~ is~ empty. } + \cs_new:Npn \__csl_print_bibliography:n #1 { \begin { thebibliography } @@ -436,12 +434,6 @@ \end { thebibliography } } -\msg_new:nnn { citation-style-language } { bibliography / empty } - { The~ bibliography~ is~ empty. } - -\msg_new:nnn { citation-style-language } { file / non-exist } - { No~ file~ #1. } - \tl_new:N \l__csl_style_tl \clist_new:N \l__csl_bib_resources_clist @@ -483,7 +475,7 @@ \bool_new:N \l__csl_engine_initialized_bool -\prop_set_from_keyval:Nn \l__csl_babel_locale_mapping_prop +\prop_set_from_keyval:Nn \l__csl_language_code_map_prop { acadian = fr-CA, american = en-US, @@ -600,10 +592,27 @@ welsh = cy-GB, } -\tl_new:N \l__csl_bibliography_tl -\tl_new:N \l__csl_bibliography_setup_tl +\tl_new:N \g__csl_bibliography_tl +\tl_new:N \g__csl_bibliography_setup_tl + + +\AtBeginDocument { \__csl_at_begin_document_hook: } + + +\cs_new:Npn \__csl_at_begin_document_hook: + { + \__csl_write_aux_info: + \sys_if_engine_luatex:TF + { + \__csl_initialize_lua_module: + } + { + \__csl_load_bbl: + } + } + -\AtBeginDocument +\cs_new:Npn \__csl_write_aux_info: { \tl_if_empty:NTF \l__csl_style_tl { \tl_set_eq:NN \l__csl_style_tl \g__csl_aux_bibstyle_tl } @@ -615,44 +624,35 @@ { \clist_use:Nn \l__csl_bib_resources_clist { , } } } \__csl_write_aux_csl_options: - \sys_if_engine_luatex:T - { - \lua_now:e - { - csl.init( - "\l__csl_style_tl", - "\l__csl_bib_resources_clist", - "\l__csl_locale_tl" - ) - } - \str_if_eq:eeT { \lua_now:n { tex.print(csl.initialized) } } { true } - { \bool_set_true:N \l__csl_engine_initialized_bool } - \__csl_get_style_class: - \@ifpackageloaded { hyperref } - { \lua_now:n { csl.enable_linking() } } - { } - } - % Load .bbl at the beginning of document to save one pass of latex. - % In this procedure, the \cslcite command is processed and the contents - % of `thebibliography` is stored into \l__csl_bibliography_tl. - \group_begin: - \RenewDocumentCommand \cslsetup { m } - { \tl_set:Nn \l__csl_bibliography_setup_tl {#1} } - \RenewDocumentEnvironment { thebibliography } { m +b } - { \tl_set:Nn \l__csl_bibliography_tl { {#1} #2 } } - { } - \file_if_exist_input:n { \jobname .bbl } - \group_end: } \cs_new:Npn \__csl_write_aux_bibstyle:n #1 { \if@filesw - \iow_now:Nn \@auxout { \bibstyle {#1} } + \iow_now:Nx \@auxout { \token_to_str:N \bibstyle {#1} } \fi } +\cs_new:Npn \__csl_initialize_lua_module: + { + \lua_now:e + { + csl.init( + "\l__csl_style_tl", + "\l__csl_bib_resources_clist", + "\l__csl_locale_tl" + ) + } + \str_if_eq:eeT { \lua_now:n { tex.print(csl.initialized) } } { true } + { \bool_set_true:N \l__csl_engine_initialized_bool } + \__csl_get_style_class: + \@ifpackageloaded { hyperref } + { \lua_now:n { csl.enable_linking() } } + { } + } + + \str_new:N \l__csl_style_class_str % In-text (including numeric or author-date) or note style \bool_new:N \l__csl_note_style_bool @@ -677,7 +677,7 @@ { \tl_if_exist:NT \bbl@main@language { - \prop_get:NVN \l__csl_babel_locale_mapping_prop \bbl@main@language + \prop_get:NVN \l__csl_language_code_map_prop \bbl@main@language \l__csl_locale_tl } } @@ -696,7 +696,7 @@ \if@filesw \iow_now:Nx \@auxout { - \exp_not:N \csloptions + \token_to_str:N \csloptions { \clist_use:Nn \l__csl_options_clist { , } } } \fi @@ -704,6 +704,31 @@ } +% Load .bbl at the beginning of document to save one pass of latex. +% In this procedure, the \cslcite command is processed and the contents +% of `thebibliography` is stored into \g__csl_bibliography_tl. +\cs_new:Npn \__csl_load_bbl: + { + \group_begin: + \RenewDocumentCommand \cslsetup { m } + { \tl_set:Nn \g__csl_bibliography_setup_tl {##1} } + \RenewDocumentEnvironment { thebibliography } { m +b } + { \tl_gset:Nn \g__csl_bibliography_tl { {##1} ##2 } } + { } + % The \@input@ prints "No file ....bbl" in the .log file from which + % the latexmk decides to run $bibtex or not. + \@input@ { \jobname .bbl } + % \file_if_exist_input:nF { \jobname .bbl } + % { + % \msg_warning:nnx { citation-style-language } { file / non-exist} { \jobname .bbl } + % } + \group_end: + } + +% \msg_new:nnn { citation-style-language } { file / non-exist } +% { No~ file~ #1. } + + \DeclareDocumentCommand \bibliographystyle { m } { \__csl_if_preamble:F @@ -734,7 +759,7 @@ \cs_new:Npn \__csl_write_aux_bibdata:n #1 { \if@filesw - \iow_now:Nn \@auxout { \bibdata {#1} } + \iow_now:Nx \@auxout { \token_to_str:N \bibdata {#1} } \fi } |