diff options
author | Norbert Preining <norbert@preining.info> | 2021-06-18 03:01:13 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-06-18 03:01:13 +0000 |
commit | 3ecc00c27119bc47ba26b518b7d26c00b69599df (patch) | |
tree | db60a75c06403ca74ed76bc3339d80958159ae3e /macros/latex/contrib/gs1/GS1.dtx | |
parent | 5f3280db1e6f333f79e9930e5609d3f5175d5af7 (diff) |
CTAN sync 202106180301
Diffstat (limited to 'macros/latex/contrib/gs1/GS1.dtx')
-rw-r--r-- | macros/latex/contrib/gs1/GS1.dtx | 120 |
1 files changed, 62 insertions, 58 deletions
diff --git a/macros/latex/contrib/gs1/GS1.dtx b/macros/latex/contrib/gs1/GS1.dtx index 0f6508d9ce..a69bbf41e8 100644 --- a/macros/latex/contrib/gs1/GS1.dtx +++ b/macros/latex/contrib/gs1/GS1.dtx @@ -18,7 +18,7 @@ % %<*driver|package|test> \RequirePackage{expl3}[2017/05/29] -\GetIdInfo$Id: GS1.dtx 22 2017-07-15 18:03:18Z mjk $ +\GetIdInfo$Id: GS1.dtx 23 2021-06-17 07:00:36Z mjk $ {GS1 code handler and barcode generator} %</driver|package|test> %<*driver> @@ -311,10 +311,10 @@ % % \section{\pkg{GS1} implementation} % \label{sec:implementation} -% \iffalse -%<*package> +% +% \begin{macrocode} %<@@=GS> -% \fi +% \end{macrocode} % % The implementation has been done in two parts. The first part is the L3 % code with all the functions and variables. The second part is the @@ -322,12 +322,14 @@ % % But before this, we just declare, what this is: % \begin{macrocode} +%<*package> \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} % \end{macrocode} % and what it requires: % \begin{macrocode} \RequirePackage{rule-D} +%</package> % \end{macrocode} % % \subsection{Implementation of Functions and Variables} @@ -340,12 +342,14 @@ % While this is an internal function, that should allow only some tokens at % the arguments, it is declared \texttt{nopar}. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \@@_new_seq_c:cn #1#2 { \seq_new:c {c@@_ #1 _seq} \seq_set_split:Nnn \l_tmpa_seq {} {#2} \seq_gset_eq:cN {c@@_ #1 _seq} \l_tmpa_seq } +%</package> % \end{macrocode} % \end{macro} % @@ -355,6 +359,7 @@ % These constants represent the generation rules of the left side of an EAN-13 % barcode. See figure~5.2.1.3.1-1 of the GS1 specification. % \begin{macrocode} +%<*package> \@@_new_seq_c:cn {AB0} {AAAAAA} \@@_new_seq_c:cn {AB1} {AABABB} \@@_new_seq_c:cn {AB2} {AABBAB} @@ -365,6 +370,7 @@ \@@_new_seq_c:cn {AB7} {ABABAB} \@@_new_seq_c:cn {AB8} {ABABBA} \@@_new_seq_c:cn {AB9} {ABBABA} +%</package> % \end{macrocode} % \end{variable} % @@ -379,6 +385,7 @@ % the module sequences of type C are same like type A but start with a black % module instead of a white one. % \begin{macrocode} +%<*package> \@@_new_seq_c:cn {A0} {3211} % start white (C0 same but start with black) \@@_new_seq_c:cn {A1} {2221} \@@_new_seq_c:cn {A2} {2122} @@ -404,14 +411,17 @@ \@@_new_seq_c:cn {special} {111111} % start white \@@_new_seq_c:cn {extra_margin} {112} % start black \@@_new_seq_c:cn {extra_separator} {11} % start white +%</package> % \end{macrocode} % \end{variable} % % There are some basic dimensions for the modules at the specification: % \begin{variable}{\c__GS_module_min_width_dim, \c__GS_module_norm_width_dim} % \begin{macrocode} +%<*package> \dim_const:Nn \c_@@_module_min_width_dim {0.264mm} \dim_const:Nn \c_@@_module_norm_width_dim {0.33mm} +%</package> % \end{macrocode} % \end{variable} % @@ -428,6 +438,7 @@ % Needed to set both \cmd{\l_GS_code_type_tl} and \cmd{\l_GS_code_size_int} % with one key. Together they are the type of code, to be handled. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \@@_set_key_code:nn #1#2 { \tl_if_exist:NF \l_GS_code_type_tl { \tl_new:N \l_GS_code_type_tl } @@ -459,6 +470,7 @@ add_control .bool_set:N = \l_GS_add_control_bool, add_control .initial:n = false, } +%</package> % \end{macrocode} % \end{variable} % @@ -471,7 +483,9 @@ % This will be used later for several local GS1 sequences. It is private % and also shouldn't be used in global context. % \begin{macrocode} +%<*package> \seq_new:N \l_@@_code_seq +%</package> % \end{macrocode} % \end{variable} % @@ -482,6 +496,7 @@ % only EAN-8 and EAN-13 are supported, both with or without control % digit. This message will be used as an error message. % \begin{macrocode} +%<*package> \msg_new:nnnn { GS1 } { EAN-code-size } { #1~isn't~a~valid~EAN~code~\msg_line_context:. @@ -491,12 +506,14 @@ nor~a~EAN-13~with~or~without~control~digit.\\\\ The~GS1~module~currently~only~supports~EAN-8~and~EAN~13. } +%</package> % \end{macrocode} % % Another message is only a warning message. It will be used whenever the used % module width would be less than the minimum module width given by the GS1 % specification. % \begin{macrocode} +%<*package> \msg_new:nnn { GS1 } { module/minwidth } { Resulting~module~width~is~less~than~allowed~minimum~\msg_line_context:.\\\\ @@ -504,6 +521,7 @@ Currently~the~module~with~would~be~#1.\\ To~avoid~problems,~I'll~increase~module~width~to~#2. } +%</package> % \end{macrocode} % % \subsubsection{Functions} @@ -512,6 +530,7 @@ % \begin{macro}{\GS_set_code_digit_seq:Nn} % Convert a string into a code sequence ignoring all but digits. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \GS_set_code_digit_seq:Nn #1#2 { \seq_set_eq:NN #1 \c_empty_seq @@ -526,13 +545,12 @@ } } } +%</package> % \end{macrocode} % % \TestFiles{GS_set_code_digit.tex}\UnitTested -% \iffalse meta-comment -%</package> -%<*test&GS.set.code.digit.seq> % \begin{macrocode} +%<*test&GS.set.code.digit.seq> \ExplSyntaxOn \seq_new:N \l_testa_seq \seq_new:N \l_testb_seq @@ -569,10 +587,8 @@ Sequence~for~ISBN~978-3-86541-459-5~is:~ } \ExplSyntaxOff -% \end{macrocode} %</test&GS.set.code.digit.seq> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}[updated = 2017-07-15]{\GS_cut_EAN_control_digit:N} @@ -583,6 +599,7 @@ Sequence~for~ISBN~978-3-86541-459-5~is:~ % a 8 or 13 digits sequence. 7 or 12 digit sequences are already without % control digit. All other sequences are not supported. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \GS_cut_EAN_control_digit:N #1 { \int_case:nnF @@ -597,13 +614,12 @@ Sequence~for~ISBN~978-3-86541-459-5~is:~ \msg_error:nnn { GS1 } { EAN-code-size } { #1 } } } +%</package> % \end{macrocode} -% \TestFiles{GS_cut_EAN_control_digit.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&GS.cut.EAN.control.digit> +% \TestFiles{GS_cut_EAN_control_digit.tex}\UnitTested % \begin{macrocode} +%<*test&GS.cut.EAN.control.digit> \raggedright \ExplSyntaxOn \seq_new:N \l_testa_seq @@ -625,18 +641,17 @@ With~control:~\seq_use:Nnnn \l_testa_seq { ,~ } { ,~} { ,~ }\\ } Without~control:~\seq_use:Nnnn \l_testa_seq { ,~ } { ,~} { ,~ }\\ \ExplSyntaxOff -% \end{macrocode} %</test&GS.cut.EAN.control.digit> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}{\int_set_to_EAN_control_digit:NN} -% Sets an integer to the control digit calculated with the EAN control digit -% algorithm for a given code sequence. Note, that the complete code -% sequence will be used to calculate the control digit. So, if you have a -% EAN-8 or EAN-13 code sequence, you should cut of the control digit first. +% Sets an integer to the control digit calculated with the EAN control digit +% algorithm for a given code sequence. Note, that the complete code +% sequence will be used to calculate the control digit. So, if you have a +% EAN-8 or EAN-13 code sequence, you should cut of the control digit first. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \int_set_to_EAN_control_digit:NN #1#2 { \int_zero:N #1 @@ -656,13 +671,12 @@ Without~control:~\seq_use:Nnnn \l_testa_seq { ,~ } { ,~} { ,~ }\\ } \int_set:Nn #1 { \int_mod:nn { 10 - \int_mod:nn { #1 } { 10 } } { 10 } } } +%</package> % \end{macrocode} -% \TestFiles{int_set_to_EAN_control_digit.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&int.set.to.EAN.control.digit> +% \TestFiles{int_set_to_EAN_control_digit.tex}\UnitTested % \begin{macrocode} +%<*test&int.set.to.EAN.control.digit> \ExplSyntaxOn \seq_new:N \l_testa_seq \tl_new:N \l_control_tl @@ -681,28 +695,26 @@ Control~digit~should~be~\tl_use:N \l_control_tl{} ~ { \int_set_to_EAN_control_digit:NN } } \ExplSyntaxOff -% \end{macrocode} %</test&int.set.to.EAN.control.digit> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}{\GS_set_EAN_control_digit:N} % Add a new control digit to a EAN sequence % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \GS_set_EAN_control_digit:N #1 { \GS_cut_EAN_control_digit:N #1 \int_set_to_EAN_control_digit:NN \l_tmpa_int #1 \seq_put_right:NV #1 \l_tmpa_int } +%</package> % \end{macrocode} -% \TestFiles{GS_set_EAN_control_digit.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&GS.set.EAN.control.digit> +% \TestFiles{GS_set_EAN_control_digit.tex}\UnitTested % \begin{macrocode} +%<*test&GS.set.EAN.control.digit> \ExplSyntaxOn \seq_new:N \l_testa_seq \GS_set_code_digit_seq:Nn \l_testa_seq {ISBN 978-3-86541-459-5} @@ -720,17 +732,15 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ ~but~it~\tl_use:N \t_testa_tl . \msg_error:nnn { GS1/test } { function } { \GS_set_EAN_control_digit:N } } - \ExplSyntaxOff -% \end{macrocode} %</test&GS.set.EAN.control.digit> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}{\__GS_modules:Nn, \__GS_modules:NnN, \__GS_modules:cn, % \__GS_modules_start_black:Nn, \__GS_modules_start_white:Nn} % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \@@_modules:Nn #1#2 { \seq_map_inline:Nn #1 @@ -775,6 +785,7 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ } \cs_generate_variant:Nn \@@_modules:Nn { c } +%</package> % \end{macrocode} % \TestFiles{EANBarcode.tex}\UnitTested % \end{macro} @@ -783,6 +794,7 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ % Puts the digits, rules, and gaps for an EAN barcode into the input % stream. % \begin{macrocode} +%<*package> \cs_new_nopar:Npn \GS_use_as_EAN_barcode:N #1 { \seq_set_eq:NN \l_@@_code_seq #1 @@ -829,6 +841,7 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ \hbox_to_wd:nn { \l_GS_module_wd_dim * 7 } { } } +%</package> % \end{macrocode} % \TestFiles{EANBarcode.tex}\UnitTested % \end{macro} @@ -839,6 +852,7 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ % % For this, additional packages are needed: % \begin{macrocode} +%<*package> \RequirePackage{xparse} % \end{macrocode} % @@ -854,13 +868,12 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ \int_to_arabic:n { \l_tmpa_int } \group_end: } +%</package> % \end{macrocode} % \TestFiles{EANControlDigit.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&EANControlDigit> % \begin{macrocode} +%<*test&EANControlDigit> \begin{tabular}{ll} \hline Calculated & Known \\ @@ -871,14 +884,13 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ EAN-8: 2012345\EANControlDigit{2012345} & EAN-8: 20123451 \\ \hline \end{tabular} -% \end{macrocode} %</test&EANControlDigit> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}{\EANBarcode} % \begin{macrocode} +%<*package> \NewDocumentCommand \EANBarcode { o m } { @@ -950,13 +962,12 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ \box_use:N \l_tmpa_box \group_end: } +%</package> % \end{macrocode} % \TestFiles{EANBarcode.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&EANBarcode|GSSetup> % \begin{macrocode} +%<*test&EANBarcode|GSSetup> \raggedright \verb|\EANBarcode{ISBN 978-3-86541-459-5}|: \EANBarcode{ISBN 978-3-86541-459-5} @@ -973,24 +984,22 @@ Control~digit~should~be~ \tl_use:N \l_testb_tl {} ~ \verb|\EANBarcode[code=EAN-8,ocrb=false,add_control]{2012345}|: \EANBarcode[code=EAN-8,ocrb=false,add_control]{2012345} -% \end{macrocode} %</test&EANBarcode|GSSetup> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % % \begin{macro}{\GSSetup} % \begin{macrocode} +%<*package> \NewDocumentCommand \GSSetup { m } { \keys_set:nn { GS1 } { #1 } } +%</package> % \end{macrocode} -% \TestFiles{GSSetup.tex}\UnitTested % -% \iffalse meta-comment -%</package> -%<*test&GSSetup> +% \TestFiles{GSSetup.tex}\UnitTested % \begin{macrocode} +%<*test&GSSetup> After \verb|\GSSetup{ocrb=false,add_control}|: \GSSetup{ocrb=false,add_control} @@ -1001,17 +1010,12 @@ After \verb|\GSSetup{ocrb=false,add_control}|: \EANBarcode[code=EAN-8,ocrb,add_control=false]{20123451} %</test&GSSetup> -%<*package> -% \fi +% \end{macrocode} % \end{macro} % -% % \iffalse -%</package> %<*test> -% \begin{macrocode} \end{document} -% \end{macrocode} %</test> % \fi % \end{implementation} |