How use scantokens at the end of environment to pass a expanded macro (or a copy) to list in xparse?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

What are these boxed doors outside store fronts in New York?

How can bays and straits be determined in a procedurally generated map?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

What's the output of a record needle playing an out-of-speed record

Convert two switches to a dual stack, and add outlet - possible here?

What doth I be?

What's that red-plus icon near a text?

What's the point of deactivating Num Lock on login screens?

Do I have a twin with permutated remainders?

RSA: Danger of using p to create q

High voltage LED indicator 40-1000 VDC without additional power supply

Revoked SSL certificate

Could an aircraft fly or hover using only jets of compressed air?

Roll the carpet

Maximum likelihood parameters deviate from posterior distributions

Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?

How does quantile regression compare to logistic regression with the variable split at the quantile?

Cross compiling for RPi - error while loading shared libraries

How much of data wrangling is a data scientist's job?

What is a clear way to write a bar that has an extra beat?

Codimension of non-flat locus

How does one intimidate enemies without having the capacity for violence?

Why are electrically insulating heatsinks so rare? Is it just cost?



How use scantokens at the end of environment to pass a expanded macro (or a copy) to list in xparse?














0















I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
I have defined a one command and two environments and I have had a problem with one of them.



The problem happens when trying to execute the following command:



tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl



at the end of the environment:



tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
% Copy macro every time in tl_var (at definition time) and pass to list
cs_set_eq:NN l_my_macro_copy_tl macro
expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:



the following error occurs



! TeX capacity exceeded, sorry [input stack size=5000].
<to be read again>
q_nil


My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



This is my example file (MWE), the comments should be removed to see the error that occurs.



documentclassarticle
usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
setlengthparindent0pt
pagestyleempty
ExplSyntaxOn
% show content save in macro
tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl


% elementinlistname and clearlistlistname
cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

% addcontentlistname#1 ...need double ...
NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

% usecontent[index]listname
DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

cs_new_protected:Npn savecontent_add_content:nn #1 #2

seq_if_exist:cF l_savecontent_content_#1_seq
seq_new:c l_savecontent_content_#1_seq
__savecontent_add_content:nn #1 #2


cs_new_protected:Npn __savecontent_add_content:nn #1 #2

tl_map_inline:nn #2

seq_gput_right:cn l_savecontent_content_#1_seq ##1



cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

keys_define:nn scontent

save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
show-all .meta:n = show-env = true , show-cmd = true ,%


NewDocumentCommandSetscontent +m keys_set:nn scontent #1

% pass to list
newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

% Scontent[...]... NO verbatim env support, but Verb[...]... yes
NewDocumentCommandScontent O +m

group_begin:
IfNoValueF#1 keys_set:nn scontent #1
addcontent l_scontent_cmd_save_tl #2 % pass direct to list
IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
group_end:


% beginscontent[...] NO verbatim env suport, but Verb[...]... yes
NewDocumentEnvironmentscontent !o +b

group_begin:
IfNoValueF #1 keys_set:nn scontent #1

expandafterenvtolistexpandafter#2
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:


% beginscontent*[...] verbatim env save in macro
tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
% Copy macro every time in tl_var (at definition time) and pass to list
%cs_set_eq:NN l_my_macro_copy_tl macro
%expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
%IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:

ExplSyntaxOff
% set name of lists
Setscontent save-env=test-env, save-cmd=test-cmd
begindocument
sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
subsectionWhit texttt[show-env=false]
Text save in verb|beginscontent[show-env=false]| (hidden)

beginscontent[show-env=false]
Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionWhit texttt[show-env=true]
Text save in verb|beginscontent[show-env=true]| (Not hidden)

beginscontent[show-env=true]
Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionUsing Verbusecontent[1]test-env
Now see saved text in list:par
usecontent[2]test-envpar
usecontent[1]test-env

sectionUsing Verb*Scontent[...]...
Text save whit verb|Scontent....| (hidden)par
Scontent
using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
(by Verb*fvextra) textcolormagentainline
par

And see saved text in list using verb|usecontent[1]test-cmd| par
usecontent[1]test-cmdpar
OK
sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

subsectionWhit texttt[show-env=false]
Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

