Skip to content

Commit 640f916

Browse files
committed
FEAT: including R2's version of the build-tag function
(but not enabled by default in boot-files) Related to: Oldes/Rebol-issues#370
1 parent 09e1c78 commit 640f916

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/mezz/boot-files.r

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ REBOL [
4949
%mezz-colors.r
5050
%mezz-crypt.r
5151
%mezz-date.r ; Internet date support
52+
;%mezz-tag.r ; build-tag
5253
%mezz-tail.r
5354
%codec-json.r
5455
%codec-unixtime.r

src/mezz/mezz-tag.r

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
REBOL [
2+
System: "REBOL [R3] Language Interpreter and Run-time Environment"
3+
Title: "REBOL 3 Mezzanine: Tag"
4+
Rights: {
5+
Copyright 2012 REBOL Technologies
6+
REBOL is a trademark of REBOL Technologies
7+
}
8+
License: {
9+
Licensed under the Apache License, Version 2.0
10+
See: http://www.apache.org/licenses/LICENSE-2.0
11+
}
12+
]
13+
14+
build-tag: func [
15+
"Generates a tag from a composed block."
16+
values [block!] "Block of parens to evaluate and other data."
17+
/local tag value-rule xml? name attribute value
18+
][ ;@@ slightly modified version from Rebol2
19+
tag: make string! 7 * length? values
20+
value-rule: [
21+
set value issue! (value: mold value)
22+
| set value file! (value: replace/all copy value #" " "%20")
23+
| set value any-type! (value: replace/all form value #"'" {\'})
24+
]
25+
xml?: false
26+
parse compose values [
27+
[
28+
set name ['?xml (xml?: true) | word! | url!] (append tag name)
29+
any [
30+
set attribute [word! | url!] value-rule (
31+
append tag ajoin [#" " attribute {='} value #"'"]
32+
)
33+
| value-rule (append tag join #" " value)
34+
]
35+
end (if xml? [append tag #"?"])
36+
]
37+
|
38+
[set name refinement! to end (tag: mold name)]
39+
]
40+
to tag! tag
41+
]

0 commit comments

Comments
 (0)