summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/semantex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-27 21:28:13 +0000
committerKarl Berry <karl@freefriends.org>2020-09-27 21:28:13 +0000
commit33fb2810502fa7c62e017ee6defb956db30125a0 (patch)
tree6463d5d808482f354bfca1bd3a1829ace355d069 /Master/texmf-dist/tex/latex/semantex
parent88f3fea0e61c7d9183c2d9de8d59af21db852d82 (diff)
semantex (27sep20)
git-svn-id: svn://tug.org/texlive/trunk@56455 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/semantex')
-rw-r--r--Master/texmf-dist/tex/latex/semantex/semantex.sty578
-rw-r--r--Master/texmf-dist/tex/latex/semantex/stripsemantex.lua71
-rw-r--r--Master/texmf-dist/tex/latex/semantex/stripsemantex.sty87
3 files changed, 451 insertions, 285 deletions
diff --git a/Master/texmf-dist/tex/latex/semantex/semantex.sty b/Master/texmf-dist/tex/latex/semantex/semantex.sty
index e705b068862..dcbf1f9193b 100644
--- a/Master/texmf-dist/tex/latex/semantex/semantex.sty
+++ b/Master/texmf-dist/tex/latex/semantex/semantex.sty
@@ -1,5 +1,5 @@
\RequirePackage{xparse,l3keys2e,leftindex}
-\ProvidesExplPackage{semantex}{2020/09/13}{0.43}{}
+\ProvidesExplPackage{semantex}{2020/09/27}{0.44}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
@@ -20,6 +20,7 @@
semtexfile .choice:,
semtexfile / true .code:n = \semantex_turn_semtex_file_on:,
semtexfile / false .code:n = \semantex_turn_semtex_file_off:,
+ semtexfile / .code:n = \semantex_turn_semtex_file_on:,
semtexfile / unknown .code:n = \msg_error:nnnn { semantex } { semantex_setup_key_value_not_found } { semtexfile } { #1 },
unknown .code:n = \msg_error:nnx { semantex } { semantex_setup_key_not_found } { \l_keys_key_str }
}
@@ -29,110 +30,23 @@
\keys_set:nn { semantex } { #1 }
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% THE FOLLOWING SECTION IS IDENTICAL TO THE semtex PACKAGE
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-% These are some essential commands that are needed for bullets and parentheses,
-% and they are the only ones that will not be stripped by running the
-% stripsemantex algorithm. Therefore, they are also available as a standalone
-% package, called "semtex". This name is meant to suggest "stripped SemanTeX",
-% and at the same time, semtex is the name of a plastic explosive, suggesting
-% "blown-up SemanTeX".
-% (Mathematicians are not famous for the quality of their humour.)
-
-% Bullets:
-
-\box_if_exist:NF \g__semantex_bullet_box
-{
- \box_new:N \g__semantex_bullet_box
- \hbox_set:Nn \g__semantex_bullet_box { $\cdot$ }
- \box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2}
- \tl_set:Nn\g_semantex_bullet
- {
- \box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box}
- }
-
- \tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet}
-
- \tl_set_eq:NN\SemantexBullet \g_semantex_bullet
-
- \tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet
-}
-
-% Parentheses:
-
-\cs_set:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left }
-
-\cs_set:Npn\SemantexRight { \aftergroup\egroup\right }
-
-\tl_set:Nn\SemantexDelimiterSize{}
-
-\DeclareDocumentCommand\SemantexParentheses { mmmm }
-{
- \str_case:nnF { #1 } % This is where \big,\Big, etc. go.
- {
- { normal } {
- \group_begin:
- \tl_clear:N \SemantexDelimiterSize
- \str_if_eq:nnF { #2 } { . } { \mathopen #2 }
- #4
- \str_if_eq:nnF { #3 } { . } { \mathclose #3 }
- \group_end:
- }
- { auto } {
- \group_begin:
- \tl_set_eq:NN \SemantexDelimiterSize \middle
- \SemantexLeft #2
- #4
- \SemantexRight #3
- \group_end:
- }
- { * } {
- \group_begin:
- \tl_set_eq:NN \SemantexDelimiterSize \middle
- \SemantexLeft #2
- #4
- \SemantexRight #3
- \group_end:
- }
- }
- {
- \group_begin:
- \tl_set_eq:NN\SemantexDelimiterSize #1
- \mathopen #1 #2
- #4
- \mathclose #1 #3
- \group_end:
- }
-}
-
-\DeclareDocumentCommand\SemantexNoParentheses { m }
-{
- \group_begin:
- \tl_clear:N\SemantexDelimiterSize
- #1
- \group_end:
-}
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% THE .semtex FILE
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\bool_new:N \g__semantex_semtex_file_was_opened
+\bool_new:N \g__semantex_semtex_file_was_opened_bool
\iow_new:N \g__semantex_semtex_file_stream_temp_iow
\cs_new_protected:Npn \semantex_turn_semtex_file_on:
{
- \bool_if:NF \g__semantex_semtex_file_was_opened
+ \bool_if:NF \g__semantex_semtex_file_was_opened_bool
{
\iow_open:Nn \g__semantex_semtex_file_stream_temp_iow { \jobname.semtex }
\iow_now:Nn \g__semantex_semtex_file_stream_temp_iow { \DeclareClass {\SemantexBaseObject } }
+ \iow_now:Nn \g__semantex_semtex_file_stream_temp_iow { \DeclareObject {\SemantexDelimiterSize } }
}
\cs_set:Npn\semantex_write_to_semtex_file:n##1
@@ -140,23 +54,38 @@
\iow_now:Nn \g__semantex_semtex_file_stream_temp_iow { ##1 }
}
- \bool_set_true:N \g__semantex_semtex_file_was_opened
+ \cs_set:Npn\semantex_write_to_semtex_file_V:N ##1
+ {
+ % We use this command instead of a :V variant
+ % in order to save time; when semtexfile=false,
+ % there is no reason to V-expand the argument.
+ \semantex_write_to_semtex_file:V ##1
+ }
+
+ \bool_set_true:N \g__semantex_semtex_file_was_opened_bool
}
\cs_new_protected:Npn \semantex_turn_semtex_file_off:
{
- \bool_if:NT \g__semantex_semtex_file_was_opened
+ \bool_if:NT \g__semantex_semtex_file_was_opened_bool
{
\iow_close:N \g__semantex_semtex_file_stream_temp_iow
}
\cs_set:Npn\semantex_write_to_semtex_file:n##1 {}
- \bool_set_false:N \g__semantex_semtex_file_was_opened
+ \cs_set:Npn\semantex_write_to_semtex_file_V:N ##1 {}
+ % We use this command instead of a :V variant
+ % in order to save time; when semtexfile=false,
+ % there is no reason to V-expand the argument.
+
+ \bool_set_false:N \g__semantex_semtex_file_was_opened_bool
}
\semantex_turn_semtex_file_off:
+\cs_generate_variant:Nn \semantex_write_to_semtex_file:n { V }
+
\cs_new_protected:Npn\semantex_write_original_source_to_semtex_file:n#1
{
\semantex_write_to_semtex_file:n { \BeginSource }
@@ -170,6 +99,8 @@
\semantex_write_to_semtex_file:n { #1 }
}
+\cs_set_eq:NN\SemantexAddToRecordedSource\semantex_add_to_existing_original_source_in_semtex_file:n
+
\cs_new_protected:Npn\semantex_write_output_to_semtex_file:n#1
{
\semantex_write_to_semtex_file:n { \EndSource }
@@ -178,9 +109,15 @@
\semantex_write_to_semtex_file:n { \EndOutput }
}
-\cs_generate_variant:Nn\semantex_write_output_to_semtex_file:n { V }
+\cs_set_eq:NN\SemantexRecordOutput\semantex_write_output_to_semtex_file:n
-\cs_generate_variant:Nn\semantex_write_original_source_to_semtex_file:n { o }
+\cs_new_protected:Npn\semantex_write_output_to_semtex_file_V:N#1
+{
+ \semantex_write_to_semtex_file:n { \EndSource }
+ \semantex_write_to_semtex_file:n { \BeginOutput }
+ \semantex_write_to_semtex_file_V:N #1
+ \semantex_write_to_semtex_file:n { \EndOutput }
+}
\cs_new_protected:Npn\semantex_write_class_declaration_to_semtex_file:n#1
{
@@ -199,6 +136,99 @@
\cs_set_eq:NN\SemantexRecordObject\semantex_write_object_declaration_to_semtex_file:n
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% THE FOLLOWING SECTION IS IDENTICAL TO THE semtex PACKAGE
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These are some essential commands that are needed for bullets and parentheses,
+% and they are the only ones that will not be stripped by running the
+% stripsemantex algorithm. Therefore, they are also available as a standalone
+% package, called "semtex". This name is meant to suggest "stripped SemanTeX",
+% and at the same time, semtex is the name of a plastic explosive, suggesting
+% "blown-up SemanTeX".
+% (Mathematicians are not famous for the quality of their humour.)
+
+% Bullets:
+
+\box_if_exist:NF \g__semantex_bullet_box
+{
+ \box_new:N \g__semantex_bullet_box
+ \hbox_set:Nn \g__semantex_bullet_box { $\cdot$ }
+ \box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2}
+ \tl_set:Nn\g_semantex_bullet
+ {
+ \box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box}
+ }
+
+ \tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet}
+
+ \tl_set_eq:NN\SemantexBullet \g_semantex_bullet
+
+ \tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet
+}
+
+% Parentheses:
+
+\cs_set:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left }
+
+\cs_set:Npn\SemantexRight { \aftergroup\egroup\right }
+
+\DeclareDocumentCommand\SemantexDelimiterSize { }
+{
+ \semantex_write_original_source_to_semtex_file:n { \SemantexDelimiterSize }
+ \semantex_write_output_to_semtex_file_V:N \l_semantex_delimiter_size_temp_tl
+ \l_semantex_delimiter_size_temp_tl
+}
+
+\DeclareDocumentCommand\RecordSemantexDelimiterSize { }
+{
+ \semantex_write_output_to_semtex_file_V:N \l_semantex_delimiter_size_temp_tl
+}
+
+\DeclareDocumentCommand\SemantexDelimiterSizeNoRecord { }
+{
+ \l_semantex_delimiter_size_temp_tl
+}
+
+\DeclareDocumentCommand\SemantexMathOpen { mm }
+{
+ \group_begin:
+ \tl_set:Nn\l_semantex_delimiter_size_temp_tl { #1 }
+ \str_if_eq:nnF { #2 } { . } { \mathopen #1 #2 }
+}
+
+\DeclareDocumentCommand\SemantexMathClose { mm }
+{
+ \str_if_eq:nnF { #2 } { . } { \mathclose #1 #2 }
+ \group_end:
+}
+
+\DeclareDocumentCommand\SemantexMathOpenAuto { m }
+{
+ \group_begin:
+ \tl_set:Nn\l_semantex_delimiter_size_temp_tl { \middle }
+ \SemantexLeft #1
+}
+
+\DeclareDocumentCommand\SemantexMathCloseAuto { m }
+{
+ \SemantexRight #1
+ \group_end:
+}
+
+\DeclareDocumentCommand\SemantexMathOpenNoPar { }
+{
+ \group_begin:
+ \tl_clear:N\l_semantex_delimiter_size_temp_tl
+}
+
+\DeclareDocumentCommand\SemantexMathCloseNoPar { }
+{
+ \group_end:
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% USER COMMANDS FOR CREATING NEW CLASSES
@@ -1572,20 +1602,6 @@
\semantex_data_bool_get:nnTF { #1 } { output } % Checks if the register is supposed to output
{
\semantex_inner_return:n { #1 }
- \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } % Checks if more than one argument has been received, i.e. whether we want to render any argument
- {
- \semantex_data_bool_get:nnTF { #1 } { leftargument } % Checks if left or right argument
- {
- \semantex_left_return:n { #1 }
- }
- {
- \semantex_right_return:n { #1 }
- }
- }
- {
- % do nothing
- }
- \tl_set:Nx\l__semantex_render_symbol_temp_tl { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % Stores the symbol in a temporary command
\tl_set:Nx \l__semantex_render_output_class_temp_tl { \semantex_data_tl_get:nn { #1 } { output } } % The output class
\exp_args:NNx\cs_set:Nn\l__semantex_render_outputoptions_temp_cs:n
{ \semantex_data_tl_get_exp_not:nn { #1 } { outputoptions } }
@@ -1602,51 +1618,130 @@
{
\l__semantex_render_outputoptions_temp_tl
} % This was necessary, trust me.
- \tl_set:Nx \l__semantex_render_temp_tl
- {
- \exp_not:c {
- __semantex_make_object_of_\l__semantex_render_output_class_temp_tl _with_options:nnw
- }
- % This is for outputting -- the command
- % \__semantex_make_object_of_class_???_with_options:nnw
- % makes a one-time object of class ??? and allows us to
- % immediately pass options to it
- {
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { upperputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { upper } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { lowerputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { lower } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { upperleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { lowerleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { preupper } { \semantex_data_tl_get_exp_not:nn { #1 } { preupper } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { postupper } { \semantex_data_tl_get_exp_not:nn { #1 } { postupper } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { prelower } { \semantex_data_tl_get_exp_not:nn { #1 } { prelower } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { postlower } { \semantex_data_tl_get_exp_not:nn { #1 } { postlower } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { preupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { postupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { prelowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { postlowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { heightphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { slantingphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom } }
- \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
- { texclass } { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } }
- \exp_not:V \l__semantex_render_outputoptions_temp_tl
- % These are the options we pass to the output class so that it
- % can eventually render it
- }
- { \exp_not:V \l__semantex_render_symbol_temp_tl }
+ \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } % Checks if more than one argument has been received, i.e. whether we want to render any argument
+ {
+ \semantex_data_bool_get:nnTF { #1 } { leftargument } % Checks if left or right argument
+ {
+ \semantex_left_pre_return:n { #1 }
+ \tl_set:Nx\l__semantex_render_symbol_temp_tl { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % Stores the symbol in a temporary command
+ \tl_set:Nx \l__semantex_render_temp_tl
+ {
+ \exp_not:c {
+ __semantex_make_object_of_\l__semantex_render_output_class_temp_tl _with_options:nnw
+ }
+ % This is for outputting -- the command
+ % \__semantex_make_object_of_class_???_with_options:nnw
+ % makes a one-time object of class ??? and allows us to
+ % immediately pass options to it
+ {
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { upperputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { upper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { lowerputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { lower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { preupper } { \semantex_data_tl_get_exp_not:nn { #1 } { preupper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postupper } { \semantex_data_tl_get_exp_not:nn { #1 } { postupper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { prelower } { \semantex_data_tl_get_exp_not:nn { #1 } { prelower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postlower } { \semantex_data_tl_get_exp_not:nn { #1 } { postlower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { texclass } { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } }
+ \exp_not:V \l__semantex_render_outputoptions_temp_tl
+ % These are the options we pass to the output class so that it
+ % can eventually render it
+ }
+ { \exp_not:V \l__semantex_render_symbol_temp_tl }
+ }
+ }
+ {
+ \semantex_right_pre_return:n { #1 }
+ \tl_set:Nx\l__semantex_render_symbol_temp_tl { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % Stores the symbol in a temporary command
+ \tl_set:Nx \l__semantex_render_temp_tl
+ {
+ \exp_not:c {
+ __semantex_make_object_of_\l__semantex_render_output_class_temp_tl _with_options:nnw
+ }
+ % This is for outputting -- the command
+ % \__semantex_make_object_of_class_???_with_options:nnw
+ % makes a one-time object of class ??? and allows us to
+ % immediately pass options to it
+ {
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { upperleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { lowerleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { preupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { prelowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postlowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { heightphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { slantingphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { texclass } { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } }
+ \exp_not:V \l__semantex_render_outputoptions_temp_tl
+ % These are the options we pass to the output class so that it
+ % can eventually render it
+ }
+ { \exp_not:V \l__semantex_render_symbol_temp_tl }
+ }
+ }
+ }
+ {
+ \tl_set:Nx\l__semantex_render_symbol_temp_tl { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % Stores the symbol in a temporary command
+ \tl_set:Nx \l__semantex_render_temp_tl
+ {
+ \exp_not:c {
+ __semantex_make_object_of_\l__semantex_render_output_class_temp_tl _with_options:nnw
+ }
+ % This is for outputting -- the command
+ % \__semantex_make_object_of_class_???_with_options:nnw
+ % makes a one-time object of class ??? and allows us to
+ % immediately pass options to it
+ {
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { upperputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { upper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { lowerputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { lower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { upperleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { lowerleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { preupper } { \semantex_data_tl_get_exp_not:nn { #1 } { preupper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postupper } { \semantex_data_tl_get_exp_not:nn { #1 } { postupper } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { prelower } { \semantex_data_tl_get_exp_not:nn { #1 } { prelower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postlower } { \semantex_data_tl_get_exp_not:nn { #1 } { postlower } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { preupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { prelowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { postlowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { heightphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { slantingphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom } }
+ \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl }
+ { texclass } { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } }
+ \exp_not:V \l__semantex_render_outputoptions_temp_tl
+ % These are the options we pass to the output class so that it
+ % can eventually render it
+ }
+ { \exp_not:V \l__semantex_render_symbol_temp_tl }
+ }
}
}
{
@@ -1669,7 +1764,7 @@
}
}
\group_begin:
- \semantex_write_output_to_semtex_file:V \l__semantex_render_temp_tl
+ \semantex_write_output_to_semtex_file_V:N \l__semantex_render_temp_tl
% Adds the output to the .semtex file, if this has been turned on,
% which it is not by default.
\group_end:
@@ -1703,113 +1798,78 @@
\cs_new_protected:Npn \semantex_parentheses_store:nN#1#2
{
\semantex_data_tl_get_store:nnN { #1 } { parsize } \l__semantex_parentheses_store_temp_tl
- \semantex_data_bool_get:nnTF { #1 } { allowSemantexDelimiterSize }
+ \str_case:VnF { \l__semantex_parentheses_store_temp_tl } % This is where \big,\Big, etc. go.
{
- \tl_set:Nn#2 { \SemantexParentheses }
- \tl_put_right:Nx#2
- {
- { \exp_not:V \l__semantex_parentheses_store_temp_tl }
- { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } }
- { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } }
+ { normal } {
+ \tl_set:Nx #2
{
+ \exp_not:N \SemantexMathOpen { }
+ \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
\semantex_data_tl_get_exp_not:nn { #1 } { prearg }
\semantex_data_tl_get_exp_not:nn { #1 } { arg }
\semantex_data_tl_get_exp_not:nn { #1 } { postarg }
+ \exp_not:N \SemantexMathClose { }
+ \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
}
}
- }
- {
- \str_case:VnF { \l__semantex_parentheses_store_temp_tl } % This is where \big,\Big, etc. go.
- {
- { normal } {
- \tl_set:Nx#2
- {
- \semantex_data_tl_get_exp_not:nn { #1 } { prearg }
- \semantex_data_tl_get_exp_not:nn { #1 } { arg }
- \semantex_data_tl_get_exp_not:nn { #1 } { postarg }
- }
- \str_if_eq:xnF { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } } { . }
- {
- \tl_put_left:Nx#2
- {
- \exp_not:N \mathopen \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
- }
- }
- \str_if_eq:xnF { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } } { . }
- {
- \tl_put_right:Nx#2
- {
- \exp_not:N \mathclose \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
- }
- }
- }
- { auto } {
- \tl_set:Nx#2
- {
- \exp_not:N \SemantexLeft \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
- \semantex_data_tl_get_exp_not:nn { #1 } { prearg }
- \semantex_data_tl_get_exp_not:nn { #1 } { arg }
- \semantex_data_tl_get_exp_not:nn { #1 } { postarg }
- \exp_not:N \SemantexRight \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
- }
- }
- { * } {
- \tl_set:Nx#2
- {
- \exp_not:N \SemantexLeft \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
- \semantex_data_tl_get_exp_not:nn { #1 } { prearg }
- \semantex_data_tl_get_exp_not:nn { #1 } { arg }
- \semantex_data_tl_get_exp_not:nn { #1 } { postarg }
- \exp_not:N \SemantexRight \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
- }
- }
- }
- {
- \tl_set:Nx#2
+ { auto } {
+ \tl_set:Nx #2
{
- \exp_not:N \mathopen
- \exp_not:V \l__semantex_parentheses_store_temp_tl
+ \exp_not:N \SemantexMathOpenAuto
\semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
\semantex_data_tl_get_exp_not:nn { #1 } { prearg }
\semantex_data_tl_get_exp_not:nn { #1 } { arg }
\semantex_data_tl_get_exp_not:nn { #1 } { postarg }
- \exp_not:N \mathclose
- \exp_not:V \l__semantex_parentheses_store_temp_tl
+ \exp_not:N \SemantexMathCloseAuto
\semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
}
}
- }
-}
-
-\cs_generate_variant:Nn \str_case:nnF { VnF }
-
-\cs_generate_variant:Nn \str_if_eq:nnF { xnF }
-
-\cs_new_protected:Npn \semantex_no_parentheses_store:nN#1#2
-% The central command for handling the rendering of arguments with no parentheses around
-{
- \semantex_data_bool_get:nnTF { #1 } { allowSemantexDelimiterSize }
- {
- \tl_set:Nn#2 { \SemantexNoParentheses }
- \tl_put_right:Nx#2
- {
+ { * } {
+ \tl_set:Nx #2
{
+ \exp_not:N \SemantexMathOpenAuto
+ \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
\semantex_data_tl_get_exp_not:nn { #1 } { prearg }
\semantex_data_tl_get_exp_not:nn { #1 } { arg }
\semantex_data_tl_get_exp_not:nn { #1 } { postarg }
+ \exp_not:N \SemantexMathCloseAuto
+ \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
}
}
}
{
- \tl_set:Nx#2
+ \tl_set:Nx #2
{
+ \exp_not:N \SemantexMathOpen
+ \exp_not:V \l__semantex_parentheses_store_temp_tl
+ \semantex_data_tl_get_exp_not:nn { #1 } { leftpar }
\semantex_data_tl_get_exp_not:nn { #1 } { prearg }
\semantex_data_tl_get_exp_not:nn { #1 } { arg }
\semantex_data_tl_get_exp_not:nn { #1 } { postarg }
+ \exp_not:N \SemantexMathClose
+ \exp_not:V \l__semantex_parentheses_store_temp_tl
+ \semantex_data_tl_get_exp_not:nn { #1 } { rightpar }
}
}
}
+\cs_generate_variant:Nn \str_case:nnF { VnF }
+
+\cs_generate_variant:Nn \str_if_eq:nnF { xnF }
+
+\cs_new_protected:Npn \semantex_no_parentheses_store:nN#1#2
+% The central command for handling the rendering of arguments with no parentheses around
+{
+ \tl_set:Nx#2
+ {
+ \exp_not:N\SemantexMathOpenNoPar
+ \semantex_data_tl_get_exp_not:nn { #1 } { prearg }
+ \semantex_data_tl_get_exp_not:nn { #1 } { arg }
+ \semantex_data_tl_get_exp_not:nn { #1 } { postarg }
+ \exp_not:N\SemantexMathCloseNoPar
+ }
+}
+
\cs_new_protected:Npn \__semantex_symbol_parentheses_store:nnnnN#1#2#3#4#5
% The central command handling the rendering of symbol parentheses
{
@@ -2188,7 +2248,6 @@
\cs_new_protected:Npn \_semantex_arg_return_store:nN#1#2
{
- \semantex_data_tl_get_store:nnN { #1 } { parsize } \l__arg_return_store_parsize_temp_tl
\semantex_data_bool_get:nnTF { #1 } { par }
{
\semantex_data_int_if_positive:nnTF { #1 } { numberofarguments }
@@ -5621,8 +5680,6 @@
dataprovide=parseoptions,
dataprovide=texclass,
boolprovide=leftargument,
- boolprovide=allowSemantexDelimiterSize,
- boolsettrue=allowSemantexDelimiterSize,
dataprovide=heightphantom,
dataprovide=slantingphantom,
execute={ \semantex_data_seq_provide:nn { \semantex_this: } { commands_sequence } },
@@ -5692,21 +5749,6 @@
},
},
},
- {allowSemantexDelimiterSize}{
- strifeqTF={#1}{true}
- {
- boolsettrue={allowSemantexDelimiterSize},
- }
- {
- strifeqTF={#1}{false}
- {
- boolsetfalse={allowSemantexDelimiterSize},
- }
- {
- ERRORkeyvaluenotfound={allowSemantexDelimiterSize}{#1},
- }
- },
- },
{default}{si={#1}},
{degreedefault}{sd={#1}},
{arg}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } },
@@ -5893,7 +5935,9 @@
},
},
{parsize}{
- execute={ \semantex_data_tl_set:nnn { ##1 } { parsize } { #1 } },
+ execute={
+ \semantex_data_tl_set:nnn { ##1 } { parsize } { #1 }
+ },
},
{leftpar}{
execute={ \semantex_data_tl_set:nnn { ##1 } { leftpar } { #1 } },
@@ -6023,12 +6067,16 @@
},
{preupper}{
execute={
- \semantex_data_tl_put_left:nnn { ##1 } { preupper } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_left:nnn { ##1 } { preupper } { #1 }
+ }
},
},
{postupper}{
execute={
- \semantex_data_tl_put_right:nnn { ##1 } { postupper } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_right:nnn { ##1 } { postupper } { #1 }
+ }
},
},
{upperputleft}{
@@ -6203,12 +6251,16 @@
},
{prelower}{
execute={
- \semantex_data_tl_put_left:nnn { ##1 } { prelower } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_left:nnn { ##1 } { prelower } { #1 }
+ }
},
},
{postlower}{
execute={
- \semantex_data_tl_put_right:nnn { ##1 } { postlower } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_right:nnn { ##1 } { postlower } { #1 }
+ }
},
},
{lowerputleft}{
@@ -6383,12 +6435,16 @@
},
{preupperleft}{
execute={
- \semantex_data_tl_put_left:nnn { ##1 } { preupperleft } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_left:nnn { ##1 } { preupperleft } { #1 }
+ }
},
},
{postupperleft}{
execute={
- \semantex_data_tl_put_right:nnn { ##1 } { postupperleft } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_right:nnn { ##1 } { postupperleft } { #1 }
+ }
},
},
{upperleftputright}{
@@ -6563,12 +6619,16 @@
},
{prelowerleft}{
execute={
- \semantex_data_tl_put_left:nnn { ##1 } { prelowerleft } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_left:nnn { ##1 } { prelowerleft } { #1 }
+ }
},
},
{postlowerleft}{
execute={
- \semantex_data_tl_put_right:nnn { ##1 } { postlowerleft } { #1 }
+ \tl_if_blank:nF{#1}{
+ \semantex_data_tl_put_right:nnn { ##1 } { postlowerleft } { #1 }
+ }
},
},
{lowerleftputright}{
diff --git a/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua b/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
index 1ebce1f716f..0ecb5e62408 100644
--- a/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
+++ b/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
@@ -64,6 +64,11 @@ addIDsToRegisters = function(str)
end
removeSuperfluousIDs = function()
+ local p = content:find('([^\\]%%[^\n]-)\\SemantexIDcommand{}([^\n]-\n)')
+ while p do
+ content = content:gsub('([^\\]%%[^\n]-)\\SemantexIDcommand{}([^\n]-\n)','%1%2')
+ p = content:find('([^\\]%%[^\n]-)\\SemantexIDcommand{}([^\n]-\n)')
+ end
content = content:gsub('parent(%s*)=(%s*)\\SemantexIDcommand{}','parent%1=%2')
content = content:gsub('class(%s*)=(%s*)\\SemantexIDcommand{}','class%1=%2')
content = content:gsub('clone(%s*)=(%s*)\\SemantexIDcommand{}','clone%1=%2')
@@ -75,12 +80,12 @@ removeSuperfluousIDs = function()
end
addNumbersToIDs = function()
- local n = 1
+ local n = 0
local p,q = string.find(content,'\\SemantexIDcommand{}')
while q do
+ n = n + 1
content = content:sub(1,q-1) .. n .. content:sub(q,-1)
p, q = string.find(content,'\\SemantexIDcommand{}')
- n = n + 1
end
end
@@ -154,7 +159,7 @@ semantexIDluacommand = function(id, source, output)
netto = netto + 1
elseif e == '\\' then
q = q + 1
- -- there is no chance that the source contains a %, so we do not
+ -- there is no chance that the source contains an unescaped %, so we do not
-- check for this
end
end
@@ -187,14 +192,18 @@ semantexIDluacommand = function(id, source, output)
output = output:gsub('\\mathclose \\}', '\\}')
output = output:gsub('\\mathopen \\lbrace', '\\lbrace')
output = output:gsub('\\mathclose \\rbrace', '\\rbrace')
- output = output:gsub('\\mathopen \\lbrack', '\\rbrack')
+ output = output:gsub('\\mathopen \\lbrack', '\\lbrack')
output = output:gsub('\\mathclose \\rbrack', '\\rbrack')
output = output:gsub('\\mathopen \\langle', '\\langle')
output = output:gsub('\\mathclose \\rangle', '\\rangle')
- output = output:gsub('\\mathopen \\lvert', '\\rvert')
+ output = output:gsub('\\mathopen \\lvert', '\\lvert')
output = output:gsub('\\mathclose \\rvert', '\\rvert')
- output = output:gsub('\\mathopen \\lVert', '\\rVert')
+ output = output:gsub('\\mathopen \\vert', '\\lvert')
+ output = output:gsub('\\mathclose \\vert', '\\rvert')
+ output = output:gsub('\\mathopen \\lVert', '\\lVert')
output = output:gsub('\\mathclose \\rVert', '\\rVert')
+ output = output:gsub('\\mathopen \\Vert', '\\lVert')
+ output = output:gsub('\\mathclose \\Vert', '\\rVert')
output = output:gsub('%^{\\prime }', '\'')
output = output:gsub('%^{\\prime \\prime }', '\'\'')
output = output:gsub('%^{\\prime \\prime \\prime }', '\'\'\'')
@@ -227,8 +236,56 @@ stripRemainingSemantexIDs = function()
content = content:gsub('\\SemantexIDcommand{%d+}', '')
end
+removeParenthesisCommands = function()
+ content = content:gsub('\\SemantexMathOpen \\bigg%s?', '\\biggl')
+ content = content:gsub('\\SemantexMathClose \\bigg%s?', '\\biggr')
+ content = content:gsub('\\SemantexMathOpen \\Bigg%s?', '\\Biggl')
+ content = content:gsub('\\SemantexMathClose \\Bigg%s?', '\\Biggr')
+ content = content:gsub('\\SemantexMathOpen \\big%s?', '\\bigl')
+ content = content:gsub('\\SemantexMathClose \\big%s?', '\\bigr')
+ content = content:gsub('\\SemantexMathOpen \\Big%s?', '\\Bigl')
+ content = content:gsub('\\SemantexMathClose \\Big%s?', '\\Bigr')
+ content = content:gsub('\\SemantexMathOpen{} %(', '(')
+ content = content:gsub('%s*\\SemantexMathClose{}%)', ')')
+ content = content:gsub('\\SemantexMathOpen{} %[', '[')
+ content = content:gsub('%s*\\SemantexMathClose{}%]', ']')
+ content = content:gsub('\\SemantexMathOpen{} \\{', '\\{')
+ content = content:gsub('%s*\\SemantexMathClose{} \\}', '\\}')
+ content = content:gsub('\\SemantexMathOpen{} \\lbrace', '\\lbrace')
+ content = content:gsub('\\SemantexMathClose{} \\rbrace', '\\rbrace')
+ content = content:gsub('\\SemantexMathOpen{} \\lbrack', '\\rbrack')
+ content = content:gsub('\\SemantexMathClose{} \\rbrack', '\\rbrack')
+ content = content:gsub('\\SemantexMathOpen{} \\langle', '\\langle')
+ content = content:gsub('\\SemantexMathClose{} \\rangle', '\\rangle')
+ content = content:gsub('\\SemantexMathOpen{} \\lvert', '\\lvert')
+ content = content:gsub('\\SemantexMathClose{} \\rvert', '\\rvert')
+ content = content:gsub('\\SemantexMathOpen{} \\vert', '\\lvert')
+ content = content:gsub('\\SemantexMathClose{} \\vert', '\\rvert')
+ content = content:gsub('\\SemantexMathOpen{} \\lVert', '\\lVert')
+ content = content:gsub('\\SemantexMathClose{} \\rVert', '\\rVert')
+ content = content:gsub('\\SemantexMathOpen{} \\Vert', '\\lVert')
+ content = content:gsub('\\SemantexMathClose{} \\Vert', '\\rVert')
+ content = content:gsub('\\SemantexMathOpen{} .%s?', '')
+ content = content:gsub('\\SemantexMathClose{} .%s?', '')
+ content = content:gsub('\\SemantexMathOpen{}', '\\mathopen ')
+ content = content:gsub('\\SemantexMathClose{}', '\\mathclose ')
+ content = content:gsub('\\SemantexMathOpenAuto%s?', '\\SemantexLeft')
+ content = content:gsub('\\SemantexMathCloseAuto%s?', '\\SemantexRight')
+ content = content:gsub('\\SemantexMathOpenNoPar%s?', '')
+ content = content:gsub('\\SemantexMathCloseNoPar%s?', '')
+ content = content:gsub('\\SemantexMathOpen%s?', '\\mathopen')
+ content = content:gsub('\\SemantexMathClose%s?', '\\mathclose')
+end
+
+stripComments = function()
+ content = content:gsub('\\%%', '\\StripSemantexEscapedPercent')
+ content = content:gsub('(\\%w+)%%.-\n%s*', '%1 ')
+ content = content:gsub('%%.-\n%s*', '')
+ content = content:gsub('\\StripSemantexEscapedPercent', '\\%%')
+end
+
addSemtexPackageToFile = function()
- content = [[% The following was added by "stripsemantex"
+ content = [[% The following was added by "stripsemantex":
\usepackage{semtex,leftindex,graphicx}
diff --git a/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty b/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
index 2599c108c26..419a4dd75a4 100644
--- a/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
+++ b/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
@@ -1,5 +1,5 @@
\RequirePackage{xparse}
-\ProvidesExplPackage{stripsemantex}{2020/09/13}{0.43}{}
+\ProvidesExplPackage{stripsemantex}{2020/09/27}{0.44}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
@@ -18,6 +18,8 @@
\msg_new:nnn { stripsemantex } { begin_document_not_found } { No~\token_to_str:N\begin{document}~found~in~the~file~#1;~it~has~to~be~in~the~main~document. }
+\msg_new:nnn { stripsemantex } { rerun_stripsemantex } { Some~SemanTeX~commands~are~still~remaining~in~your~document;~please~(re)run~TeX~on~the~file~#1_prestripped.tex,~and~then~rerun~LuaTeX~on~the~file~\jobname.tex. }
+
\sys_if_engine_luatex:F { \msg_fatal:nn { stripsemantex } { not_luatex } }
\lua_now:n { require('stripsemantex.lua') }
@@ -31,6 +33,10 @@
\lua_now:e {
copy_file('\lua_escape:e{#1}.tex', '\lua_escape:e{#1}_prestripped.tex')
+ }
+
+ \lua_now:e
+ {
openFile('\lua_escape:e{#1}_prestripped.tex')
}
@@ -53,9 +59,13 @@
addNumbersToIDs()
closeFile('\lua_escape:e{#1}_prestripped.tex')
}
+
+ \msg_warning:nnn { stripsemantex } { rerun_stripsemantex } { #1 }
}
-\cs_new_protected:Npn\stripsemantex_create_stripped_file:n#1
+\bool_new:N\g_stripsemantex_something_left_to_strip_bool
+
+\cs_new_protected:Npn\stripsemantex_strip_file:n#1
{
\file_if_exist:nF { #1_prestripped.semtex }
{
@@ -63,8 +73,7 @@
}
\lua_now:e {
- copy_file('\lua_escape:e{#1}_prestripped.tex', '\lua_escape:e{#1}_stripped.tex')
- openFile('\lua_escape:e{#1}_stripped.tex')
+ openFile('\lua_escape:e{#1}_prestripped.tex')
}
\DeclareDocumentCommand\SemantexID{ m t{\BeginSource} }
@@ -78,6 +87,7 @@
\cs_set:Npn\strip_semantex_id_command:w##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput
{
+ \bool_set_true:N \g_stripsemantex_something_left_to_strip_bool
\lua_now:e
{
semantexIDluacommand( '\lua_escape:e{\tl_trim_spaces:n{##1}}' , '\lua_escape:e{\exp_not:n{##2}}' , '\lua_escape:e{\exp_not:n{##3}}' )
@@ -95,30 +105,69 @@
\lua_now:e
{
stripRemainingSemantexIDs()
- addSemtexPackageToFile()
- closeFile('\lua_escape:e{#1}_stripped.tex')
+ }
+
+ \bool_if:NTF \g_stripsemantex_something_left_to_strip_bool
+ {
+ \cs_set:Npn\DeclareObject##1
+ {
+ \lua_now:e { addIDsToRegisters ( '\cs_to_str:N ##1' ) }
+ }
+
+ \cs_set:Npn\DeclareClass##1
+ {
+ \lua_now:e { addIDsToRegisters ( '\cs_to_str:N ##1' ) }
+ }
+
+ \cs_set:Npn\SemantexID##1 {}
+
+ \cs_set:Npn\BeginSource##1\EndSource\BeginOutput##2\EndOutput {}
+
+ \file_input:n { #1.semtex }
+
+ \lua_now:e
+ {
+ removeSuperfluousIDs()
+ addNumbersToIDs()
+ closeFile('\lua_escape:e{#1}_prestripped.tex')
+ }
+
+ \msg_warning:nnn { stripsemantex } { rerun_stripsemantex } { #1 }
+ }
+ {
+ \lua_now:e
+ {
+ removeParenthesisCommands()
+ addSemtexPackageToFile()
+ closeFile('\lua_escape:e{#1}_prestripped.tex')
+ copy_file('\lua_escape:e{#1}_prestripped.tex', '\lua_escape:e{#1}_stripped.tex')
+ }
}
}
-\cs_set_eq:NN\StripSemantexCopyFile\stripsemantex_create_prestripped_file:n
-
-\cs_new_protected:Npn\StripSemantexStripFile#1
-{
- \begingroup
- \ExplSyntaxOn
- \stripsemantex_create_stripped_file:n { #1 }
-% \ExplSyntaxOff
- \endgroup
-}
\cs_new_protected:Npn\StripSemantex#1
{
- % This will only work after a bug has been corrected in expl3
+ \group_begin:
+ \ExplSyntaxOn % this will prevent the inserting of the annoying extra spaces
+ % from the .semtex file into the document.
\file_compare_timestamp:nNnTF { #1.semtex } < { #1_prestripped.semtex }
{
- \StripSemantexStripFile { #1 }
+ \stripsemantex_strip_file:n { #1 }
+ }
+ {
+ \stripsemantex_create_prestripped_file:n { #1 }
}
+ \group_end:
+}
+
+\cs_new_protected:Npn\StripSemantexStripComments#1
+{
+ \lua_now:e
{
- \StripSemantexCopyFile { #1 }
+ copy_file('\lua_escape:e{#1}.tex', '\lua_escape:e{#1}_comments_stripped.tex')
+ openFile('\lua_escape:e{#1}_comments_stripped.tex')
+ stripComments()
+ closeFile('\lua_escape:e{#1}_comments_stripped.tex')
}
} \ No newline at end of file