diff options
author | Karl Berry <karl@freefriends.org> | 2021-08-11 20:15:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-08-11 20:15:57 +0000 |
commit | 78a278be7587c8b6321671f24a56203a546533f6 (patch) | |
tree | 76174091613e8886253acfdf56ea20ac3b7d8c7a /Master/texmf-dist/source/latex | |
parent | 3327e9d91f2fa85e634543a2769202bddc83018a (diff) |
tipauni (11aug21)
git-svn-id: svn://tug.org/texlive/trunk@60220 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/tipauni/tipauni.dtx | 536 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/tipauni/tipauni.ins | 10 |
2 files changed, 401 insertions, 145 deletions
diff --git a/Master/texmf-dist/source/latex/tipauni/tipauni.dtx b/Master/texmf-dist/source/latex/tipauni/tipauni.dtx index e83e5af260d..be9b509fd25 100644 --- a/Master/texmf-dist/source/latex/tipauni/tipauni.dtx +++ b/Master/texmf-dist/source/latex/tipauni/tipauni.dtx @@ -3,15 +3,15 @@ % File: tipauni.dtx % --------------------------------------------------------------------------- % Package: tipauni -% Author: Niranjan -% Version: v0.1 (27 April, 2021) +% Author: निरंजन +% Version: v0.2 (11 August, 2021) % Description: For producing Unicode characters with TIPA commands. % Repository: https://gitlab.com/niruvt/tipauni % Bug tracker: https://gitlab.com/niruvt/tipauni/-/issues -% License: GPL v3.0+ +% License: GPL v3.0+, GFDL v1.3+ % --------------------------------------------------------------------------- -% LaTeX Package tipauni v0.1 -% © 2021 Niranjan +% LaTeX Package tipauni v0.2 +% © 2021 निरंजन % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ % You should have received a copy of the GNU General Public License % along with this program. If not, see <https://www.gnu.org/licenses/>. % -% The current maintainer of this work is Niranjan. +% The current maintainer of this work is निरंजन. % % This work consists of the files tipauni.dtx % tipauni.ins @@ -39,12 +39,12 @@ %<*readme> -------------------------------------------------------------------------- Package: tipauni -Author: Niranjan -Version: v0.1 (27 April, 2021) +Author: निरंजन +Version: v0.2 (11 August, 2021) Description: For producing Unicode characters with TIPA commands. Repository: https://gitlab.com/niruvt/tipauni Bug tracker: https://gitlab.com/niruvt/tipauni/-/issues -License: GPL v3.0+ +License: GPL v3.0+, GFDL v1.3+ -------------------------------------------------------------------------- %</readme> %<*internal> @@ -52,8 +52,8 @@ License: GPL v3.0+ %</internal> %<*driver|package> \def\tipauniname{tipauni} -\def\tipauniversion{0.1} -\def\tipaunidate{2021/04/27} +\def\tipauniversion{0.2} +\def\tipaunidate{2021-08-07} \def\tipaunidescription{For producing Unicode characters with TIPA commands} %</driver|package> %<*driver> @@ -66,9 +66,15 @@ License: GPL v3.0+ \usepackage{booktabs} \usepackage{float} \usepackage{xcolor} -\usepackage{dtk-logos} +\usepackage{hologo} +\DeclareRobustCommand\XeLaTeX{\hologo{XeLaTeX}} \usepackage{fontspec} \newfontfamily{\ipa}[Color=blue]{CharisSIL} +\newfontfamily{\devtext}[% +Script=Devanagari,% +Renderer=Harfbuzz,% +Scale=0.8% +]{Shobhika} \usepackage{hyperref} \hypersetup{% colorlinks,% @@ -85,7 +91,7 @@ License: GPL v3.0+ %</driver> % \fi % \title{The \pkg{\tipauniname} package} -% \author{Niranjan\thanks{\faIcon{envelope}\quad\href{mailto:hi.niranjan@pm.me}{\ttfamily hi.niranjan@pm.me}}} +% \author{{\devtext निरंजन}\thanks{\faIcon{envelope}\quad\href{mailto:hi.niranjan@pm.me}{\ttfamily hi.niranjan@pm.me}}} % \date^^A % {^^A % Version \tipauniversion\ --- \tipaunidate\\[1ex]^^A @@ -99,7 +105,7 @@ License: GPL v3.0+ % \vfill % {% % \setlength{\parindent}{0pt} -% © 2021 Niranjan +% © 2021 {\devtext निरंजन} % % Permission is granted to copy, distribute and/or modify this document under % the terms of the GNU Free Documentation License, Version 1.3 or any later @@ -126,8 +132,14 @@ License: GPL v3.0+ % % \section{Acknowledgements} % This package is completed because of the rigorous help by Jairo A.\ del Rio, -% Jonathan P.\ Spratte \textit{\&} Ulrike Fischer. Their suggestions and -% contributions are extremely valuable for the development of this package. +% Jonathan P.\ Spratte, Phelype Oleinink \textit{\&} Ulrike Fischer. Their +% suggestions and contributions are extremely valuable for the development of +% this package. +% +% Jonathan P.\ Spratte has helped the package by building a parser based on +% \pkg{expl3}. Phelype Oleinik has helped the package by building a test-suit +% for regression-tests. The tests can be seen in the git-repository of the +% project. % % \section{Package options} % @@ -429,9 +441,7 @@ Unicode characters with TIPA commands] % \begin{macrocode} \RequirePackage{xparse} \RequirePackage{fontspec} -\RequirePackage{environ} \RequirePackage{xkeyval} -\RequirePackage{ifthen} % \end{macrocode} % Package options are provided using the package \pkg{xkeyval}. The following % commands provide the option \verb|documentfont|. @@ -704,153 +714,399 @@ Unicode characters with TIPA commands] \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi }% \DeclareTextAccentDefault{\@pipeshorthands}{TU} -\NewDocumentCommand\super{ m }{% - \ifthenelse{\equal{#1}{h}}{ʰ}{\relax}% - \ifthenelse{\equal{#1}{w}}{ʷ}{\relax}% - \ifthenelse{\equal{#1}{j}}{ʲ}{\relax}% - \ifthenelse{\equal{#1}{ɣ}}{ˠ}{\relax}% - \ifthenelse{\equal{#1}{ʕ}}{ˤ}{\relax}% - \ifthenelse{\equal{#1}{n}}{ⁿ}{\relax}% - \ifthenelse{\equal{#1}{l}}{ˡ}{\relax}% -}% -% \end{macrocode} -% The replacement of several characters with different IPA symbols will be done -% in a small loop. That loop will loop over the contents of a sequence, and each -% sequence element will contain two token-list elements (braced groups), -% specifying a regular expression (really just one or two characters, nothing -% complicated) and the replacement text for that expression. -% \begin{macrocode} \ExplSyntaxOn -\seq_new:N \l__tipauni_replace_maps_seq -\seq_new:N \l__tipauni_remove_from_accents_seq -\tl_new:N \l__tipauni_textipa_tl -% \end{macrocode} -% The sequence \cs{l__tipauni_replace_maps_seq} stores the replacement mappings, -% we have to keep in mind that these are regular expressions in the first braced -% group, so characters that are not alpha-numeric should be escaped. Also, since -% we're using \cs{seq_set_split:Nnn} here (which doesn't ignore empty elements) -% we have to make sure to not put too many commas in the list. -% First we set the mappings in a temporary sequence to pre-build the regular -% expressions to gain at least a bit of speed. -% \begin{macrocode} -\seq_set_split:Nnn \l_tmpa_seq { , } - { -% \end{macrocode} -% First we put the composites, which should have highest priority into the - % sequence (with some escaping of the characters which aren't alpha-numeric): -% \begin{macrocode} - { \c{\! | tipaunibang } G }{ʛ}, - { \c{\! | tipaunibang } g }{ɠ}, - { \c{\* | tipaunistar } 1 }{ʢ}, - { \c{\* | tipaunistar } 2 }{ʡ}, - { \c{\* | tipaunistar } 3 }{ɧ}, - { \c{\* | tipaunistar } Z }{ʑ}, - { \c{\: | tipaunicolon } R }{ɻ}, - { \c{\; | tipaunisemicolon} A }{ᴀ}, - { \c{\; | tipaunisemicolon} G }{ɢ}, - { \c{\; | tipaunisemicolon} B }{ʙ}, - { \c{\; | tipaunisemicolon} E }{ᴇ}, - { \c{\; | tipaunisemicolon} H }{ʜ}, - { \c{\; | tipaunisemicolon} J }{ᴊ}, - { \c{\; | tipaunisemicolon} L }{ʟ}, - { \c{\; | tipaunisemicolon} N }{ɴ}, - { \c{\; | tipaunisemicolon} R }{ʀ}, - { \c{\; | tipaunisemicolon} U }{ᴜ}, -% \end{macrocode} -% Next the multi-letter mappings: -% \begin{macrocode} - {\|\|}{ǁ}, {\"\"}{ˌ}, -% \end{macrocode} -% And finally the remaining single-letter mappings: -% \begin{macrocode} - {5}{ɐ}, {A}{ɑ}, {6}{ɒ}, {2}{ʌ}, {B}{β}, {C}{ɕ}, {D}{ð}, {9}{ɘ}, {E}{ɛ}, - {3}{ɜ}, {g}{ɡ}, {G}{ɣ}, {7}{ɤ}, {H}{ɦ}, {L}{ʎ}, {4}{ɥ}, {1}{ɨ}, {I}{ɪ}, - {J}{ʝ}, {M}{ɱ}, {W}{ɯ}, {N}{ŋ}, {8}{ɵ}, {O}{ɔ}, {F}{ɸ}, {R}{ɾ}, {K}{ʁ}, - {S}{ʃ}, {T}{θ}, {0}{ʉ}, {U}{ʊ}, {V}{ʋ}, {X}{χ}, {Y}{ʏ}, {Z}{ʒ}, - {P}{ʔ}, {Q}{ʕ}, - {\:}{ː}, {\;}{ˑ}, {\!}{ǃ}, {\&}{ɞ}, {\@}{ə}, {\|}{ǀ}, {\"}{ˈ} - } -% \end{macrocode} -% Now we build the real sequence from the temporary one. We have to call -% \cs{regex_const:Nn} for each item to precompile the regular expressions, then -% store the regular expressions name and the replacement in the correct -% sequence. -% \begin{macrocode} -\seq_clear:N \l__tipauni_replace_maps_seq -\seq_map_inline:Nn \l_tmpa_seq - { - \exp_args:Nco \regex_const:Nn - { c__tipauni_ \exp_args:No \tl_to_str:n { \use_i:nn #1 } _regex } - { \use_i:nn #1 } - \seq_put_right:Nx \l__tipauni_replace_maps_seq +\NewDocumentCommand \super { m } + {% + \str_case:nn {#1} { - \exp_not:c - { c__tipauni_ \exp_args:No \tl_to_str:n { \use_i:nn #1 } _regex } - { \exp_not:o { \use_ii:nn #1 } } + {h} {ʰ} + {w} {ʷ} + {j} {ʲ} + {ɣ} {ˠ} + {ʕ} {ˤ} + {n} {ⁿ} + {l} {ˡ} } } % \end{macrocode} +% We need a few variables. +% \begin{macrocode} +\seq_new:N \l_@@_remove_from_accents_seq +\tl_new:N \l_@@_textipa_tl +% \end{macrocode} % Since we have a non-standard syntax for some of the accent macros (having a % starred variant) we have to exclude them from the list of accents which get % special handling from \cs{text_expand:n} or else the stars will be surrounded % by braces and not found by \cs{@ifstar}. This sequence stores the problematic % accents which need to be excluded. % \begin{macrocode} -\seq_set_split:Nnn \l__tipauni_remove_from_accents_seq { , } +\seq_set_split:Nnn \l_@@_remove_from_accents_seq { , } { \~, \=, \", \r, \v, \t } % \end{macrocode} +% We only search for the macros not contained in \pkg{tipa} if this is requested +% by the user. +% \begin{macrocode} +\ifnontipaignore + \cs_new_eq:NN \@@_nontipa_search: \prg_do_nothing: + \cs_new_eq:NN \@@_nontipa_search:n \use_none:n +\else + \cs_new_protected:Npn \@@_nontipa_search: + { + \unless\ifnontipa + \exp_args:No \@@_nontipa_search:n \l_@@_textipa_tl + \fi + } +% \end{macrocode} +% The warning thrown at the end of the run doesn't list which symbols were +% incompatible, so we stop searching when we found one incompatible symbol. We +% use \cs{str_if_in:nnT} so that groups don't affect the search. The alternative +% would be the much slower \cs{regex_match:nnT}. +% \begin{macrocode} + \cs_new_protected:Npn \@@_nontipa_search:n #1 + { + \str_if_in:nnT {#1} {ⱱ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ɞ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ɰ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ǃ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ǂ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ʢ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ɺ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ʑ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \str_if_in:nnT {#1} {ɧ} { \nontipatrue \use_none_delimet_by_s_stop:w } + \use_none:nnn \s_stop + \use:n { \cs_gset_eq:NN \@@_nontipa_search: \prg_do_nothing: } + } +\fi +% \end{macrocode} +% The user facing macro needs to make some local settings. % \begin{macrocode} -\cs_new_protected:Npn \__tipauni_nontipa_search:n #1 - { - \regex_match:nnT {ⱱ} {#1} \nontipatrue - \regex_match:nnT {ɞ} {#1} \nontipatrue - \regex_match:nnT {ɰ} {#1} \nontipatrue - \regex_match:nnT {ǃ} {#1} \nontipatrue - \regex_match:nnT {ǂ} {#1} \nontipatrue - \regex_match:nnT {ʢ} {#1} \nontipatrue - \regex_match:nnT {ɺ} {#1} \nontipatrue - \regex_match:nnT {ʑ} {#1} \nontipatrue - \regex_match:nnT {ɧ} {#1} \nontipatrue - } -\cs_generate_variant:Nn \__tipauni_nontipa_search:n { o } \NewDocumentCommand\textipa{ +m }% { \begingroup - \let\*\tipaunistar - \let\:\tipaunicolon - \let\;\tipaunisemicolon - \let\!\tipaunibang - \let\|\tipaunipipe - \let\t\tipaunit - \catcode`\&=11 + \let\*\tipaunistar + \let\:\tipaunicolon + \let\;\tipaunisemicolon + \let\!\tipaunibang + \let\|\tipaunipipe + \let\t\tipaunit % \end{macrocode} % Here we locally remove the accents which have a starred variant from the % exclusion list of \cs{text_expand:n}. % \begin{macrocode} - \seq_map_inline:Nn \l__tipauni_remove_from_accents_seq + \seq_map_inline:Nn \l_@@_remove_from_accents_seq { \tl_remove_all:Nn \l_text_accents_tl {##1} } % \end{macrocode} % Here is the real replacement. First we carefully expand the input using -% \cs{text_expand:n}, then we'll loop over the sequence. Since each sequence -% element contains two brace groups we can use the element |##1| directly as the -% two normal argument to \cs{regex_replace_all:NnN}. -% \begin{macrocode} - \tl_set:Nx \l__tipauni_textipa_tl { \text_expand:n {#1} } - \seq_map_inline:Nn \l__tipauni_replace_maps_seq - { \regex_replace_all:NnN ##1 \l__tipauni_textipa_tl } - \l__tipauni_textipa_tl -% \end{macrocode} -% Finally test for \pkg{tipa}-incompatible symbols. We only test for the -% incompatible symbols if the boolean is not yet true to save a bit of -% processing time when the tests are not necessary. Since the used -% \cs{regex_match:nnT} test needs the token list expanded we expand it only once -% here with the |o|-variant. -% \begin{macrocode} - \unless\ifnontipa - \__tipauni_nontipa_search:o \l__tipauni_textipa_tl - \fi +% \cs{text_expand:n}, then we'll loop over the token list with a construct +% similar to the \pkg{expl3} internal \cs{__tl_act:NNNn} (hence the name +% \cs{@@_act:n}). Since the replacement code depends on the correct string +% representation of things we explicitly set the \cs{escapechar} to a backslash +% and reset it afterwards. +% \begin{macrocode} + \tl_set:Nx \l_@@_textipa_tl { \text_expand:n {#1} } + \use:x + { + \exp_not:n + { + \escapechar = `\\ + \tl_set:Nx \l_@@_textipa_tl + { \exp_args:No \@@_act:n \l_@@_textipa_tl } + \escapechar = + } + \int_use:N \escapechar + } + \exp_stop_f: + \l_@@_textipa_tl +% \end{macrocode} +% Finally test for \pkg{tipa}-incompatible symbols. +% \begin{macrocode} + \@@_nontipa_search: \endgroup } +% \end{macrocode} +% We'll need a scan mark for the |act| code, so we initialise it. +% \begin{macrocode} +\scan_new:N \s_@@_act_stop +\cs_new:Npn \@@_use_none_delimit_by_act_stop:w #1 \s_@@_act_stop {} +% \end{macrocode} +% The act macro uses a bit of low level coding to get good performance. It +% implements a loop which does the replacement of single letters, bigraphs or +% combinations of one macro and one letter (which might be separated from the +% macro by multiple spaces, or contained in braces as an argument, or both). +% \cs{_@@_act:n} should be used inside an |x|-expansion context. The only +% token which is not allowed to be ever part of the argument for +% \cs{_@@_act:n} is \cs{s_@@_act_stop}. +% \begin{macrocode} +\cs_new:Npn \@@_act:n #1 { \@@_act_loop:w #1 {\s_@@_act_stop} . \s_@@_act_stop } +% \end{macrocode} +% Just to have an easier to spot output we use a private copy of \cs{exp_not:n}, +% meaning we leave the output in the input stream (but since the whole loop +% should be used in an |x|-expansion context this is fine, anything expecting +% arguments will get those later). +% \begin{macrocode} +\cs_new_eq:NN \@@_act_output:n \exp_not:n +% \end{macrocode} +% The current loop status is indicated by one macro -- \cs{use_none:nn} for the +% initial state; \cs{@@_act_macro:nn} if a macro being the start of a +% bigraph was encountered; or \cs{@@_act_char:nn} if a character being +% the start of a bigraph or a monograph was encountered -- followed by one +% |n|-type argument containing information depending on the state. So for +% \cs{@@_act_loop:Nnw} the arguments are: |#1| is the status macro, |#2| +% more status information, |#3| the remainder of the argument list. It'll branch +% off depending on the first token in |#3| being either a space, a group +% (anything started by a character of category 1, typically an opening brace) +% and anything else (a valid |N|-type argument). +% \begin{macrocode} +\cs_new:Npn \@@_act_loop:w { \@@_act_loop:Nnw \use_none:nn {} } +\cs_new:Npn \@@_act_loop:Nnw #1#2#3 \s_@@_act_stop + { + \@@_act_if_head_is_space:nTF {#3} + { \@@_act_space:Nnw } + { + \tl_if_head_is_group:nTF {#3} + \@@_act_group:Nnn + \@@_act_normal:NnN + } + #1 {#2} #3 \s_@@_act_stop + } +% \end{macrocode} +% We'll need a few explicit space tokens in the following definitions, so we use +% a temporary macro to set this up. +% \begin{macrocode} +\group_begin: + \cs_set:Npn \@@_tmp:n #1 + { +% \end{macrocode} +% Quick test for a leading space using the |stop|-marker. +% \begin{macrocode} + \cs_new:Npn \@@_act_if_head_is_space:nTF ##1 + { + \@@_act_if_head_is_space:w + \s_@@_act_stop ##1 \s_@@_act_stop + \@@_act_if_head_is_space_true:w + \s_@@_act_stop #1 \s_@@_act_stop + \use_ii:nn + } + \cs_new:Npn \@@_act_if_head_is_space:w + ##1 \s_@@_act_stop #1 ##2 \s_@@_act_stop + {} + \cs_new:Npn \@@_act_if_head_is_space_true:w + \s_@@_act_stop #1 \s_@@_act_stop \use_ii:nn ##1 ##2 + {##1} +% \end{macrocode} +% The case with a space needs a bit of special treatment if the current state is +% |macro|. In that case we defer the decision and save the space inside the +% additional status |n|-type argument. That consists of two nested |n|-type +% arguments, the first being the control sequence under test and the second +% tokens which need to be reinserted should the replacement fail. +% \begin{macrocode} + \cs_new:Npn \@@_act_space:Nnw ##1 ##2 #1 + { + \token_if_eq_meaning:NNTF ##1 \@@_act_macro:nn + { \@@_act_space_macro:nn ##2 } + { + \cs_if_exist_use:cTF { @@_act_char_mono_ \tl_to_str:n { ##2 } : } + { \@@_act_output:n {~} } + { \@@_act_output:n { ##2 ~ } } + \@@_act_loop:w + } + } + } + \@@_tmp:n {~} +\group_end: +% \end{macrocode} +% This macro just works as a helper to get the two separate arguments in the +% status and append a space token to the deferred list. +% \begin{macrocode} +\cs_new:Npn \@@_act_space_macro:nn #1#2 + { \@@_act_loop:Nnw \@@_act_macro:nn { {#1} { #2 ~ } } } +% \end{macrocode} +% The end marker is a single \cs{s_@@_act_stop} in a group, hence we need to +% test for that. If this isn't the end we need to handle two different cases, if +% the current state is a macro the group might actually be the correct argument +% to that macro, else a bigraph shouldn't contain a group, so we output what +% ever the current status deferred information was (either as a |mono| +% replacement or just as is) and act on the group. +% \begin{macrocode} +\cs_new:Npn \@@_act_group:Nnn #1#2#3 + { + \@@_use_none_delimit_by_act_stop:w + #3 \@@_act_final:Nnw #1 {#2} \s_@@_act_stop + \token_if_eq_meaning:NNTF #1 \@@_act_macro:nn + { \@@_act_group_macro:nn {#2} {#3} } + { + \cs_if_exist_use:cF { @@_act_char_mono_ \tl_to_str:n { #2 } : } + { \@@_act_output:n {#2} } + { \@@_act_loop:w #3 {\s_@@_act_stop} . \s_@@_act_stop } + } + \@@_act_loop:w + } +% \end{macrocode} +% The final code needs to remove the remainder of the loop and reinsert whatever +% was deferred, unless that happens to be one of the single tokens to be +% replaced in which case we do the replacement. +% \begin{macrocode} +\cs_new:Npn \@@_act_final:Nnw + #1#2 \s_@@_act_stop #3 \@@_act_loop:w #4 \s_@@_act_stop + { + \cs_if_exist_use:cF { @@_act_char_mono_ \tl_to_str:n { #2 } : } + { + \token_if_eq_meaning:NNTF #1 \@@_act_macro:nn + { \exp_args:No \@@_act_output:n { \use:nn #2 } } + { \@@_act_output:n {#2} } + } + } +% \end{macrocode} +% The normal case is pretty straight forward, if the current state is the +% initial state, check whether the token under test is the start of one of the +% replacement sequences (this would be stored inside a macro), if it isn't +% directly output it. If it is the code in that macro will do the right thing. +% If the current state is something else the state macro will handle things, so +% we just call it with the arguments it should get. +% \begin{macrocode} +\cs_new:Npn \@@_act_normal:NnN #1#2#3 + { + \token_if_eq_meaning:NNTF #1 \use_none:nn + { + \cs_if_exist_use:cF { @@_act_normal_ \tl_to_str:n {#3} :nw } + { \@@_act_output:n } + {#3} + } + { #1 {#2} {#3} } + \@@_act_loop:w + } +% \end{macrocode} +% The code that should handle a macro will test whether a replacement occurs +% (stored inside a macro), if it does calls that macro, else outputs the +% deferred information. Since the |macro| state will have two groups in the +% deferred state we need to handle that using \cs{use_i:nn} to get the macro +% name, and \cs{use:nn} to just unbrace the macro and the other deferred tokens +% (which might be any number of spaces). +% \begin{macrocode} +\cs_new:Npn \@@_act_macro:nn #1#2 + { + \cs_if_exist_use:cF + { @@_act_macro_ \exp_args:No \tl_to_str:n { \use_i:nn #1 / #2 } : } + { \exp_args:No \@@_act_output:n { \use:nn #1 #2 } } + } +% \end{macrocode} +% If the |macro| state was active when a group was encountered we need to check +% whether that group was the correct argument for the replacement, if it was do +% the replacement, else reinsert the macro and deferred tokens and loop through +% the group. +% \begin{macrocode} +\cs_new:Npn \@@_act_group_macro:nn #1#2 + { + \cs_if_exist_use:cF + { @@_act_macro_ \exp_args:No \tl_to_str:n { \use_i:nn #1 / #2 } : } + { + \exp_args:No \@@_act_output:n { \use:nn #1 } + { \@@_act_loop:w #2 {\s_@@_act_stop} . \s_@@_act_stop } + } + } +% \end{macrocode} +% If the |char| state is active we need to check whether a bigraph was found, if +% so do that replacement, else test whether the single char is to be replaced +% without being part of a bigraph, if not output it unchanged. If there was no +% bigraph the newly found character might be the start of a mono- or bigraph so +% we pass it back to the |N|-type act to evaluate that, in which case we need +% to remove a trailing \cs{@@_act_loop:w} which would start the next loop which +% we do using \cs{use_i:nn}. +% \begin{macrocode} +\cs_new:Npn \@@_act_char:nn #1#2 + { + \cs_if_exist_use:cF { @@_act_char_bigraph_ \tl_to_str:n { #1/#2 } : } + { + \cs_if_exist_use:cF { @@_act_char_mono_ \tl_to_str:n { #1 } : } + { \@@_act_output:n {#1} } + \use_i:nn { \@@_act_normal:NnN \use_none:nn {} {#2} } + } + } +% \end{macrocode} +% To register new bigraphs we use the following functions. The information is +% always stored inside two macros, the first is called +% |@@_act_normal_|\meta{first token}|:nw| and will set the correct state, the +% second is named dependent on the state it should be found in, either +% |@@_act_macro_|\meta{first token}|/|\meta{second token}|:|, +% |@@_act_char_bigraph_|\meta{first token}|/|\meta{second token}|:|, or +% |@@_act_char_mono_|\meta{token}|:|. Those second macros contain the actual +% replacement. +% +% The first macro is a wrapper which just inputs \cs{@@_new_macro_bigraph:NNn} +% for the two macros in |#1| and |#2|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_new_macro_pair_bigraph:NNNn #1#2#3#4 + { + \@@_new_macro_bigraph:NNn #1 #3 {#4} + \@@_new_macro_bigraph:NNn #2 #3 {#4} + } +% \end{macrocode} +% A macro bigraph should consist of a control sequence followed by another +% token. It'll switch the state to |macro|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_new_macro_bigraph:NNn #1#2#3 + { + \cs_gset:cpn { @@_act_normal_ \tl_to_str:n {#1} :nw } ##1##2 \@@_act_loop:w + { \@@_act_loop:Nnw \@@_act_macro:nn { {##1} {} } } + \cs_gset:cpn { @@_act_macro_ \tl_to_str:n { #1/#2 } : } + { \@@_act_output:n {#3} } + } +% \end{macrocode} +% A character bigraph should consist of two characters. It'll switch the state +% to |char|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_new_char_bigraph:NNn #1#2#3 + { + \cs_gset:cpn { @@_act_normal_ \tl_to_str:n {#1} :nw } ##1##2 \@@_act_loop:w + { \@@_act_loop:Nnw \@@_act_char:nn {##1} } + \cs_gset:cpn { @@_act_char_bigraph_ \tl_to_str:n { #1/#2 } : } + { \@@_act_output:n {#3} } + } +% \end{macrocode} +% And lastly the single replacements which should just be a single character. +% These will also switch the state to |char| (as they might be also a start of +% a bigraph). +% \begin{macrocode} +\cs_new_protected:Npn \@@_new_char_mono:Nn #1#2 + { + \cs_gset:cpn { @@_act_normal_ \tl_to_str:n {#1} :nw } ##1##2 \@@_act_loop:w + { \@@_act_loop:Nnw \@@_act_char:nn {##1} } + \cs_gset:cpn { @@_act_char_mono_ \tl_to_str:n {#1} : } + { \@@_act_output:n {#2} } + } +% \end{macrocode} +% Everything that's now missing is defining the macros storing the replacements +% as described above. +% \begin{macrocode} +\@@_new_macro_pair_bigraph:NNNn \! \tipaunibang G {ʛ} +\@@_new_macro_pair_bigraph:NNNn \! \tipaunibang g {ɠ} +\@@_new_macro_pair_bigraph:NNNn \* \tipaunistar 1 {ʢ} +\@@_new_macro_pair_bigraph:NNNn \* \tipaunistar 2 {ʡ} +\@@_new_macro_pair_bigraph:NNNn \* \tipaunistar 3 {ɧ} +\@@_new_macro_pair_bigraph:NNNn \* \tipaunistar Z {ʑ} +\@@_new_macro_pair_bigraph:NNNn \: \tipaunicolon R {ɻ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon A {ᴀ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon G {ɢ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon B {ʙ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon E {ᴇ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon H {ʜ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon J {ᴊ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon L {ʟ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon N {ɴ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon R {ʀ} +\@@_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon U {ᴜ} +\@@_new_char_bigraph:NNn || {ǁ} +\@@_new_char_bigraph:NNn "" {ˌ} +\clist_map_inline:nn + { + {5}{ɐ}, {A}{ɑ}, {6}{ɒ}, {2}{ʌ}, {B}{β}, {C}{ɕ}, {D}{ð}, {9}{ɘ}, {E}{ɛ}, + {3}{ɜ}, {g}{ɡ}, {G}{ɣ}, {7}{ɤ}, {H}{ɦ}, {L}{ʎ}, {4}{ɥ}, {1}{ɨ}, {I}{ɪ}, + {J}{ʝ}, {M}{ɱ}, {W}{ɯ}, {N}{ŋ}, {8}{ɵ}, {O}{ɔ}, {F}{ɸ}, {R}{ɾ}, {K}{ʁ}, + {S}{ʃ}, {T}{θ}, {0}{ʉ}, {U}{ʊ}, {V}{ʋ}, {X}{χ}, {Y}{ʏ}, {Z}{ʒ}, + {P}{ʔ}, {Q}{ʕ}, + {:}{ː}, {;}{ˑ}, {!}{ǃ}, {&}{ɞ}, {@}{ə}, {|}{ǀ}, {"}{ˈ} + } + { \@@_new_char_mono:Nn #1 } \ExplSyntaxOff % \end{macrocode} % The following commands define the long commands for dependent diacritics. @@ -925,7 +1181,7 @@ Unicode characters with TIPA commands] % \end{macrocode} % Lastly the code for environment \texttt{IPA} is provided by the following. % \begin{macrocode} -\NewEnviron{IPA}{\textipa{\BODY}} +\NewDocumentEnvironment{IPA}{+b}{\textipa{#1}}{} % \end{macrocode} % \begin{macrocode} %</package> diff --git a/Master/texmf-dist/source/latex/tipauni/tipauni.ins b/Master/texmf-dist/source/latex/tipauni/tipauni.ins index cdcc0d8ee58..9d95201d6a9 100644 --- a/Master/texmf-dist/source/latex/tipauni/tipauni.ins +++ b/Master/texmf-dist/source/latex/tipauni/tipauni.ins @@ -8,15 +8,15 @@ --------------------------------------------------------------------------- Package: tipauni -Author: Niranjan +Author: निरंजन Description: For producing Unicode characters with TIPA commands. Repository: https://gitlab.com/niruvt/tipauni Bug tracker: https://gitlab.com/niruvt/tipauni/-/issues License: GPL v3.0+ --------------------------------------------------------------------------- -LaTeX Package tipauni v0.1 -© 2021 Niranjan +LaTeX Package tipauni v0.2 +© 2021 निरंजन This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. -The current maintainers of this work are Niranjan. +The current maintainers of this work are निरंजन. This work consists of the files tipauni.dtx tipauni.ins @@ -51,4 +51,4 @@ and the derived file tipauni.sty. \file{README.txt}{\from{\jobname.dtx}{readme}} } -\endbatchfile
\ No newline at end of file +\endbatchfile |