Parse experiments: help needed
[1/8] 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?!?
[2/8] from: robert:muench:robertmuench at: 27-Nov-2001 18:36
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 4>>
> Subject: [REBOL] Parse experiments: help needed
> Has someone any suggestion to handle this?
Hi, yes I had the same problem while developing make-doc-pro. It took me some
time ;-) but here is the rule of thumb:
The trick is to parse your string the following way, while reducing the valid
character set by your special chars:
chars: complement charset "_*%"
rules: copy text some chars [
*
<this is your bold rule>
| "_" <this is your underline rule>
| "%" <this is your italic rule>
]
You got the idea?
--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax : +49 (0)721 8408 9112
Web : http://www.robertmuench.de
[3/8] from: greggirwin:mindspring at: 27-Nov-2001 11:13
Hi Mario,
<< 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 think the best method is to use parsing rules rather than just string
spliiting. I think Andrew Martin's eText does just what you want.
<< PS Is the RebMail team still alive?!? >>
I think all the members are still alive :), but the "team" has been silent
for lo these two months.
--Gregg
[4/8] from: ammonjohnson:ya:hoo at: 27-Nov-2001 16:11
Hi,
> Zaijian
> Mario
>
> PS Is the RebMail team still alive?!?
Like Gregg said, we are still living, but I am sure what you meant was, is
there still the drive to finish the product. I seemed to be the big
pressure behind it to start with, although I was far from all of the brains.
I have been very busy trying to get RIDE out of the door, & only able to
work half days on that so I haven't been able to work on RebMail recently.
RIDE will be going into Private Beta with a select few developers,
hopefully before the end of the week, & certainly within the next two weeks.
Once RIDE is on the market as Version 1 I will devote some more time to
RebMail...
HTH
Ammon
[5/8] from: ddalley:idirect at: 27-Nov-2001 17:57
Hello, Mario:
You might want to add "/" surrounded text as italic markers, too.
One of my mailers uses that method.
Donald
----- Original Message -----
From: "Cassani Mario" <[Mario--Cassani--icl--com]>
To: "REBOL List (E-mail)" <[rebol-list--rebol--com]>
Cc: "Rebmail (E-mail)" <[rebmail--yahoogroups--com]>
[6/8] from: mario:cassani:icl at: 28-Nov-2001 9:04
Hallo Robert, Donald, Ryan, Gregg, Ammon, and, why not, all the Rebolers out
there,
> You might want to add "/" surrounded text as italic markers, too.
> One of my mailers uses that method.
>
> Donald
If is not Amiga YAM but a PC program can you tell me its
name, please?
I will do that later, actually the #"/" is used in URLs:
http://dont.italicise.me/
> The trick is to parse your string the following way, while
> reducing the valid
<<quoted lines omitted: 6>>
> ]
> You got the idea?
Yes, thanks!
>> sample: {This string contains *bold text* and is a sample}
== "This string contains *bold text* and is a sample"
>>
>> chars: complement charset "_*%"
== make bitset! #{
FFFFFFFFDFFBFFFFFFFFFF7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
}
>>
>> rules: [copy text some chars [
[ "*" (print "bold!")
[ | "_" (print "underline!")
[ | "%" (print "italic!")
[ ]]
== [copy text some chars [
"*" (print "bold!")
| "_" (print "underline!")
| "%" (print "italic!")
]]
>>
>> parse sample rules
bold!
== false
>> text
== "This string contains "
>>
Now extracting the rest will be easier!
Xie xie nimen
Mario
[7/8] from: ddalley:idirect at: 28-Nov-2001 23:16
Hi, Mario:
Yes, I was thinking of YAM.
If the URL doesn't start with a "/", it doesn't seem to be much of an
exception, though.
Donald
[8/8] from: mario:cassani:icl at: 30-Nov-2001 8:42
Hallo Donald,
> Yes, I was thinking of YAM.
> If the URL doesn't start with a "/", it doesn't seem to be much of an
> exception, though.
right this morning, driving to the office I was thinking about your
last mail and a "trick" that, thinking deeper, looks like the only way
to prevent bugs and undesired colourisation.
I must track " *", " /", " _" *not* followed by spaces up to the
ending "* ", "/ ", "_ " *not* preceded by spaces.
This will allow to use * and / to write math formulas and _ to be
used_in_names.
Thank you
Mario
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted