[REBOL] Re: Tags, anyone?
From: chalz:earthlink at: 15-Apr-2002 23:30
> Also note that because tag is a series it is easy to get caught with
> rejoin when forming a string from tags:
>
> >> rejoin [<test> "color"]
> == <testcolor>
Actually, when you think about it for a second, that's very obvious and
logical behavior. (Works same with join.) It's taking the second argument and
basically adding it to the first, transmuting it to a matching datatype. So if
you did:
>> join "color" <test>
It casts the second arg into the type of the first - so <test> becomes
<test>
and they're joined together.
> So my habit is to use join where the first argument dictates the
> datatype of my result:
>
> >> join {} [<test> "color" </test>]
> == "<test>color</test>"
There's always form:
>> form [<tag> "color" </tag>]
== "<tag> color </tag>"
Of course, since this is REBOL, there are at least 5 simple ways to do it,
and 50 more complicated ways.
> Ages ago I wrote some stuff to play with markup and change tags
> into blocks using load/markup and the fact that tags are series:
>
> http://www.codeconscious.com/rebsite/rebol-library/tag-tool.r
> http://www.codeconscious.com/rebsite/rebol-library/markup-tools.r
Cool.
> There is also form-markup which converts this representation back into a
> string:
>
> >> form-markup [ [p] "paragraph 1" [p] "paragraph2" ]
> == "<p>paragraph 1<p>paragraph2"
Quick question: Why? You could just as easily work with <p> instead, since
it's valid.
> I did this to give a basic markup manipulation facility:
>
> m: load-markup {<body bgcolor="white">some <b>text</b></body>}
> change next find first m 'bgcolor "blue"
> form-markup m
You could also use your import-tag and build-tag for the same purposes, if I
follow correctly.
And how would load-markup display the value of m there?
I'm not critiquing so much as asking for verifications and exaplanations.
Thanks for the work, Brett!
--Charles