[REBOL] Recursive parsing (WAS: colored text)
From: mario::cassani::icl::com at: 21-Nov-2001 15:28
Hi all,
a reply/answer to my question follows in order to help people
with the same problems with an easy to search subject.
> > The color-text VID style uses very simple dialect like:
> >
> > view layout [
> > color-text ["Hello" red "World" eol bold blue "This is"
> > normal yellow
> > "next" italic "line."] wrap
> > ]
>
> could you (or someone listening and interested) please help
> me writing a short example showing how to colorise the below
> example only (at the bottom)?
>
[...]
> ; *** Botton example is this ***
> ;
> ; > > Something has color2
> ; > Something has color1
> ; Something has standard color
> ;
> either parse mail-string ["> > > " copy unquoted-string to end] [
> colored-string: [red "> > > " orange unquoted-string]
> ] [
> either parse mail-string ["> > " copy unquoted-string to end] [
> colored-string: [blue "> > " cyan unquoted-string]
> ] [
> either parse mail-string ["> " copy unquoted-string to end] [
> colored-string: [brown "> " yellow unquoted-string]
> ] [
> colored-string: [mail-string]
> ]
> ]
> ]
the solution is (word wrap will kill it, I know):
>> levels: 0
== 0
>> original-text: ">> > >Questa e' una linea di prova http://www.rebol.com
scrivi a [carl--rebol--com] e pure a me"
>> parse original-text [any [["> " | #">"] (levels: levels + 1)] copy
clean-text to end]
== true
>> clean-text
== {Questa e' una linea di prova http://www.rebol.com scrivi a
[carl--rebol--com] e pure a me}
>> levels
== 4
using levels I can select a colour in a 'serie for the original text...
Now I miss an 'url! and 'email! "catcher". I remember a /view script
showing
underlined and browseable URLs in a text file. Can someone tell me the
example's
URL (I am behind a proxy that prevents REBOL to see the World Wide Reb)?
Thanks again
Mario