Skip to content

Commit

Permalink
FEAT: including R2's version of the build-tag function
Browse files Browse the repository at this point in the history
(but not enabled by default in boot-files)

Related to: Oldes/Rebol-issues#370
  • Loading branch information
Oldes committed May 19, 2020
1 parent 09e1c78 commit 640f916
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mezz/boot-files.r
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ REBOL [
%mezz-colors.r
%mezz-crypt.r
%mezz-date.r ; Internet date support
;%mezz-tag.r ; build-tag
%mezz-tail.r
%codec-json.r
%codec-unixtime.r
Expand Down
41 changes: 41 additions & 0 deletions src/mezz/mezz-tag.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
REBOL [
System: "REBOL [R3] Language Interpreter and Run-time Environment"
Title: "REBOL 3 Mezzanine: Tag"
Rights: {
Copyright 2012 REBOL Technologies
REBOL is a trademark of REBOL Technologies
}
License: {
Licensed under the Apache License, Version 2.0
See: http://www.apache.org/licenses/LICENSE-2.0
}
]

build-tag: func [
"Generates a tag from a composed block."
values [block!] "Block of parens to evaluate and other data."
/local tag value-rule xml? name attribute value
][ ;@@ slightly modified version from Rebol2
tag: make string! 7 * length? values
value-rule: [
set value issue! (value: mold value)
| set value file! (value: replace/all copy value #" " "%20")
| set value any-type! (value: replace/all form value #"'" {\'})
]
xml?: false
parse compose values [
[
set name ['?xml (xml?: true) | word! | url!] (append tag name)
any [
set attribute [word! | url!] value-rule (
append tag ajoin [#" " attribute {='} value #"'"]
)
| value-rule (append tag join #" " value)
]
end (if xml? [append tag #"?"])
]
|
[set name refinement! to end (tag: mold name)]
]
to tag! tag
]

0 comments on commit 640f916

Please sign in to comment.