Preserving spaces when scannig `tl` variables into a sequence using `seq_set_split`

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












As stated in the interface3 document (Part IX, 1. Creating and initializing sequences) seq_set_split: does not preserve spaces. Wishing to scan the text contained in a _tl variable into a sequence item by item for further processing (to be parsed for example) it would be advantageous to have spaces preserved. The MWE demonstrates that this can be achieved by introducing hard spaces, but is there a way to make do without the ~s?



documentclassarticle
% RN. 11 Nov 2018
%=======================
usepackage[check-declarations,log-functions]expl3
usepackagexparse
%-----------------------
ExplSyntaxOn
tl_new:N l_rn_auxOne_tl
seq_new:N l_rn_auxOne_seq

NewDocumentCommandmyScanTextm

tl_set:Nn l_rn_auxOne_tl #1
textbftl~variable:~tl_use:N l_rn_auxOne_tl\
seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
% myExperminent
ExplSyntaxOff
%-----------------------
begindocument
verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
myScanTextThe quick brown fox jumps over the lazy dog.

verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
enddocument









share|improve this question

























    up vote
    2
    down vote

    favorite












    As stated in the interface3 document (Part IX, 1. Creating and initializing sequences) seq_set_split: does not preserve spaces. Wishing to scan the text contained in a _tl variable into a sequence item by item for further processing (to be parsed for example) it would be advantageous to have spaces preserved. The MWE demonstrates that this can be achieved by introducing hard spaces, but is there a way to make do without the ~s?



    documentclassarticle
    % RN. 11 Nov 2018
    %=======================
    usepackage[check-declarations,log-functions]expl3
    usepackagexparse
    %-----------------------
    ExplSyntaxOn
    tl_new:N l_rn_auxOne_tl
    seq_new:N l_rn_auxOne_seq

    NewDocumentCommandmyScanTextm

    tl_set:Nn l_rn_auxOne_tl #1
    textbftl~variable:~tl_use:N l_rn_auxOne_tl\
    seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
    % myExperminent
    ExplSyntaxOff
    %-----------------------
    begindocument
    verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
    myScanTextThe quick brown fox jumps over the lazy dog.

    verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
    enddocument









    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      As stated in the interface3 document (Part IX, 1. Creating and initializing sequences) seq_set_split: does not preserve spaces. Wishing to scan the text contained in a _tl variable into a sequence item by item for further processing (to be parsed for example) it would be advantageous to have spaces preserved. The MWE demonstrates that this can be achieved by introducing hard spaces, but is there a way to make do without the ~s?



      documentclassarticle
      % RN. 11 Nov 2018
      %=======================
      usepackage[check-declarations,log-functions]expl3
      usepackagexparse
      %-----------------------
      ExplSyntaxOn
      tl_new:N l_rn_auxOne_tl
      seq_new:N l_rn_auxOne_seq

      NewDocumentCommandmyScanTextm

      tl_set:Nn l_rn_auxOne_tl #1
      textbftl~variable:~tl_use:N l_rn_auxOne_tl\
      seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
      textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
      % myExperminent
      ExplSyntaxOff
      %-----------------------
      begindocument
      verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
      myScanTextThe quick brown fox jumps over the lazy dog.

      verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
      myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
      enddocument









      share|improve this question













      As stated in the interface3 document (Part IX, 1. Creating and initializing sequences) seq_set_split: does not preserve spaces. Wishing to scan the text contained in a _tl variable into a sequence item by item for further processing (to be parsed for example) it would be advantageous to have spaces preserved. The MWE demonstrates that this can be achieved by introducing hard spaces, but is there a way to make do without the ~s?



      documentclassarticle
      % RN. 11 Nov 2018
      %=======================
      usepackage[check-declarations,log-functions]expl3
      usepackagexparse
      %-----------------------
      ExplSyntaxOn
      tl_new:N l_rn_auxOne_tl
      seq_new:N l_rn_auxOne_seq

      NewDocumentCommandmyScanTextm

      tl_set:Nn l_rn_auxOne_tl #1
      textbftl~variable:~tl_use:N l_rn_auxOne_tl\
      seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
      textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
      % myExperminent
      ExplSyntaxOff
      %-----------------------
      begindocument
      verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
      myScanTextThe quick brown fox jumps over the lazy dog.

      verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
      myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
      enddocument






      expl3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      Reinhard Neuwirth

      1,44511321




      1,44511321




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Use a slower routine first splitting at spaces.



          documentclassarticle
          usepackage[margin=1cm]geometry
          usepackagexparse

          ExplSyntaxOn
          tl_new:N l_rn_auxOne_tl
          tl_new:N l_rn_auxTwo_tl
          seq_new:N l_rn_auxOne_seq
          seq_new:N l_rn_auxTwo_seq

          NewDocumentCommandmyScanTextm

          tl_set:Nn l_rn_auxOne_tl #1
          seq_clear:N l_rn_auxOne_seq
          % split at spaces
          seq_set_split:Nnn l_rn_auxTwo_seq ~ #1
          % the first item is special, pop it out and split it
          seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
          tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
          % now do the other items, reinserting the space before them
          seq_map_inline:Nn l_rn_auxTwo_seq

          __rn_add:n ~
          tl_map_function:nN ##1 __rn_add:n

          % print the data
          textbftl~variable:~tl_use:N l_rn_auxOne_tl\
          textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

          cs_new_protected:Nn __rn_add:n

          seq_put_right:Nn l_rn_auxOne_seq #1

          ExplSyntaxOff
          %-----------------------
          begindocument

          setlengthparindent0pt % just for the example

          myScanTextThe quick brown fox jumps over the lazy dog.

          myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

          enddocument


          enter image description here



          Alternative method: first replace spaces with a private token and then split with tl_map_function:NN



          documentclassarticle
          usepackage[margin=1cm]geometry
          usepackagexparse

          ExplSyntaxOn
          tl_new:N l_rn_auxOne_tl
          seq_new:N l_rn_auxOne_seq

          NewDocumentCommandmyScanTextm

          seq_clear:N l_rn_auxOne_seq
          tl_set:Nn l_rn_auxOne_tl #1
          tl_replace_all:Nnn l_rn_auxOne_tl ~ __rn_space:
          tl_map_function:NN l_rn_auxOne_tl __rn_add:n
          % print the data
          textbfinput:~#1\
          textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

          cs_new_protected:Nn __rn_add:n

          tl_if_eq:nnTF #1 __rn_space:

          seq_put_right:Nn l_rn_auxOne_seq ~


          seq_put_right:Nn l_rn_auxOne_seq #1


          cs_new_protected:Nn __rn_space:
          ExplSyntaxOff
          %-----------------------
          begindocument

          setlengthparindent0pt % just for the example

          myScanTextThe quick brown fox jumps over the lazy dog.

          myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

          enddocument





          share|improve this answer





























            up vote
            2
            down vote













            You could use str_map_inline:Nn and append to the seq. The problem is that catcodes are all 12 then.



            documentclassarticle
            % RN. 11 Nov 2018
            %=======================
            usepackage[check-declarations,log-functions]expl3
            usepackagexparse
            %-----------------------
            ExplSyntaxOn
            tl_new:N l_rn_auxOne_tl
            seq_new:N l_rn_auxOne_seq

            NewDocumentCommandmyScanTextm

            tl_set:Nn l_rn_auxOne_tl #1
            textbftl~variable:~tl_use:N l_rn_auxOne_tl\
            seq_clear:N l_rn_auxOne_seq
            str_map_inline:Nn l_rn_auxOne_tl seq_put_right:Nn l_rn_auxOne_seq ##1
            textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
            % myExperminent
            ExplSyntaxOff
            %-----------------------
            begindocument
            verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
            myScanTextThe quick brown fox jumps over the lazy dog.

            verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
            myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
            enddocument


            enter image description here






            share|improve this answer



























              up vote
              1
              down vote













              You could pre-process the input using regex_replace_all:nnN to replace all spaces with space. (I first tried replacing spaces with ~ and ~ but this did not work so well.) Doing this your MWE produces:



              enter image description here



              Here is the code:



              documentclassarticle
              % RN. 11 Nov 2018
              %=======================
              usepackage[check-declarations,log-functions]expl3
              usepackagexparse
              %-----------------------
              ExplSyntaxOn
              tl_new:N l_rn_auxOne_tl
              seq_new:N l_rn_auxOne_seq

              NewDocumentCommandmyScanTextm

              tl_set:Nn l_rn_auxOne_tl #1
              regex_replace_all:nnN s+ cspace l_rn_auxOne_tl
              textbftl~variable:~tl_use:N l_rn_auxOne_tl\
              seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
              textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
              % myExperminent
              ExplSyntaxOff
              %-----------------------
              begindocument
              verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
              myScanTextThe quick brown fox jumps over the lazy dog.

              verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
              myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
              enddocument


              Note that this replaces repeated spaces with a single space, which I'm guessing is probably what you'd really want.






              share|improve this answer




















                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',
                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%2f459519%2fpreserving-spaces-when-scannig-tl-variables-into-a-sequence-using-seq-set-sp%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                2
                down vote



                accepted










                Use a slower routine first splitting at spaces.



                documentclassarticle
                usepackage[margin=1cm]geometry
                usepackagexparse

                ExplSyntaxOn
                tl_new:N l_rn_auxOne_tl
                tl_new:N l_rn_auxTwo_tl
                seq_new:N l_rn_auxOne_seq
                seq_new:N l_rn_auxTwo_seq

                NewDocumentCommandmyScanTextm

                tl_set:Nn l_rn_auxOne_tl #1
                seq_clear:N l_rn_auxOne_seq
                % split at spaces
                seq_set_split:Nnn l_rn_auxTwo_seq ~ #1
                % the first item is special, pop it out and split it
                seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
                tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
                % now do the other items, reinserting the space before them
                seq_map_inline:Nn l_rn_auxTwo_seq

                __rn_add:n ~
                tl_map_function:nN ##1 __rn_add:n

                % print the data
                textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                cs_new_protected:Nn __rn_add:n

                seq_put_right:Nn l_rn_auxOne_seq #1

                ExplSyntaxOff
                %-----------------------
                begindocument

                setlengthparindent0pt % just for the example

                myScanTextThe quick brown fox jumps over the lazy dog.

                myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                enddocument


                enter image description here



                Alternative method: first replace spaces with a private token and then split with tl_map_function:NN



                documentclassarticle
                usepackage[margin=1cm]geometry
                usepackagexparse

                ExplSyntaxOn
                tl_new:N l_rn_auxOne_tl
                seq_new:N l_rn_auxOne_seq

                NewDocumentCommandmyScanTextm

                seq_clear:N l_rn_auxOne_seq
                tl_set:Nn l_rn_auxOne_tl #1
                tl_replace_all:Nnn l_rn_auxOne_tl ~ __rn_space:
                tl_map_function:NN l_rn_auxOne_tl __rn_add:n
                % print the data
                textbfinput:~#1\
                textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                cs_new_protected:Nn __rn_add:n

                tl_if_eq:nnTF #1 __rn_space:

                seq_put_right:Nn l_rn_auxOne_seq ~


                seq_put_right:Nn l_rn_auxOne_seq #1


                cs_new_protected:Nn __rn_space:
                ExplSyntaxOff
                %-----------------------
                begindocument

                setlengthparindent0pt % just for the example

                myScanTextThe quick brown fox jumps over the lazy dog.

                myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                enddocument





                share|improve this answer


























                  up vote
                  2
                  down vote



                  accepted










                  Use a slower routine first splitting at spaces.



                  documentclassarticle
                  usepackage[margin=1cm]geometry
                  usepackagexparse

                  ExplSyntaxOn
                  tl_new:N l_rn_auxOne_tl
                  tl_new:N l_rn_auxTwo_tl
                  seq_new:N l_rn_auxOne_seq
                  seq_new:N l_rn_auxTwo_seq

                  NewDocumentCommandmyScanTextm

                  tl_set:Nn l_rn_auxOne_tl #1
                  seq_clear:N l_rn_auxOne_seq
                  % split at spaces
                  seq_set_split:Nnn l_rn_auxTwo_seq ~ #1
                  % the first item is special, pop it out and split it
                  seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
                  tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
                  % now do the other items, reinserting the space before them
                  seq_map_inline:Nn l_rn_auxTwo_seq

                  __rn_add:n ~
                  tl_map_function:nN ##1 __rn_add:n

                  % print the data
                  textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                  textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                  cs_new_protected:Nn __rn_add:n

                  seq_put_right:Nn l_rn_auxOne_seq #1

                  ExplSyntaxOff
                  %-----------------------
                  begindocument

                  setlengthparindent0pt % just for the example

                  myScanTextThe quick brown fox jumps over the lazy dog.

                  myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                  enddocument


                  enter image description here



                  Alternative method: first replace spaces with a private token and then split with tl_map_function:NN



                  documentclassarticle
                  usepackage[margin=1cm]geometry
                  usepackagexparse

                  ExplSyntaxOn
                  tl_new:N l_rn_auxOne_tl
                  seq_new:N l_rn_auxOne_seq

                  NewDocumentCommandmyScanTextm

                  seq_clear:N l_rn_auxOne_seq
                  tl_set:Nn l_rn_auxOne_tl #1
                  tl_replace_all:Nnn l_rn_auxOne_tl ~ __rn_space:
                  tl_map_function:NN l_rn_auxOne_tl __rn_add:n
                  % print the data
                  textbfinput:~#1\
                  textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                  cs_new_protected:Nn __rn_add:n

                  tl_if_eq:nnTF #1 __rn_space:

                  seq_put_right:Nn l_rn_auxOne_seq ~


                  seq_put_right:Nn l_rn_auxOne_seq #1


                  cs_new_protected:Nn __rn_space:
                  ExplSyntaxOff
                  %-----------------------
                  begindocument

                  setlengthparindent0pt % just for the example

                  myScanTextThe quick brown fox jumps over the lazy dog.

                  myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                  enddocument





                  share|improve this answer
























                    up vote
                    2
                    down vote



                    accepted







                    up vote
                    2
                    down vote



                    accepted






                    Use a slower routine first splitting at spaces.



                    documentclassarticle
                    usepackage[margin=1cm]geometry
                    usepackagexparse

                    ExplSyntaxOn
                    tl_new:N l_rn_auxOne_tl
                    tl_new:N l_rn_auxTwo_tl
                    seq_new:N l_rn_auxOne_seq
                    seq_new:N l_rn_auxTwo_seq

                    NewDocumentCommandmyScanTextm

                    tl_set:Nn l_rn_auxOne_tl #1
                    seq_clear:N l_rn_auxOne_seq
                    % split at spaces
                    seq_set_split:Nnn l_rn_auxTwo_seq ~ #1
                    % the first item is special, pop it out and split it
                    seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
                    tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
                    % now do the other items, reinserting the space before them
                    seq_map_inline:Nn l_rn_auxTwo_seq

                    __rn_add:n ~
                    tl_map_function:nN ##1 __rn_add:n

                    % print the data
                    textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                    cs_new_protected:Nn __rn_add:n

                    seq_put_right:Nn l_rn_auxOne_seq #1

                    ExplSyntaxOff
                    %-----------------------
                    begindocument

                    setlengthparindent0pt % just for the example

                    myScanTextThe quick brown fox jumps over the lazy dog.

                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                    enddocument


                    enter image description here



                    Alternative method: first replace spaces with a private token and then split with tl_map_function:NN



                    documentclassarticle
                    usepackage[margin=1cm]geometry
                    usepackagexparse

                    ExplSyntaxOn
                    tl_new:N l_rn_auxOne_tl
                    seq_new:N l_rn_auxOne_seq

                    NewDocumentCommandmyScanTextm

                    seq_clear:N l_rn_auxOne_seq
                    tl_set:Nn l_rn_auxOne_tl #1
                    tl_replace_all:Nnn l_rn_auxOne_tl ~ __rn_space:
                    tl_map_function:NN l_rn_auxOne_tl __rn_add:n
                    % print the data
                    textbfinput:~#1\
                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                    cs_new_protected:Nn __rn_add:n

                    tl_if_eq:nnTF #1 __rn_space:

                    seq_put_right:Nn l_rn_auxOne_seq ~


                    seq_put_right:Nn l_rn_auxOne_seq #1


                    cs_new_protected:Nn __rn_space:
                    ExplSyntaxOff
                    %-----------------------
                    begindocument

                    setlengthparindent0pt % just for the example

                    myScanTextThe quick brown fox jumps over the lazy dog.

                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                    enddocument





                    share|improve this answer














                    Use a slower routine first splitting at spaces.



                    documentclassarticle
                    usepackage[margin=1cm]geometry
                    usepackagexparse

                    ExplSyntaxOn
                    tl_new:N l_rn_auxOne_tl
                    tl_new:N l_rn_auxTwo_tl
                    seq_new:N l_rn_auxOne_seq
                    seq_new:N l_rn_auxTwo_seq

                    NewDocumentCommandmyScanTextm

                    tl_set:Nn l_rn_auxOne_tl #1
                    seq_clear:N l_rn_auxOne_seq
                    % split at spaces
                    seq_set_split:Nnn l_rn_auxTwo_seq ~ #1
                    % the first item is special, pop it out and split it
                    seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
                    tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
                    % now do the other items, reinserting the space before them
                    seq_map_inline:Nn l_rn_auxTwo_seq

                    __rn_add:n ~
                    tl_map_function:nN ##1 __rn_add:n

                    % print the data
                    textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                    cs_new_protected:Nn __rn_add:n

                    seq_put_right:Nn l_rn_auxOne_seq #1

                    ExplSyntaxOff
                    %-----------------------
                    begindocument

                    setlengthparindent0pt % just for the example

                    myScanTextThe quick brown fox jumps over the lazy dog.

                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                    enddocument


                    enter image description here



                    Alternative method: first replace spaces with a private token and then split with tl_map_function:NN



                    documentclassarticle
                    usepackage[margin=1cm]geometry
                    usepackagexparse

                    ExplSyntaxOn
                    tl_new:N l_rn_auxOne_tl
                    seq_new:N l_rn_auxOne_seq

                    NewDocumentCommandmyScanTextm

                    seq_clear:N l_rn_auxOne_seq
                    tl_set:Nn l_rn_auxOne_tl #1
                    tl_replace_all:Nnn l_rn_auxOne_tl ~ __rn_space:
                    tl_map_function:NN l_rn_auxOne_tl __rn_add:n
                    % print the data
                    textbfinput:~#1\
                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,

                    cs_new_protected:Nn __rn_add:n

                    tl_if_eq:nnTF #1 __rn_space:

                    seq_put_right:Nn l_rn_auxOne_seq ~


                    seq_put_right:Nn l_rn_auxOne_seq #1


                    cs_new_protected:Nn __rn_space:
                    ExplSyntaxOff
                    %-----------------------
                    begindocument

                    setlengthparindent0pt % just for the example

                    myScanTextThe quick brown fox jumps over the lazy dog.

                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.

                    enddocument






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 6 hours ago

























                    answered 7 hours ago









                    egreg

                    696k8518483111




                    696k8518483111




















                        up vote
                        2
                        down vote













                        You could use str_map_inline:Nn and append to the seq. The problem is that catcodes are all 12 then.



                        documentclassarticle
                        % RN. 11 Nov 2018
                        %=======================
                        usepackage[check-declarations,log-functions]expl3
                        usepackagexparse
                        %-----------------------
                        ExplSyntaxOn
                        tl_new:N l_rn_auxOne_tl
                        seq_new:N l_rn_auxOne_seq

                        NewDocumentCommandmyScanTextm

                        tl_set:Nn l_rn_auxOne_tl #1
                        textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                        seq_clear:N l_rn_auxOne_seq
                        str_map_inline:Nn l_rn_auxOne_tl seq_put_right:Nn l_rn_auxOne_seq ##1
                        textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                        % myExperminent
                        ExplSyntaxOff
                        %-----------------------
                        begindocument
                        verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                        myScanTextThe quick brown fox jumps over the lazy dog.

                        verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                        myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                        enddocument


                        enter image description here






                        share|improve this answer
























                          up vote
                          2
                          down vote













                          You could use str_map_inline:Nn and append to the seq. The problem is that catcodes are all 12 then.



                          documentclassarticle
                          % RN. 11 Nov 2018
                          %=======================
                          usepackage[check-declarations,log-functions]expl3
                          usepackagexparse
                          %-----------------------
                          ExplSyntaxOn
                          tl_new:N l_rn_auxOne_tl
                          seq_new:N l_rn_auxOne_seq

                          NewDocumentCommandmyScanTextm

                          tl_set:Nn l_rn_auxOne_tl #1
                          textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                          seq_clear:N l_rn_auxOne_seq
                          str_map_inline:Nn l_rn_auxOne_tl seq_put_right:Nn l_rn_auxOne_seq ##1
                          textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                          % myExperminent
                          ExplSyntaxOff
                          %-----------------------
                          begindocument
                          verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                          myScanTextThe quick brown fox jumps over the lazy dog.

                          verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                          myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                          enddocument


                          enter image description here






                          share|improve this answer






















                            up vote
                            2
                            down vote










                            up vote
                            2
                            down vote









                            You could use str_map_inline:Nn and append to the seq. The problem is that catcodes are all 12 then.



                            documentclassarticle
                            % RN. 11 Nov 2018
                            %=======================
                            usepackage[check-declarations,log-functions]expl3
                            usepackagexparse
                            %-----------------------
                            ExplSyntaxOn
                            tl_new:N l_rn_auxOne_tl
                            seq_new:N l_rn_auxOne_seq

                            NewDocumentCommandmyScanTextm

                            tl_set:Nn l_rn_auxOne_tl #1
                            textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                            seq_clear:N l_rn_auxOne_seq
                            str_map_inline:Nn l_rn_auxOne_tl seq_put_right:Nn l_rn_auxOne_seq ##1
                            textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                            % myExperminent
                            ExplSyntaxOff
                            %-----------------------
                            begindocument
                            verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                            myScanTextThe quick brown fox jumps over the lazy dog.

                            verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                            myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                            enddocument


                            enter image description here






                            share|improve this answer












                            You could use str_map_inline:Nn and append to the seq. The problem is that catcodes are all 12 then.



                            documentclassarticle
                            % RN. 11 Nov 2018
                            %=======================
                            usepackage[check-declarations,log-functions]expl3
                            usepackagexparse
                            %-----------------------
                            ExplSyntaxOn
                            tl_new:N l_rn_auxOne_tl
                            seq_new:N l_rn_auxOne_seq

                            NewDocumentCommandmyScanTextm

                            tl_set:Nn l_rn_auxOne_tl #1
                            textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                            seq_clear:N l_rn_auxOne_seq
                            str_map_inline:Nn l_rn_auxOne_tl seq_put_right:Nn l_rn_auxOne_seq ##1
                            textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                            % myExperminent
                            ExplSyntaxOff
                            %-----------------------
                            begindocument
                            verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                            myScanTextThe quick brown fox jumps over the lazy dog.

                            verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                            myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                            enddocument


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 7 hours ago









                            Henri Menke

                            66.5k7147255




                            66.5k7147255




















                                up vote
                                1
                                down vote













                                You could pre-process the input using regex_replace_all:nnN to replace all spaces with space. (I first tried replacing spaces with ~ and ~ but this did not work so well.) Doing this your MWE produces:



                                enter image description here



                                Here is the code:



                                documentclassarticle
                                % RN. 11 Nov 2018
                                %=======================
                                usepackage[check-declarations,log-functions]expl3
                                usepackagexparse
                                %-----------------------
                                ExplSyntaxOn
                                tl_new:N l_rn_auxOne_tl
                                seq_new:N l_rn_auxOne_seq

                                NewDocumentCommandmyScanTextm

                                tl_set:Nn l_rn_auxOne_tl #1
                                regex_replace_all:nnN s+ cspace l_rn_auxOne_tl
                                textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                                seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
                                textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                                % myExperminent
                                ExplSyntaxOff
                                %-----------------------
                                begindocument
                                verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                                myScanTextThe quick brown fox jumps over the lazy dog.

                                verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                                myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                                enddocument


                                Note that this replaces repeated spaces with a single space, which I'm guessing is probably what you'd really want.






                                share|improve this answer
























                                  up vote
                                  1
                                  down vote













                                  You could pre-process the input using regex_replace_all:nnN to replace all spaces with space. (I first tried replacing spaces with ~ and ~ but this did not work so well.) Doing this your MWE produces:



                                  enter image description here



                                  Here is the code:



                                  documentclassarticle
                                  % RN. 11 Nov 2018
                                  %=======================
                                  usepackage[check-declarations,log-functions]expl3
                                  usepackagexparse
                                  %-----------------------
                                  ExplSyntaxOn
                                  tl_new:N l_rn_auxOne_tl
                                  seq_new:N l_rn_auxOne_seq

                                  NewDocumentCommandmyScanTextm

                                  tl_set:Nn l_rn_auxOne_tl #1
                                  regex_replace_all:nnN s+ cspace l_rn_auxOne_tl
                                  textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                                  seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
                                  textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                                  % myExperminent
                                  ExplSyntaxOff
                                  %-----------------------
                                  begindocument
                                  verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                                  myScanTextThe quick brown fox jumps over the lazy dog.

                                  verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                                  myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                                  enddocument


                                  Note that this replaces repeated spaces with a single space, which I'm guessing is probably what you'd really want.






                                  share|improve this answer






















                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    You could pre-process the input using regex_replace_all:nnN to replace all spaces with space. (I first tried replacing spaces with ~ and ~ but this did not work so well.) Doing this your MWE produces:



                                    enter image description here



                                    Here is the code:



                                    documentclassarticle
                                    % RN. 11 Nov 2018
                                    %=======================
                                    usepackage[check-declarations,log-functions]expl3
                                    usepackagexparse
                                    %-----------------------
                                    ExplSyntaxOn
                                    tl_new:N l_rn_auxOne_tl
                                    seq_new:N l_rn_auxOne_seq

                                    NewDocumentCommandmyScanTextm

                                    tl_set:Nn l_rn_auxOne_tl #1
                                    regex_replace_all:nnN s+ cspace l_rn_auxOne_tl
                                    textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                                    seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
                                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                                    % myExperminent
                                    ExplSyntaxOff
                                    %-----------------------
                                    begindocument
                                    verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                                    myScanTextThe quick brown fox jumps over the lazy dog.

                                    verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                                    enddocument


                                    Note that this replaces repeated spaces with a single space, which I'm guessing is probably what you'd really want.






                                    share|improve this answer












                                    You could pre-process the input using regex_replace_all:nnN to replace all spaces with space. (I first tried replacing spaces with ~ and ~ but this did not work so well.) Doing this your MWE produces:



                                    enter image description here



                                    Here is the code:



                                    documentclassarticle
                                    % RN. 11 Nov 2018
                                    %=======================
                                    usepackage[check-declarations,log-functions]expl3
                                    usepackagexparse
                                    %-----------------------
                                    ExplSyntaxOn
                                    tl_new:N l_rn_auxOne_tl
                                    seq_new:N l_rn_auxOne_seq

                                    NewDocumentCommandmyScanTextm

                                    tl_set:Nn l_rn_auxOne_tl #1
                                    regex_replace_all:nnN s+ cspace l_rn_auxOne_tl
                                    textbftl~variable:~tl_use:N l_rn_auxOne_tl\
                                    seq_set_split:NnV l_rn_auxOne_seq l_rn_auxOne_tl
                                    textbfseq~variable:~seq_use:Nn l_rn_auxOne_seq ,\
                                    % myExperminent
                                    ExplSyntaxOff
                                    %-----------------------
                                    begindocument
                                    verb+myScanTextThe quick brown fox jumps over the lazy dog.+\
                                    myScanTextThe quick brown fox jumps over the lazy dog.

                                    verb+myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.+\
                                    myScanTextThe~quick~brown~fox~jumps~over~the~lazy~dog.
                                    enddocument


                                    Note that this replaces repeated spaces with a single space, which I'm guessing is probably what you'd really want.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 7 hours ago









                                    Andrew

                                    28.9k34177




                                    28.9k34177



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459519%2fpreserving-spaces-when-scannig-tl-variables-into-a-sequence-using-seq-set-sp%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Displaying single band from multi-band raster using QGIS

                                        How many registers does an x86_64 CPU actually have?