Loading ...
Sorry, an error occurred while loading the content.

Re: [NH] Re: clip to html code text list?

Expand Messages
  • Alec Burgess
    Alan: I couldn t figure out what the chomp was doing in your script. When I ... chomp function Remove a trailing record separator from a string chomp
    Message 1 of 11 , Dec 6, 2002
    • 0 Attachment
      Alan:

      I couldn't figure out what the "chomp" was doing in your script. When I
      looked for "perl chomp" with Google I found:
      ---
      chomp function
      Remove a trailing record separator from a string
      chomp VARIABLE
      chomp LIST
      chomp
      ---
      Do you just include the "chomp ($_);" as a safety measure always, or
      have you discovered that things dont work correctly without it?

      Regards ... Alec
      --

      ---- Original Message ----
      From: "Alan B Cummings" <acumming@...>
      To: <ntb-html@yahoogroups.com>
      Sent: Fri, 06-Dec-2002 22:11
      Subject: [NH] Re: clip to html code text list?

      > Hello,
      >
      > Perl script for the task if anyone interested. ez to do line(s).
      > Perl needed in order to work.
      >
      > H="pl_txt2htm"
      > ^!RunPerl pl_tx2htm
      >
      > H="_pl_tx2htm"
      > #!/perl/bin/perl -w
      > print "<ul>\n";
      > while (<>) {
      > chomp ($_);
      > print "<li>$_</li>\n";
      > }
      > print '</ul>';
      > # end
    • Alan C.
      Hello Alec, ... Of your two lines above, (in a formatting way) it has to do with the latter/2nd of the two. It s not always needed or included. chomp It s
      Message 2 of 11 , Dec 7, 2002
      • 0 Attachment
        Hello Alec,

        >Do you just include the "chomp ($_);" as a safety measure always, or
        >have you discovered that things dont work correctly without it?

        Of your two lines above, (in a formatting way) it has to do with the latter/2nd of the two. It's not always needed or included.

        chomp It's nothing more than a simple function that removes the \n (new line or line break character), removes such character from end of string.

        Since the clip/script does each line, one at a time which in this case means that the end of string happens also to be end of line. (a perl pesky unless it's good :-) thing is when doing each line it carries with it the line break character at the end of the line.

        So, the chomp function in that line of code removes the string's line break character--then in the very next line, the print line, the line break is added back in again (\n) --> added back in AFTER or to the right of the newly included </li>

        No harm in running it without the chomp line--you'll see the difference in how the html comes out. While NTB uses a ; to deactivate a line--Perl uses a # to do the same thing.

        Try like next (note the # must be at beginning of chomp line--also remove the \n from the print line---you'll see the difference and see that indeed perl does take the line break character as the end of the string as well as print or output same)

        original clip had pertinent 2 lines like this

        chomp ($_);
        print "<li>$_</li>\n";

        but in clip below you can try same 2 lines altered like this

        # chomp ($_);
        print "<li>$_</li>";

        #!/perl/bin/perl -w
        print "<ul>\n";
        while (<>) {
        # chomp ($_);
        print "<li>$_</li>";
        }
        print '</ul>';
        # end

        --
        Alan.
      • Jim Shepard
        I love your answer but what was the question Jim Shepard ... From: Alan B Cummings To: Sent: Friday, December
        Message 3 of 11 , Dec 7, 2002
        • 0 Attachment
          I love your answer but what was the question
          Jim Shepard
          ----- Original Message -----
          From: "Alan B Cummings" <acumming@...>
          To: <ntb-html@yahoogroups.com>
          Sent: Friday, December 06, 2002 9:11 PM
          Subject: [NH] Re: clip to html code text list?


          >
          > Hello,
          >
          > Perl script for the task if anyone interested. ez to do line(s). Perl
          needed in order to work.
          >
          > H="pl_txt2htm"
          > ^!RunPerl pl_tx2htm
          >
          > H="_pl_tx2htm"
          > #!/perl/bin/perl -w
          > print "<ul>\n";
          > while (<>) {
          > chomp ($_);
          > print "<li>$_</li>\n";
          > }
          > print '</ul>';
          > # end
          >
          > --
          > Alan C.
          >
          >
          >
          >
          >
          >
          >
          > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          >
          >
        • Alan C.
          Hi Jim, ... Someone did seek a clip to convert a text list of items into an html unorderd list. (included an updated, more featured RunPerl NTB/Perl script
          Message 4 of 11 , Dec 7, 2002
          • 0 Attachment
            Hi Jim,

            >what was the question

            Someone did seek a clip to convert a text list of items into an html unorderd list.

            (included an updated, more featured RunPerl NTB/Perl script below) (for scripts, perl, etc., there's a NTB-scripts email list I been trying to drum up just a bit of business for that list it's at ntb-scripts@yahoogroups.com) maybe the next subscribes but I don't know for sure

            ntb-scripts-subscribe@yahoogroups.com

            As to what was originally sought, that mentioned text list could have either leading * or leading spaces

            * List Item 1
            List Item 2
            example list items end at item 2 above

            The individual wanted either of those two leading items stripped then the list items put into an html unordered list.

            Actually I formerly forgot to accomodate for either of those two leading characters. But the updated two runperl NTB clips below handles those and more; it can also handle when there are no characters preceding a list item.

            2 clips follow. Perl needed in order to work.

            H="pl_txt2htm"
            ^!RunPerl pl_tx2htm

            H="_pl_tx2htm"
            #!/perl/bin/perl -w
            # a text list gets coded into an html unordered list
            # Works entire doc if nothing is selected
            # Or, works just your selection if text is selected
            print "<ul>\n"; # the html start tag
            while (<>) { # ea line. Ends when no more lines
            chomp ; # remove trailing line break char.
            s/^\*//; # remove leading *
            s/^ *//; # remove leading space(s)
            print "<li>$_</li>\n"; # ea list item's tags
            } # end of the while block
            print '</ul>'; # the html closing tag
            # end

            --
            Alan.
          • Jim Shepard
            Thanks Jim Shepard ... From: Alan C. To: Sent: Saturday, December 07, 2002 10:32 PM Subject: Re: [NH] Re:
            Message 5 of 11 , Dec 7, 2002
            • 0 Attachment
              Thanks
              Jim Shepard
              ----- Original Message -----
              From: "Alan C." <acumming@...>
              To: <ntb-html@yahoogroups.com>
              Sent: Saturday, December 07, 2002 10:32 PM
              Subject: Re: [NH] Re: clip to html code text list?


              > Hi Jim,
              >
              > >what was the question
              >
              > Someone did seek a clip to convert a text list of items into an html
              unorderd list.
              >
              > (included an updated, more featured RunPerl NTB/Perl script below) (for
              scripts, perl, etc., there's a NTB-scripts email list I been trying to drum
              up just a bit of business for that list it's at ntb-scripts@yahoogroups.com)
              maybe the next subscribes but I don't know for sure
              >
              > ntb-scripts-subscribe@yahoogroups.com
              >
              > As to what was originally sought, that mentioned text list could have
              either leading * or leading spaces
              >
              > * List Item 1
              > List Item 2
              > example list items end at item 2 above
              >
              > The individual wanted either of those two leading items stripped then the
              list items put into an html unordered list.
              >
              > Actually I formerly forgot to accomodate for either of those two leading
              characters. But the updated two runperl NTB clips below handles those and
              more; it can also handle when there are no characters preceding a list item.
              >
              > 2 clips follow. Perl needed in order to work.
              >
              > H="pl_txt2htm"
              > ^!RunPerl pl_tx2htm
              >
              > H="_pl_tx2htm"
              > #!/perl/bin/perl -w
              > # a text list gets coded into an html unordered list
              > # Works entire doc if nothing is selected
              > # Or, works just your selection if text is selected
              > print "<ul>\n"; # the html start tag
              > while (<>) { # ea line. Ends when no more lines
              > chomp ; # remove trailing line break char.
              > s/^\*//; # remove leading *
              > s/^ *//; # remove leading space(s)
              > print "<li>$_</li>\n"; # ea list item's tags
              > } # end of the while block
              > print '</ul>'; # the html closing tag
              > # end
              >
              > --
              > Alan.
              >
              >
              >
              >
              >
              >
              > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              >
              >
            • Wright, John - Textron Financial
              Nice, but it seems to lop off the firt character of each item. ... From: Alec Burgess [mailto:burale@aci.on.ca] Sent: Friday, December 06, 2002 4:32 PM To:
              Message 6 of 11 , Dec 9, 2002
              • 0 Attachment
                Nice, but it seems to lop off the firt character of each item.

                -----Original Message-----
                From: Alec Burgess [mailto:burale@...]
                Sent: Friday, December 06, 2002 4:32 PM
                To: ntb-html@yahoogroups.com
                Subject: Re: [NH] Re: clip to html code text list?


                Hugo:
                Brilliant! All of sudden a light-bulb went on over my head ;-)

                With this as a template, a lot of tasks I've labored over from time to
                time become so obvious!
                I'm sure I've seen countless examples of this method, in various clips
                in the clip-list, that I've eyeballed without ever looking at them
                closely enough. _*I was blind and now I see*_

                Regards ... Alec
                --

                On Fri, 06-Dec-2002 03:48 [GMT+500 EST],
                h.paulissen@... <h.paulissen@...>
                wrote:

                > John, Jonathon,
                >
                > I felt the same way too, John... Here is a regular epression that
                > works on a list (select it first)...
                >
                > ^!Replace "^[^<][\s\*]*{.*}" >> "<li>\1</li>" CAIHRS
                > <ul>
                > ^$GetSelection$
                > </ul>
                >
                >
                > Hugo
                >
                >
                >>
                >> I had to chuckle at your "I'm lazy" comment Jonathon.. :)
                >>
                >
                > ------------------------ Yahoo! Groups Sponsor
                > ---------------------~--> Get 128 Bit SSL Encryption!
                > http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/CefplB/TM
                > ---------------------------------------------------------------------~
                ->
                >
                >
                >
                > Your use of Yahoo! Groups is subject to
                > http://docs.yahoo.com/info/terms/





                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              • h.paulissen@facburfdcw.unimaas.nl
                It was intended to strip off a space and/or a * in front of a listitem... It did the trick, and I didn t really test it on another pattern, but you re right...
                Message 7 of 11 , Dec 9, 2002
                • 0 Attachment
                  It was intended to strip off a space and/or a * in front of a listitem... It
                  did the trick, and I didn't really test it on another pattern, but you're
                  right... it strips off other characters as well.

                  I don't have the time to investigate it, but if your lists start without
                  such a charachter (space/*) this might be sufficient...

                  ^!Replace "^{.*}" >> "<li>\1</li>" CAIHRS

                  Hugo



                  > -----Original Message-----
                  > From: Wright, John - Textron Financial
                  > [mailto:JWright@...]
                  > Sent: Monday, December 09, 2002 2:49 PM
                  > To: 'ntb-html@yahoogroups.com'
                  > Subject: RE: [NH] Re: clip to html code text list?
                  >
                  >
                  > Nice, but it seems to lop off the firt character of each item.
                  >
                  > -----Original Message-----
                  > From: Alec Burgess [mailto:burale@...]
                • Alan C.
                  Hello, Topic: clip that converts a text list of items into an html unorderd list. (wraps a text list with the desired html tags) ... Worked fine on my machine.
                  Message 8 of 11 , Dec 9, 2002
                  • 0 Attachment
                    Hello,

                    Topic: clip that converts a text list of items into an html unorderd list. (wraps a text list with the desired html tags)

                    >if your lists start without
                    >such a charachter (space/*) this might be sufficient...
                    >
                    >^!Replace "^{.*}" >> "<li>\1</li>" CAIHRS

                    Worked fine on my machine.

                    Here's a NTB clip can accommodate either if the list item(s) has or does not have leading space or *

                    ^!Replace "^[\*\s|\s]*" >> "" CAIHRS
                    ^!Replace "^{.*}" >> "<li>\1</li>" CAIHRS
                    <ul>
                    ^$GetSelection$
                    </ul>

                    Note the character class above (square brackets) since Notetab wouldn't alternate with the * quantifier (until I put/added the square brackets in, made it a character class)

                    (I discovered a difference between NoteTab and Perl: Perl will alternate with the * quantifier as below; Notetab must use a character class in order to do the same.
                    For any user of my perl script-- the two lines:

                    s/^\*//; # remove leading *
                    s/^ *//; # remove leading space(s)

                    I updated it, made/replaced both of those lines with just one line:

                    s/^\* *|^ *//; # trim leading * and space

                    --
                    Alan.
                  Your message has been successfully submitted and would be delivered to recipients shortly.