diff options
author | Karl Berry <karl@freefriends.org> | 2023-02-21 20:51:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-02-21 20:51:02 +0000 |
commit | 8ccd5660da0d8469a4812788ae6e5939f9612140 (patch) | |
tree | 05540dbefde686b3d2265189dc6c9a8af4bb19d3 /Master/texmf-dist/tex | |
parent | ba471fee0fecefbb27dc4d5629f8205ddc83bc13 (diff) |
langsci-avm (21feb23) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2022.final@66030 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty | 569 |
1 files changed, 384 insertions, 185 deletions
diff --git a/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty b/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty index e7908b7d273..9c879e809f6 100644 --- a/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty +++ b/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty @@ -7,23 +7,18 @@ %% langsci-avm.dtx (with options: `package') %% ------------------------------------------------------------------------------ %% -%% langsci-avm is aimed at typesetting beautiful feature structures, -%% also known as attribute-value matrices (AVMs), for use in linguistics. +%% A package for typesetting feature structures, also known as attribute-value +%% matrices (AVMs), for use in linguistics. %% -%% The package provides a minimal and easy to read syntax. -%% It depends only on the array package and can be placed almost everywhere, -%% in particular in footnotes or graphs and tree structures. The package is meant -%% as an update to, and serves the same purpose as, Christopher Manning’s -%% avm package, but shares no code base with that package. +%% The package provides a minimal and easy to read syntax. It depends only on the +%% array package and can be placed almost everywhere, in particular in footnotes or +%% graphs and tree structures. The package serves the same purpose as, Christopher +%% Manning’s avm package, but shares no code base with that package. %% -%% langsci-avm was developed at Language Science Press to help in the -%% production of scientific texts in linguistics. +%% Copyright (C) 2023 by Felix Kopecky, Language Science Press %% -%% Copyright (C) 2020 by Felix Kopecky, Language Science Press -%% -%% This work consists of the file langsci-avm.dtx -%% and the derived files langsci-avm.ins, -%% langsci-avm.pdf. +%% This work consists of the file langsci-avm.dtx +%% and the derived file langsci-avm.pdf. %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,34 +39,82 @@ %% https://github.com/langsci/langsci-avm/issues %% %% ------------------------------------------------------------------------------ -\RequirePackage{xparse,array} +\RequirePackage{xparse}[2022/03/26] +\RequirePackage{array} \ProvidesExplPackage {langsci-avm} - {2020-07-15} {0.2.1} - {AVMs and feature structures in LaTeX3} + {2023-02-20} {0.3.0} + {AVMs and feature structures} + +\msg_new:nnnn {avm} {lfgoptionmissing} + { Missing~package~option~lfg~at~line~\msg_line_number: } + { + You~issued~a~command~in~line~\msg_line_number:~that~is~only~available~when~ + the~lfg~package~option~is~enabled. + } + +\msg_new:nnnn {avm} {idpositionunknown} + { Unkown~value~for~option~`id~position`~near~line~\msg_line_number:. } + { You~specified~an~unknown~value~for~option~`id~position`.~The~content~of~ + the~id~could~not~be~output.~Please~see~the~manual~for~a~list~of~valid~ + settings. + } +\bool_new:N \l__avm_lfg_bool +\bool_new:N \l__avm_tikz_bool +\DeclareOption{tikz}{ \bool_set_true:N \l__avm_tikz_bool } +\DeclareOption{lfg}{ \bool_set_true:N \l__avm_lfg_bool } +\ProcessOptions\relax +\bool_if:NT \l__avm_tikz_bool + { + \RequirePackage{tikz} + \newcounter{l__avm_picture_counter} + \tl_new:N \l__avm_picture_name_prefix_tl + } +\bool_if:NT \l__avm_lfg_bool + { + \cs_if_exist:NF \lBrack + { + \RequirePackage{etoolbox} + \AtEndPreamble { \RequirePackage{unicode-math} } + } + } \NewDocumentCommand{\avm}{ O{} +m } { \c_group_begin_token + \keys_set:nn { avm } { #1 } \__avm_initialise_document_commands: \__avm_initialise_custom_commands: \tl_use:N \l__avm_defined_commands_tl - \bool_set_true:N \l__avm_mode_bool - \keys_set:nn { avm } { #1 } - \__avm_wrap:n { #2 } + \__avm_mode_switch: + \__avm_parse:n { #2 } \c_group_end_token } +\bool_new:N \l__avm_mode_bool +\seq_new:N \l__avm_parens_tracker +\tl_new:N \l__avm_defined_commands_tl +\box_new:N \l__avm_fillmore_kay_box +\tl_new:N \l__avm_parsed_tl +\int_new:N \l__avm_mode_switch_character_int \NewDocumentCommand{\avmsetup}{ m } { \keys_set:nn { avm } { #1 } } \keys_define:nn { avm } { + align .bool_set:N = \l__avm_align_bool, + align .initial:n = {true}, stretch .tl_set:N = \l__avm_arraystretch_tl, stretch .initial:n = {0.9}, columnsep .dim_set:N = \l__avm_tabcolsep_dim, columnsep .initial:n = {.5ex}, + vectorsep .dim_set:N = \l__avm_singlesep_dim, + vectorsep .initial:n = {1em}, delimfactor .int_set:N = \l__avm_delimfactor_int, delimfactor .initial:n = {1000}, delimfall .dim_set:N = \l__avm_delimshortfall_dim, delimfall .initial:n = {0pt}, + framewidth .dim_set:N = \l__avm_fillmore_kay_boxrule_dim, + framewidth .initial:n = {1pt}, + framesep .dim_set:N = \l__avm_fillmore_kay_boxsep_dim, + framesep .initial:n = {3pt}, attributes .code:n = {\cs_set:Nn \__avm_font_attribute: {#1}}, attributes .initial:n = {\scshape}, types .code:n = {\cs_set:Nn \__avm_font_type: {#1}}, @@ -80,18 +123,32 @@ values .initial:n = {\itshape}, tags .code:n = {\cs_set:Nn \__avm_font_tag: {#1}}, tags .initial:n = {\footnotesize}, - apptovalues .code:n = {\cs_set:Nn \__avm_deinit_second_column: {#1}}, - apptovalues .initial:n = {\/}, singleton .code:n = {\cs_set:Nn \__avm_font_singleton: {#1}}, singleton .initial:n = {\normalfont}, - switch .code:n = {\tl_set:Nn \__avm_mode_switch_character {#1}}, + switch .code:n = + { + \tl_set:Nn \l__avm_mode_switch_character {#1} + \exp_args:NNx \int_set:Nn \l__avm_mode_switch_character_int + {`\tl_use:N \l__avm_mode_switch_character} + }, switch .initial:n = { ! }, extraskip .dim_set:N = \l__avm_extra_skip_dim, extraskip .initial:n = {\smallskipamount}, - customise .code:n = {\cs_set:Nn \__avm_initialise_custom_commands: {#1}}, + extraskip~in~every~row .bool_set:N = \l__avm_extraskip_bool, + customise .code:n = {\cs_set:Nn \__avm_initialise_custom_commands: + {#1}}, customise .initial:n = { }, + pic .bool_set:N = \l__avm_picture_bool, + pic .default:n = { true }, + picname .tl_set:N = \l__avm_picture_name_tl, + picname .initial:n = {automatic}, + id~align .code:n = { \newcolumntype{i}{#1} }, + id~align .initial:n = {l}, + id~position .tl_set:N = \l__avm_id_position_tl, + id~position .initial:n = {south-west}, style .choice:, - style / narrow .code:n = {\delimiterfactor=997\delimitershortfall5pt}, + style / narrow .code:n = {\int_set:Nn \l__avm_delimfactor_int {997} + \dim_set:Nn \l__avm_delimshortfall_dim {5pt}}, } \NewDocumentCommand{\avmdefinestyle}{ m m } @@ -113,11 +170,7 @@ } } -\bool_new:N \l__avm_mode_bool -\seq_new:N \l__avm_parens_tracker -\tl_new:N \l__avm_defined_commands_tl - -\cs_generate_variant:Nn \seq_set_split:Nnn { NVn } +\cs_generate_variant:Nn \tl_if_eq:nnTF {VnTF} \bool_new:N \l__avm_in_first_column @@ -133,6 +186,30 @@ \normalfont\__avm_font_value: } +\cs_new:Nn \__avm_init_single_column: + { + \normalfont\__avm_font_attribute: + } + + + +\tl_const:Nn \l__avm_italics_tl {it} + +\cs_new:Nn \__avm_deinit_first_column: + { + \tl_if_eq:NNT \f@shape \l__avm_italics_tl {\/} + } + +\cs_new:Nn \__avm_deinit_second_column: + { + \tl_if_eq:NNT \f@shape \l__avm_italics_tl {\/} + } + +\cs_new:Nn \__avm_deinit_single_column: + { + \tl_if_eq:NNT \f@shape \l__avm_italics_tl {\/} + } + \cs_new:Nn \__avm_kern_unused_columns: { \bool_if:NTF \l__avm_in_first_column @@ -147,79 +224,208 @@ \cs_new:Nn \__avm_module_begin: { - \begin{tabular}{@{} - >{\__avm_init_first_column:}l - >{\__avm_init_second_column:}l - <{\__avm_deinit_second_column:} - @{}} + \bool_if:NTF \l__avm_align_bool + { + \begin{tabular}{@{} + >{\__avm_init_first_column:}l + <{\__avm_deinit_first_column:} + >{\__avm_init_second_column:}l + <{\__avm_deinit_second_column:} + @{}} + } + { + \begin{tabular}{@{} + >{\__avm_init_single_column:}l + <{\__avm_deinit_single_column:} + @{}} + } } \cs_new:Nn \__avm_module_end: { \__avm_kern_unused_columns: \end{tabular} } + +\cs_new:Nn \__avm_replace_ampersand: + { + \bool_if:NTF \l__avm_align_bool + { \tl_build_put_right:Nn \l__avm_parsed_tl { & } } + { \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \__avm_deinit_first_column:\skip_horizontal:N + \dim_use:N \l__avm_singlesep_dim \__avm_init_second_column: + } + } + } + } \cs_new:Nn \__avm_replace_lbrace: { - \__avm_parse_output:nw - { \c_math_toggle_token\left\lbrace\__avm_module_begin: } + \c_math_toggle_token\left\lbrace\__avm_module_begin: } \cs_new:Nn \__avm_replace_rbrace: { - \__avm_parse_output:nw - { \__avm_module_end:\right\rbrace\c_math_toggle_token\__avm_extra_skip: } + \__avm_module_end:\right\rbrace\c_math_toggle_token\__avm_extra_skip: } \cs_new:Nn \__avm_replace_lbrack: { - \__avm_parse_output:nw - { \c_math_toggle_token\left\lbrack\__avm_module_begin: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \c_math_toggle_token\left\lbrack\__avm_module_begin: + } + { [ } + } + } } \cs_new:Nn \__avm_replace_rbrack: { - \__avm_parse_output:nw - { \__avm_module_end:\right\rbrack\c_math_toggle_token\__avm_extra_skip: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \__avm_module_end:\right\rbrack\c_math_toggle_token% + \__avm_extra_skip: + } + { ] } + } + } + } +\bool_if:NTF \l__avm_lfg_bool + { + \cs_new:Nn \__avm_replace_llbrack: + { + \c_math_toggle_token\left\lBrack\__avm_module_begin: + } + \cs_new:Nn \__avm_replace_rrbrack: + { + \__avm_module_end:\right\rBrack\c_math_toggle_token\__avm_extra_skip: + } + } + { + \cs_new:Nn \__avm_replace_llbrack: + { + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \msg_warning:nn {avm}{lfgoptionmissing} + \c_math_toggle_token\left.\__avm_module_begin: + } + } + } + \cs_new:Nn \__avm_replace_rrbrack: + { + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \msg_warning:nn {avm}{lfgoptionmissing} + \__avm_module_end:\right.\c_math_toggle_token\__avm_extra_skip: + } + } + } } \cs_new:Nn \__avm_replace_lparen: { - \__avm_parse_output:nw - { \c_math_toggle_token\left(\__avm_module_begin: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \c_math_toggle_token\left(\__avm_module_begin: + } + { ( } + } + } } \cs_new:Nn \__avm_replace_rparen: { - \__avm_parse_output:nw - { \__avm_module_end:\right)\c_math_toggle_token\__avm_extra_skip: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \__avm_module_end:\right)\c_math_toggle_token\__avm_extra_skip: + } + { ) } + } + } } \cs_new:Nn \__avm_replace_langle: { - \__avm_parse_output:nw - { \c_math_toggle_token\left<\__avm_module_begin: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \c_math_toggle_token\left<\__avm_module_begin: + } + { < } + } + } } \cs_new:Nn \__avm_replace_rangle: { - \__avm_parse_output:nw - { \__avm_module_end:\right>\c_math_toggle_token\__avm_extra_skip: } + \tl_build_put_right:Nn \l__avm_parsed_tl + { + \exp_not:n + { + \bool_if:NTF \l__avm_mode_bool + { + \__avm_module_end:\right>\c_math_toggle_token\__avm_extra_skip: + } + { > } + } + } + } +\cs_new:Nn \__avm_replace_lframe: + { + \hbox_set:Nw \l__avm_fillmore_kay_box \group_begin: + \c_math_toggle_token\__avm_module_begin: + } +\cs_new:Nn \__avm_replace_rframe: + { + \__avm_module_end:\c_math_toggle_token\group_end:\hbox_set_end: + \group_begin: + \dim_set_eq:NN \fboxrule \l__avm_fillmore_kay_boxrule_dim + \dim_set_eq:NN \fboxsep \l__avm_fillmore_kay_boxsep_dim + \fbox{\box_use:N \l__avm_fillmore_kay_box} + \group_end: \__avm_extra_skip: } \cs_new:Nn \__avm_replace_plus: { - \__avm_parse_output:nw { \ensuremath { \oplus \! } } + \leavevmode\unskip\hbox{${}\oplus{}$}\ignorespaces } \cs_new:Nn \__avm_replace_minus: { - \__avm_parse_output:nw { \ensuremath { \ominus \! } } + \leavevmode\unskip\hbox{${}\ominus{}$}\ignorespaces } \cs_new:Nn \__avm_replace_circle: { - \__avm_parse_output:nw { \ensuremath { \bigcirc \, } } + \leavevmode\unskip\hbox{${}\bigcirc{}$}\ignorespaces } \cs_new:Npn \__avm_controls_tag:n #1 - { \fboxsep.25ex\fbox{\normalfont\__avm_font_tag: #1} } + { \fboxsep.25ex\fboxrule.4pt\fbox{\normalfont\__avm_font_tag: #1} } \cs_new:Npn \__avm_controls_type:n #1 { \c_group_begin_token\normalfont\__avm_font_type: #1\c_group_end_token } \cs_new_protected:Npn \__avm_controls_type_starred:n #1 { \bool_set_false:N \l__avm_in_first_column \normalfont\__avm_font_type: #1 - \__avm_deinit_second_column:\span\hspace*{-2\tabcolsep} + \bool_if:NTF \l__avm_align_bool + { \__avm_deinit_second_column:\span\hspace*{-2\tabcolsep} } + { \__avm_deinit_single_column:} \peek_meaning_ignore_spaces:NTF \\ {} {\\} } \cs_new_protected:Npn \__avm_controls_punk:nn #1 #2 @@ -227,155 +433,148 @@ \bool_set_false:N \l__avm_in_first_column \normalfont\c_group_begin_token\__avm_font_attribute:#1% \c_group_end_token\hspace{2\tabcolsep}% - \c_group_begin_token\__avm_font_type: #2\c_group_end_token% + \c_group_begin_token\__avm_font_value: #2\c_group_end_token% \__avm_deinit_second_column:\span\hspace*{-2\tabcolsep} - \peek_meaning_ignore_spaces:NTF \\ {} {\\} + \peek_charcode_ignore_spaces:NTF \\ {} {\\} } -\cs_new:Nn \__avm_initialise_document_commands: +\cs_new:Nn \__avm_mode_switch: { - \def\arraystretch{\tl_use:N \l__avm_arraystretch_tl} - \tabcolsep=\l__avm_tabcolsep_dim - \delimiterfactor=\l__avm_delimfactor_int - \delimitershortfall=\l__avm_delimshortfall_dim - \cs_if_exist:NTF \tag - { \RenewDocumentCommand{\tag}{m}{ \__avm_controls_tag:n {##1} } } - { \NewDocumentCommand{\tag}{m}{ \__avm_controls_tag:n {##1} } } - \cs_if_exist:NTF \0 - { \RenewDocumentCommand{\0}{}{ \__avm_controls_tag:n {0} } } - { \NewDocumentCommand{\0}{}{ \__avm_controls_tag:n {0} } } - \cs_if_exist:NTF \1 - { \RenewDocumentCommand{\1}{}{ \__avm_controls_tag:n {1} } } - { \NewDocumentCommand{\1}{}{ \__avm_controls_tag:n {1} } } - \cs_if_exist:NTF \2 - { \RenewDocumentCommand{\2}{}{ \__avm_controls_tag:n {2} } } - { \NewDocumentCommand{\2}{}{ \__avm_controls_tag:n {2} } } - \cs_if_exist:NTF \3 - { \RenewDocumentCommand{\3}{}{ \__avm_controls_tag:n {3} } } - { \NewDocumentCommand{\3}{}{ \__avm_controls_tag:n {3} } } - \cs_if_exist:NTF \4 - { \RenewDocumentCommand{\4}{}{ \__avm_controls_tag:n {4} } } - { \NewDocumentCommand{\4}{}{ \__avm_controls_tag:n {4} } } - \cs_if_exist:NTF \5 - { \RenewDocumentCommand{\5}{}{ \__avm_controls_tag:n {5} } } - { \NewDocumentCommand{\5}{}{ \__avm_controls_tag:n {5} } } - \cs_if_exist:NTF \6 - { \RenewDocumentCommand{\6}{}{ \__avm_controls_tag:n {6} } } - { \NewDocumentCommand{\6}{}{ \__avm_controls_tag:n {6} } } - \cs_if_exist:NTF \7 - { \RenewDocumentCommand{\7}{}{ \__avm_controls_tag:n {7} } } - { \NewDocumentCommand{\7}{}{ \__avm_controls_tag:n {7} } } - \cs_if_exist:NTF \8 - { \RenewDocumentCommand{\8}{}{ \__avm_controls_tag:n {8} } } - { \NewDocumentCommand{\8}{}{ \__avm_controls_tag:n {8} } } - \cs_if_exist:NTF \9 - { \RenewDocumentCommand{\9}{}{ \__avm_controls_tag:n {9} } } - { \NewDocumentCommand{\9}{}{ \__avm_controls_tag:n {9} } } - \cs_if_exist:NTF \type - { \RenewDocumentCommand{\type}{s m} - { - \IfBooleanTF { ##1 } - { \__avm_controls_type_starred:n {##2} } - { \__avm_controls_type:n {##2} } - } - } - { \NewDocumentCommand{\type}{s m} - { - \IfBooleanTF { ##1 } - { \__avm_controls_type_starred:n {##2} } - { \__avm_controls_type:n {##2} } - } - } - \cs_if_exist:NTF \punk - { \RenewDocumentCommand{\punk}{m m} - { \__avm_controls_punk:nn {##1}{##2} } } - { \NewDocumentCommand{\punk}{m m} - { \__avm_controls_punk:nn {##1}{##2} } } - } - -\cs_new_protected:Npn \__avm_wrap:n #1 - { - \seq_set_split:NVn \l__avm_wrapper_seq - \__avm_mode_switch_character { #1 } - \seq_map_inline:Nn \l__avm_wrapper_seq + \bool_set_inverse:N \l__avm_mode_bool + \bool_if:NTF \l__avm_mode_bool { - \exp_args:No \exp_not:o - { \__avm_parse:n {##1} } - \bool_set_inverse:N \l__avm_mode_bool + \DeclareDocumentCommand{\{}{}{ \__avm_replace_lbrace: } + \DeclareDocumentCommand{\}}{}{ \__avm_replace_rbrace: } + \DeclareDocumentCommand{\[}{}{ \__avm_replace_llbrack: } + \DeclareDocumentCommand{\]}{}{ \__avm_replace_rrbrack: } + \DeclareDocumentCommand{\+}{}{ \__avm_replace_plus: } + \DeclareDocumentCommand{\-}{}{ \__avm_replace_minus: } + } + { + \DeclareCommandCopy{\{}{\__avm_old_lbrace_store:} + \DeclareCommandCopy{\}}{\__avm_old_rbrace_store:} + \DeclareCommandCopy{\[}{\__avm_old_llbrack_store:} + \DeclareCommandCopy{\]}{\__avm_old_rrbrack_store:} + \DeclareCommandCopy{\+}{\__avm_old_plus_store:} + \DeclareCommandCopy{\-}{\__avm_old_minus_store:} } } -\cs_new:Npn \__avm_parse:n #1 - { - \exp:w - \group_align_safe_begin: - \__avm_parse_loop:w #1 - \q_recursion_tail \q_recursion_stop - \__avm_result:n { } - } - -\cs_new:Npn \__avm_end:w \__avm_result:n #1 - { - \group_align_safe_end: - \exp_end: - #1 - } - -\cs_new:Npn \__avm_parse_loop:w #1 \q_recursion_stop +\cs_new:Nn \__avm_initialise_document_commands: { - \tl_if_head_is_N_type:nTF {#1} + \DeclareCommandCopy{\__avm_old_lbrace_store:}{\{} + \DeclareCommandCopy{\__avm_old_rbrace_store:}{\}} + \DeclareCommandCopy{\__avm_old_llbrack_store:}{\[} + \DeclareCommandCopy{\__avm_old_rrbrack_store:}{\]} + \DeclareCommandCopy{\__avm_old_plus_store:}{\+} + \DeclareCommandCopy{\__avm_old_minus_store:}{\-} + \def\arraystretch{\tl_use:N \l__avm_arraystretch_tl} + \dim_set_eq:NN \tabcolsep \l__avm_tabcolsep_dim + \int_set_eq:NN \delimiterfactor \l__avm_delimfactor_int + \dim_set_eq:NN \delimitershortfall \l__avm_delimshortfall_dim + \DeclareDocumentCommand{\shuffle}{}{ \__avm_replace_shuffle: } + \DeclareDocumentCommand{\lframe}{}{ \__avm_replace_lframe: } + \DeclareDocumentCommand{\rframe}{}{ \__avm_replace_rframe: } + \DeclareDocumentCommand{\tag}{m}{ \__avm_controls_tag:n {##1} } + \DeclareDocumentCommand{\0}{}{ \__avm_controls_tag:n {0} } + \DeclareDocumentCommand{\1}{}{ \__avm_controls_tag:n {1} } + \DeclareDocumentCommand{\2}{}{ \__avm_controls_tag:n {2} } + \DeclareDocumentCommand{\3}{}{ \__avm_controls_tag:n {3} } + \DeclareDocumentCommand{\4}{}{ \__avm_controls_tag:n {4} } + \DeclareDocumentCommand{\5}{}{ \__avm_controls_tag:n {5} } + \DeclareDocumentCommand{\6}{}{ \__avm_controls_tag:n {6} } + \DeclareDocumentCommand{\7}{}{ \__avm_controls_tag:n {7} } + \DeclareDocumentCommand{\8}{}{ \__avm_controls_tag:n {8} } + \DeclareDocumentCommand{\9}{}{ \__avm_controls_tag:n {9} } + \DeclareDocumentCommand{\type}{s m} { - \__avm_N_type:N #1 \q_recursion_stop + \IfBooleanTF { ##1 } + { \__avm_controls_type_starred:n {##2} } + { \__avm_controls_type:n {##2} } + } + \DeclareDocumentCommand{\punk}{m m}{ \__avm_controls_punk:nn {##1}{##2} } + \DeclareDocumentCommand{\id}{m m} + {% + \hcoffin_set:Nw \l_tmpa_coffin + \bgroup + \def\arraystretch{.5} + \begin{tabular}[b]{@{}>{$\scriptstyle}i<{$}@{}} + ##1 + \end{tabular} + \egroup + \hcoffin_set_end: + \hcoffin_set:Nw \l_tmpb_coffin ##2 \hcoffin_set_end: + \tl_if_eq:VnTF \l__avm_id_position_tl {south-west} + {% + \coffin_join:NnnNnnnn \l_tmpb_coffin {l}{H} + \l_tmpa_coffin {r}{H}{ 0pt }{ -\coffin_dp:N \l_tmpb_coffin } + } + {% + \tl_if_eq:VnTF \l__avm_id_position_tl {south-east} + {% + \coffin_join:NnnNnnnn \l_tmpb_coffin {l}{H} + \l_tmpa_coffin {l}{H}{ \coffin_wd:N \l_tmpb_coffin } + { -\coffin_dp:N \l_tmpb_coffin } + } + { + \msg_error:nn {avm}{idpositionunknown} + } + } + \coffin_typeset:Nnnnn \l_tmpb_coffin {l}{vc}{0pt}{0pt} } + \bool_if:NT \l__avm_tikz_bool { - \tl_if_head_is_group:nTF {#1} - { \__avm_replace_group:nw #1 \q_recursion_stop } - { \__avm_replace_space:w #1 \q_recursion_stop } + \tl_if_eq:VnTF \l__avm_picture_name_tl {automatic} + { + \stepcounter{l__avm_picture_counter} + \tl_set:Nn \l__avm_picture_name_prefix_tl + {avm-\tl_use:N \thel__avm_picture_counter} + } + { + \tl_set_eq:NN \l__avm_picture_name_prefix_tl \l__avm_picture_name_tl + } + \DeclareDocumentCommand{\node}{m m} + { + \tikz [remember~picture, + baseline=(\l__avm_picture_name_prefix_tl-##1.base)] + \node [inner~sep=0pt] (\l__avm_picture_name_prefix_tl-##1) + {\strut ##2}; + } } } -\cs_new:Npn \__avm_N_type:N #1 - { - \quark_if_recursion_tail_stop_do:Nn #1 { \__avm_end:w } - \bool_if:NTF \l__avm_mode_bool - { \__avm_replace:N #1 } - { \__avm_replace_none:N #1 } - } - -\cs_new:Npn \__avm_replace_none:N #1 - { - \__avm_parse_output:nw {#1} - } - -\cs_new:Npn \__avm_replace:N #1 +\cs_new:Npn \__avm_parse:n #1 { - \str_case:nnF {#1} + \group_align_safe_begin: + \tl_build_begin:N \l__avm_parsed_tl + \tl_build_put_right:Nn \l__avm_parsed_tl { \exp_not:n {\ignorespaces} } + \tl_analysis_map_inline:nn { #1 } { - { \+ }{ \__avm_replace_plus: } - { \- }{ \__avm_replace_minus: } - { \shuffle }{ \__avm_replace_circle: } - { [ }{ \__avm_replace_lbrack: } - { ] }{ \__avm_replace_rbrack: } - { ( }{ \__avm_replace_lparen: } - { ) }{ \__avm_replace_rparen: } - { \{ }{ \__avm_replace_lbrace: } - { \} }{ \__avm_replace_rbrace: } - { < }{ \__avm_replace_langle: } - { > }{ \__avm_replace_rangle: } + \int_case:nnF { ##2 } + { + { `& }{ \__avm_replace_ampersand: } + { `[ }{ \__avm_replace_lbrack: } + { `] }{ \__avm_replace_rbrack: } + { `( }{ \__avm_replace_lparen: } + { `) }{ \__avm_replace_rparen: } + { `< }{ \__avm_replace_langle: } + { `> }{ \__avm_replace_rangle: } + { \l__avm_mode_switch_character_int } + { + \tl_build_put_right:Nn \l__avm_parsed_tl + { \exp_not:n { \__avm_mode_switch: } } + } + } + { + \tl_build_put_right:Nn \l__avm_parsed_tl { ##1 } + } } - { \__avm_replace_none:N #1 } + \tl_build_end:N \l__avm_parsed_tl + \tl_set:Nx \l__avm_parsed_tl {\l__avm_parsed_tl} + \tl_use:N \l__avm_parsed_tl + \group_align_safe_end: } -\cs_new:Npn \__avm_replace_group:nw #1 - { \exp_args:NNo \exp_args:No \__avm_replace_group:n { \__avm_parse:n {#1} } } - -\cs_new:Npn \__avm_replace_group:n #1 { \__avm_parse_output:nw { {#1} } } - -\exp_last_unbraced:NNo -\cs_new:Npn \__avm_replace_space:w \c_space_tl { \__avm_parse_output:nw { ~ } } - -\cs_new:Npn \__avm_parse_output:nw #1 #2 \q_recursion_stop \__avm_result:n #3 - { \__avm_parse_loop:w #2 \q_recursion_stop \__avm_result:n {#3 #1 } } %% %% |