beginscontent*[show-env=false]
Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
beginVerbatim
This is from the verbatim environment: &%_"`´~
xxxxx
endVerbatim
endscontent*par
OK...it's posible to see verb|macro| whit verb|showmemacro|:par
showmemacropar
or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
Scontentshowmemacro
usecontent[2]test-cmd
subsectionThe idea whit texttt[show-env=true]
Setscontent save-cmd=test-other
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim A
beginVerbatim
verbatim environment A: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacropar
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim B
beginVerbatim
verbatim environment B: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacro
XXXXXXXXXpar
And see in reverse order:par
usecontent[2]test-otherpar
usecontent[1]test-otherpar
NOT OK,...
subsectionThe problem whit texttt[show-env=true]
beginscontent*[show-env=true]
Some text in whit verbatim C
beginVerbatim
verbatim environment C: &%_"`´~
endVerbatim
enddocument


An image to complement
Idea of the expected
regards









share


























    0















    I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
    I have defined a one command and two environments and I have had a problem with one of them.



    The problem happens when trying to execute the following command:



    tl_new:N l_temp_argument_tl
    NewDocumentCommandshowme +m %
    tl_set:Nx l_temp_argument_tl #1
    tex_newlinechar:D = 13
    exp_not:N scantokens exp_after:wN l_temp_argument_tl



    at the end of the environment:



    tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
    NewDocumentEnvironmentscontent* !O

    group_begin:
    IfNoValueF #1 keys_set:nn scontent #1
    filecontentsdefjobname.tscmacro

    endfilecontentsdef %
    % Copy macro every time in tl_var (at definition time) and pass to list
    cs_set_eq:NN l_my_macro_copy_tl macro
    expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
    IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
    group_end:



    the following error occurs



    ! TeX capacity exceeded, sorry [input stack size=5000].
    <to be read again>
    q_nil


    My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



    I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



    This is my example file (MWE), the comments should be removed to see the error that occurs.



    documentclassarticle
    usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
    usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
    setlengthparindent0pt
    pagestyleempty
    ExplSyntaxOn
    % show content save in macro
    tl_new:N l_temp_argument_tl
    NewDocumentCommandshowme +m %
    tl_set:Nx l_temp_argument_tl #1
    tex_newlinechar:D = 13
    exp_not:N scantokens exp_after:wN l_temp_argument_tl


    % elementinlistname and clearlistlistname
    cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
    cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

    % addcontentlistname#1 ...need double ...
    NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

    % usecontent[index]listname
    DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

    cs_new_protected:Npn savecontent_add_content:nn #1 #2

    seq_if_exist:cF l_savecontent_content_#1_seq
    seq_new:c l_savecontent_content_#1_seq
    __savecontent_add_content:nn #1 #2


    cs_new_protected:Npn __savecontent_add_content:nn #1 #2

    tl_map_inline:nn #2

    seq_gput_right:cn l_savecontent_content_#1_seq ##1



    cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

    keys_define:nn scontent

    save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
    save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
    show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
    show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
    show-all .meta:n = show-env = true , show-cmd = true ,%


    NewDocumentCommandSetscontent +m keys_set:nn scontent #1

    % pass to list
    newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

    % Scontent[...]... NO verbatim env support, but Verb[...]... yes
    NewDocumentCommandScontent O +m

    group_begin:
    IfNoValueF#1 keys_set:nn scontent #1
    addcontent l_scontent_cmd_save_tl #2 % pass direct to list
    IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
    group_end:


    % beginscontent[...] NO verbatim env suport, but Verb[...]... yes
    NewDocumentEnvironmentscontent !o +b

    group_begin:
    IfNoValueF #1 keys_set:nn scontent #1

    expandafterenvtolistexpandafter#2
    IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
    group_end:


    % beginscontent*[...] verbatim env save in macro
    tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
    NewDocumentEnvironmentscontent* !O

    group_begin:
    IfNoValueF #1 keys_set:nn scontent #1
    filecontentsdefjobname.tscmacro

    endfilecontentsdef %
    % Copy macro every time in tl_var (at definition time) and pass to list
    %cs_set_eq:NN l_my_macro_copy_tl macro
    %expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
    %IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
    group_end:

    ExplSyntaxOff
    % set name of lists
    Setscontent save-env=test-env, save-cmd=test-cmd
    begindocument
    sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
    subsectionWhit texttt[show-env=false]
    Text save in verb|beginscontent[show-env=false]| (hidden)

    beginscontent[show-env=false]
    Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
    We have coded this in LaTeX: both $E=mc^2$.
    endscontent

    OK
    subsectionWhit texttt[show-env=true]
    Text save in verb|beginscontent[show-env=true]| (Not hidden)

    beginscontent[show-env=true]
    Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
    We have coded this in LaTeX: both $E=mc^2$.
    endscontent

    OK
    subsectionUsing Verbusecontent[1]test-env
    Now see saved text in list:par
    usecontent[2]test-envpar
    usecontent[1]test-env

    sectionUsing Verb*Scontent[...]...
    Text save whit verb|Scontent....| (hidden)par
    Scontent
    using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
    (by Verb*fvextra) textcolormagentainline
    par

    And see saved text in list using verb|usecontent[1]test-cmd| par
    usecontent[1]test-cmdpar
    OK
    sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

    subsectionWhit texttt[show-env=false]
    Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

    beginscontent*[show-env=false]
    Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
    beginVerbatim
    This is from the verbatim environment: &%_"`´~
    xxxxx
    endVerbatim
    endscontent*par
    OK...it's posible to see verb|macro| whit verb|showmemacro|:par
    showmemacropar
    or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
    Scontentshowmemacro
    usecontent[2]test-cmd
    subsectionThe idea whit texttt[show-env=true]
    Setscontent save-cmd=test-other
    XXXXXXXXXpar
    beginscontent*[show-env=false]
    Some text in whit verbatim A
    beginVerbatim
    verbatim environment A: &%_"`´~
    endVerbatim
    endscontent*
    Scontent[show-cmd=true]showmemacropar
    XXXXXXXXXpar
    beginscontent*[show-env=false]
    Some text in whit verbatim B
    beginVerbatim
    verbatim environment B: &%_"`´~
    endVerbatim
    endscontent*
    Scontent[show-cmd=true]showmemacro
    XXXXXXXXXpar
    And see in reverse order:par
    usecontent[2]test-otherpar
    usecontent[1]test-otherpar
    NOT OK,...
    subsectionThe problem whit texttt[show-env=true]
    beginscontent*[show-env=true]
    Some text in whit verbatim C
    beginVerbatim
    verbatim environment C: &%_"`´~
    endVerbatim
    enddocument


    An image to complement
    Idea of the expected
    regards









    share
























      0












      0








      0








      I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
      I have defined a one command and two environments and I have had a problem with one of them.



      The problem happens when trying to execute the following command:



      tl_new:N l_temp_argument_tl
      NewDocumentCommandshowme +m %
      tl_set:Nx l_temp_argument_tl #1
      tex_newlinechar:D = 13
      exp_not:N scantokens exp_after:wN l_temp_argument_tl



      at the end of the environment:



      tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
      NewDocumentEnvironmentscontent* !O

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1
      filecontentsdefjobname.tscmacro

      endfilecontentsdef %
      % Copy macro every time in tl_var (at definition time) and pass to list
      cs_set_eq:NN l_my_macro_copy_tl macro
      expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
      IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:



      the following error occurs



      ! TeX capacity exceeded, sorry [input stack size=5000].
      <to be read again>
      q_nil


      My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



      I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



      This is my example file (MWE), the comments should be removed to see the error that occurs.



      documentclassarticle
      usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
      usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
      setlengthparindent0pt
      pagestyleempty
      ExplSyntaxOn
      % show content save in macro
      tl_new:N l_temp_argument_tl
      NewDocumentCommandshowme +m %
      tl_set:Nx l_temp_argument_tl #1
      tex_newlinechar:D = 13
      exp_not:N scantokens exp_after:wN l_temp_argument_tl


      % elementinlistname and clearlistlistname
      cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
      cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

      % addcontentlistname#1 ...need double ...
      NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

      % usecontent[index]listname
      DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

      cs_new_protected:Npn savecontent_add_content:nn #1 #2

      seq_if_exist:cF l_savecontent_content_#1_seq
      seq_new:c l_savecontent_content_#1_seq
      __savecontent_add_content:nn #1 #2


      cs_new_protected:Npn __savecontent_add_content:nn #1 #2

      tl_map_inline:nn #2

      seq_gput_right:cn l_savecontent_content_#1_seq ##1



      cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

      keys_define:nn scontent

      save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
      save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
      show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
      show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
      show-all .meta:n = show-env = true , show-cmd = true ,%


      NewDocumentCommandSetscontent +m keys_set:nn scontent #1

      % pass to list
      newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

      % Scontent[...]... NO verbatim env support, but Verb[...]... yes
      NewDocumentCommandScontent O +m

      group_begin:
      IfNoValueF#1 keys_set:nn scontent #1
      addcontent l_scontent_cmd_save_tl #2 % pass direct to list
      IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
      group_end:


      % beginscontent[...] NO verbatim env suport, but Verb[...]... yes
      NewDocumentEnvironmentscontent !o +b

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1

      expandafterenvtolistexpandafter#2
      IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:


      % beginscontent*[...] verbatim env save in macro
      tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
      NewDocumentEnvironmentscontent* !O

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1
      filecontentsdefjobname.tscmacro

      endfilecontentsdef %
      % Copy macro every time in tl_var (at definition time) and pass to list
      %cs_set_eq:NN l_my_macro_copy_tl macro
      %expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
      %IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:

      ExplSyntaxOff
      % set name of lists
      Setscontent save-env=test-env, save-cmd=test-cmd
      begindocument
      sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
      subsectionWhit texttt[show-env=false]
      Text save in verb|beginscontent[show-env=false]| (hidden)

      beginscontent[show-env=false]
      Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
      We have coded this in LaTeX: both $E=mc^2$.
      endscontent

      OK
      subsectionWhit texttt[show-env=true]
      Text save in verb|beginscontent[show-env=true]| (Not hidden)

      beginscontent[show-env=true]
      Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
      We have coded this in LaTeX: both $E=mc^2$.
      endscontent

      OK
      subsectionUsing Verbusecontent[1]test-env
      Now see saved text in list:par
      usecontent[2]test-envpar
      usecontent[1]test-env

      sectionUsing Verb*Scontent[...]...
      Text save whit verb|Scontent....| (hidden)par
      Scontent
      using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
      (by Verb*fvextra) textcolormagentainline
      par

      And see saved text in list using verb|usecontent[1]test-cmd| par
      usecontent[1]test-cmdpar
      OK
      sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

      subsectionWhit texttt[show-env=false]
      Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

      beginscontent*[show-env=false]
      Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
      beginVerbatim
      This is from the verbatim environment: &%_"`´~
      xxxxx
      endVerbatim
      endscontent*par
      OK...it's posible to see verb|macro| whit verb|showmemacro|:par
      showmemacropar
      or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
      Scontentshowmemacro
      usecontent[2]test-cmd
      subsectionThe idea whit texttt[show-env=true]
      Setscontent save-cmd=test-other
      XXXXXXXXXpar
      beginscontent*[show-env=false]
      Some text in whit verbatim A
      beginVerbatim
      verbatim environment A: &%_"`´~
      endVerbatim
      endscontent*
      Scontent[show-cmd=true]showmemacropar
      XXXXXXXXXpar
      beginscontent*[show-env=false]
      Some text in whit verbatim B
      beginVerbatim
      verbatim environment B: &%_"`´~
      endVerbatim
      endscontent*
      Scontent[show-cmd=true]showmemacro
      XXXXXXXXXpar
      And see in reverse order:par
      usecontent[2]test-otherpar
      usecontent[1]test-otherpar
      NOT OK,...
      subsectionThe problem whit texttt[show-env=true]
      beginscontent*[show-env=true]
      Some text in whit verbatim C
      beginVerbatim
      verbatim environment C: &%_"`´~
      endVerbatim
      enddocument


      An image to complement
      Idea of the expected
      regards









      share














      I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
      I have defined a one command and two environments and I have had a problem with one of them.



      The problem happens when trying to execute the following command:



      tl_new:N l_temp_argument_tl
      NewDocumentCommandshowme +m %
      tl_set:Nx l_temp_argument_tl #1
      tex_newlinechar:D = 13
      exp_not:N scantokens exp_after:wN l_temp_argument_tl



      at the end of the environment:



      tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
      NewDocumentEnvironmentscontent* !O

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1
      filecontentsdefjobname.tscmacro

      endfilecontentsdef %
      % Copy macro every time in tl_var (at definition time) and pass to list
      cs_set_eq:NN l_my_macro_copy_tl macro
      expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
      IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:



      the following error occurs



      ! TeX capacity exceeded, sorry [input stack size=5000].
      <to be read again>
      q_nil


      My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



      I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



      This is my example file (MWE), the comments should be removed to see the error that occurs.



      documentclassarticle
      usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
      usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
      setlengthparindent0pt
      pagestyleempty
      ExplSyntaxOn
      % show content save in macro
      tl_new:N l_temp_argument_tl
      NewDocumentCommandshowme +m %
      tl_set:Nx l_temp_argument_tl #1
      tex_newlinechar:D = 13
      exp_not:N scantokens exp_after:wN l_temp_argument_tl


      % elementinlistname and clearlistlistname
      cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
      cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

      % addcontentlistname#1 ...need double ...
      NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

      % usecontent[index]listname
      DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

      cs_new_protected:Npn savecontent_add_content:nn #1 #2

      seq_if_exist:cF l_savecontent_content_#1_seq
      seq_new:c l_savecontent_content_#1_seq
      __savecontent_add_content:nn #1 #2


      cs_new_protected:Npn __savecontent_add_content:nn #1 #2

      tl_map_inline:nn #2

      seq_gput_right:cn l_savecontent_content_#1_seq ##1



      cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

      keys_define:nn scontent

      save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
      save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
      show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
      show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
      show-all .meta:n = show-env = true , show-cmd = true ,%


      NewDocumentCommandSetscontent +m keys_set:nn scontent #1

      % pass to list
      newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

      % Scontent[...]... NO verbatim env support, but Verb[...]... yes
      NewDocumentCommandScontent O +m

      group_begin:
      IfNoValueF#1 keys_set:nn scontent #1
      addcontent l_scontent_cmd_save_tl #2 % pass direct to list
      IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
      group_end:


      % beginscontent[...] NO verbatim env suport, but Verb[...]... yes
      NewDocumentEnvironmentscontent !o +b

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1

      expandafterenvtolistexpandafter#2
      IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:


      % beginscontent*[...] verbatim env save in macro
      tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
      NewDocumentEnvironmentscontent* !O

      group_begin:
      IfNoValueF #1 keys_set:nn scontent #1
      filecontentsdefjobname.tscmacro

      endfilecontentsdef %
      % Copy macro every time in tl_var (at definition time) and pass to list
      %cs_set_eq:NN l_my_macro_copy_tl macro
      %expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
      %IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
      group_end:

      ExplSyntaxOff
      % set name of lists
      Setscontent save-env=test-env, save-cmd=test-cmd
      begindocument
      sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
      subsectionWhit texttt[show-env=false]
      Text save in verb|beginscontent[show-env=false]| (hidden)

      beginscontent[show-env=false]
      Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
      We have coded this in LaTeX: both $E=mc^2$.
      endscontent

      OK
      subsectionWhit texttt[show-env=true]
      Text save in verb|beginscontent[show-env=true]| (Not hidden)

      beginscontent[show-env=true]
      Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
      We have coded this in LaTeX: both $E=mc^2$.
      endscontent

      OK
      subsectionUsing Verbusecontent[1]test-env
      Now see saved text in list:par
      usecontent[2]test-envpar
      usecontent[1]test-env

      sectionUsing Verb*Scontent[...]...
      Text save whit verb|Scontent....| (hidden)par
      Scontent
      using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
      (by Verb*fvextra) textcolormagentainline
      par

      And see saved text in list using verb|usecontent[1]test-cmd| par
      usecontent[1]test-cmdpar
      OK
      sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

      subsectionWhit texttt[show-env=false]
      Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

      beginscontent*[show-env=false]
      Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
      beginVerbatim
      This is from the verbatim environment: &%_"`´~
      xxxxx
      endVerbatim
      endscontent*par
      OK...it's posible to see verb|macro| whit verb|showmemacro|:par
      showmemacropar
      or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
      Scontentshowmemacro
      usecontent[2]test-cmd
      subsectionThe idea whit texttt[show-env=true]
      Setscontent save-cmd=test-other
      XXXXXXXXXpar
      beginscontent*[show-env=false]
      Some text in whit verbatim A
      beginVerbatim
      verbatim environment A: &%_"`´~
      endVerbatim
      endscontent*
      Scontent[show-cmd=true]showmemacropar
      XXXXXXXXXpar
      beginscontent*[show-env=false]
      Some text in whit verbatim B
      beginVerbatim
      verbatim environment B: &%_"`´~
      endVerbatim
      endscontent*
      Scontent[show-cmd=true]showmemacro
      XXXXXXXXXpar
      And see in reverse order:par
      usecontent[2]test-otherpar
      usecontent[1]test-otherpar
      NOT OK,...
      subsectionThe problem whit texttt[show-env=true]
      beginscontent*[show-env=true]
      Some text in whit verbatim C
      beginVerbatim
      verbatim environment C: &%_"`´~
      endVerbatim
      enddocument


      An image to complement
      Idea of the expected
      regards







      macros expansion expl3 xparse





      share












      share










      share



      share










      asked 1 min ago









      Pablo González LPablo González L

      1,0061820




      1,0061820




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483453%2fhow-use-scantokens-at-the-end-of-environment-to-pass-a-expanded-macro-or-a-co%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483453%2fhow-use-scantokens-at-the-end-of-environment-to-pass-a-expanded-macro-or-a-co%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

          Mpande kaSenzangakhona Biographie | Références | Menu de navigationmodifierMpande kaSenzangakhonavoir la liste des auteursm

          Hornos de Moncalvillo Voir aussi | Menu de navigationmodifierm