On 07/31/2018 12:28 PM, Marc Chantreux wrote:
hello people,

given the slides of my talk in the slides.vim format
(https://github.com/eiro/slides.vim), i want some of
them to be shown one bullet a slide. so when i have
this input:

     › Renater et le libre

          Sympa
          FileSender

the desired output is:

     › Renater et le libre

          Sympa
     › Renater et le libre

          FileSender

and it seems gather is the perfect solution for that so i started to
write it (any golfer magic or other feedback warmly welcome):

@*ARGS.map: {
     gather {
         my @lines;
         for .IO.lines -> $l {
            if /'›'/ {
                @lines and take @lines;
                @lines = $l;
            }
            else {
                @lines.push($l);
                take @lines if /''/;
            }
         }
     }
}

this doesn't work as it seems that '›' and '' aren't matched.
i tried both

     for .IO.lines -> $l {

     # following https://docs.perl6.org/routine/lines#class_IO::Path
     for .IO.lines(enc => 'utf8') -> $l {

but none of them worked and i run out of idea to know what's going on.

any idea or documentation point for me ?
regards

marc



Hi Marc,

This probably will not help. but what the heck!

I do a lot of string manipulations on html files I down load
from the Internet.  They often end in what I call "weird
characters".

This table is helpful:
   https://www.ascii-code.com/

Here are some of the things I do:

   if / \> /            Note that I am escaping the ">" with "\"
   if / char(62) /      62 is ">"

if their are weird characters are at the end of the string and
I know what the string is suppose to end in, I will do
a sub with "greedy" (".*") to suck up all the weird stuff
at the end and replace it with what I want.

    $x="abc-1234.exe<weird stuff>";
    $x ~~ s/ \.exe .* /.exe/;

Note that in the first part of the sub, I can space
things out, but in the second part, it is literal.
If you use a space, it becomes part of the substitution.
I use spaces in the first part as it helps get me
around run together confusions.

You can also use greedy to whack the weird stuff off the
beginning too:

    $x="<weird stuff>abc-1234.exe";
    $x ~~ s/ .* "abc" /abc/;

I hope this helps, if only somewhat.

-T

Reply via email to