[REBOL] Parse experiments: help needed
From: mario:cassani:icl at: 27-Nov-2001 14:25
Hallo all,
I am (still) experimenting how to colourise email
texts using Cyphre's color-text.r style.
The script already colourise in a slrn-like style
the messages I receive but something is still missing.
What I need now is to make bold the strings
delimited with #"*", underline the ones with #"_" and
italicise the #"%" surrounded ones, nested effects
and new lines should be handled too.
I can simply "extract" the pieces of text but I
have no idea on how to use parse on them (for this
necessity). Let's the samples speak:
>> sample3: {This is a %long *bolded in the middle* string% for sample}
== {This is a %long *bolded in the middle* string% for sample}
>> parse/all sample3 {%}
== ["This is a " "long *bolded in the middle* string" " for sample"]
>> parse/all sample3 {*}
== ["This is a %long " "bolded in the middle" " string% for sample"]
>> parse/all sample3 {*%}
== ["This is a " "long " "bolded in the middle" " string" " for sample"]
>>
>> sample4: {This is a _long *bolded in* its *own middle* string_ for
sample}
== {This is a _long *bolded in* its *own middle* string_ for sample}
>> parse/all sample4 {_}
== ["This is a " "long *bolded in* its *own middle* string" " for sample"]
>> parse/all sample4 {*}
== ["This is a _long " "bolded in" " its " "own middle" " string_ for
sample"]
>> parse/all sample4 {*_}
== ["This is a " "long " "bolded in" " its " "own middle" " string" " for
sample"]
>>
As you can see I can split the string to be handled
but:
1) If I want to do a single parse pass the obtained series
doesn't make the #"*" splitted substrings distinguishable
from the #"%" ones (sample3 and sample4)
2) Even if I accept the overhead of using multiple passes
if the same effect is used more than once I cannot know
which ones were the "effected" substrings
The format used for color-text style is something like:
[color1 "string using that color" color2 "guess what" eol
color3 "this *can be bold* or _underlined_" eol]
Has someone any suggestion to handle this?
Zaijian
Mario
PS Is the RebMail team still alive?!?