"
replace/all markup {"pre"} ""
replace/all markup "" ""
replace/all markup "< >" " "
editor/text: markup show editor
document: layout/offset/size xmlview 0x0 550x10000
page/pane: document show page
page/color: mnb show page
pagetitle: getnodename "title"
either find histobj pagetitle [][
append histobj pagetitle
append histobj reduce [to-block xmlview]
replace/all histobj false []
replace/all histobj [[]] []
]
clear xmlview
]
tbar: [backdrop silver space 3 pad -15x-20 text "New" [] text "Open" [] text "Save" [] pad -19x-1 space 0
box 115x1 gray pad 0x0
box 115x1 white space 0 below across pad -14x2
text "Properties" []
below
history: text ""
pad -19x10 space 0
box 115x1 gray pad 0x0
box 115x1 white space 0 below across pad -14x2
text "Exit" []] 100x150 35x85
goedit: layout/size/offset tbar 100x150 90x85
goview: layout/size/offset tbar 100x150 125x85
goinsert: layout/size/offset tbar 100x169 165x85
gopreview: layout/size/offset tbar 100x150 216x85
goHelp: layout/size/offset tbar 100x150 277x85
document: []
vide: layout [at 0x0 ID: bck: backdrop gold
across
ID: t1: text "Html" [editor/text: markup: {
Demo page
} show html show editor update]font-size 12 0.0.0
ID: t2: text " " space 9
ID: t3: text "Rebol" [editor/text: markup: {REBOL [
Title: ""
Date:
Author: ""
File: %RT.r
Email: you@www.com
Purpose: {
}
Category: []
]}
show editor if error? try [
do editor/text ][] ]
font-size 12 0.0.0
ID: t4: text "Text" [editor/text: markup: thist4: {} show editor html/text: "" show html]
font-size 12 0.0.0
ID: t5: text "Insert" []font-size 12 0.0.0
ID: t6: text "Preview" []font-size 12 0.0.0
ID: t8: text "Help" []font-size 12 0.0.0 below pad -19x-5 space 0
ID: b1: box 549x1 gray pad 0x0
ID: b2: box 549x1 white space 0 below across pad -14x2
pad 300x0
Go: button "Go" 30x25 [replace html/text "http://" ""
either find html/text "www" [
insert html/text "http://"
either exists? to-url html/text [
markup: read to-url html/text
][
html/text: "Error: File not found" show html markup: " " ]][
either find html/text "/" [
remove html/text "/"
either exists? to-File html/text [
markup: read to-file html/text
][html/text: "Error: File not found" show html markup: " "]
][
either find html/text {: } [if error? try [do html/text markup: " "][]][markup: " "]
]]
clean markup
show html
editor/text: markup show editor
editor/text
update
]
html: field 193
below
pad -19x3
page: box "msgQ/pad" 195.195.195 200.200.0 edge[size: 1x1 effect: 'inbevel ] 547x200
editor: area ivory 547x140 wrap
across
button "Up" 55x20 [if error? try [document/offset/y: document/offset/y + 30 show document][]]
button "Down" 55x20 [if error? try [document/offset/y: document/offset/y - 30 show document][]]
button "View code" 85x20 [clean editor/text markup: copy editor/text
update
]
]
page/pane: ""
getnodename: func [tag][
heads: to-string copy tag insert heads "<"
findtail: parse/all tag " " tails: findtail/1
tails: to-tag join "/" tails
parse/all markup
[
to heads copy nodename to ">" (heads: to-string reduce [nodename">"])
thru ">" copy text to tails (text: to-string text)
(parse nodename
[
some [thru " " copy attname to "=" thru "=" copy attvalue to ">"
] skip
]node: to-string reduce [heads text tails]
)
]
]
selectnodes: func [nodename childnode nodevalue /local getchildnode][
getchildnode: [] text: copy nodevalue
heads: to-string reduce ["<" nodename]
tails: to-string reduce ["" nodename ">"]
nodelist: "" clear getchildnode
parse markup[
some [
to heads copy nodeslist thru tails
( append getchildnode nodeslist)]skip
]
foreach child getchildnode [
getnode: find child childnode
gettails: find child tails
node: find/part getnode nodevalue gettails
either find child node
[
nodelist: [] append nodelist child
newlist: [] append newlist child
][
]
]
]
getnodevalue: func [txt] [
text: txt if find markup text
[
parse/all markup
[
thru "<" copy htag to txt copy text to ""
]
findtag: copy htag
setag: find/last findtag "<"
parse setag [thru "<" copy gethead to ">"]
sethead: copy gethead
hds: parse/all sethead " " gettail: copy hds/1
heads: copy setag
tails: to-tag copy gettail insert tails "/"
parse setag
[
thru " " copy attname to "=" thru "=" copy attvalue
to ">"
]
]
node: to-string reduce [heads text tails]
]
getattribute: func [attrv][
parse/all markup [some [
to "<" copy heads to attrv
copy attname to "=" thru {="} copy attvalue
to {"}
to ">" thru ">" copy text
to ""
]skip
]
hds: find/last heads "<"
parse markup
[
to hds copy heads thru ">"
]
parse hds
[
thru "<" copy gettail to " " (trim/all gettail)
]
tails: to-tag copy gettail insert tails "/"
node: to-string reduce [heads text tails]
]
getid: func[id][
parse markup [
to "<" copy heads
to "id=" thru "id="
to id copy attvalue thru id
copy endhead to ">" thru ">" copy text
to "" (
hds: find/last heads "<"
gettail: parse/all hds " " gettail: gettail/1
remove gettail
tails: to-tag copy gettail insert tails "/"
node: to-string reduce [heads text tails]
print node) ]
]
getattval: func[attrv]
[
parse markup [some [
to "<" copy findheads to attrv thru attrv copy gettails to ">"
thru ">" copy text to ""
(heads: to-string reduce [findheads attrv gettails ">"])
]
]
heads: find/last heads "<"
parse/all heads [some
[
to " " copy attribute to {="} thru {="}
to attrv copy attvalue thru attrv
to {"}
]skip
]
parse heads
[
thru "<" copy gettail to " " (trim/all gettail)
]
tails: to-tag copy gettail insert tails "/"
node: to-string reduce [heads text tails]
]
setnode: func [newhead][
newhead: to-string copy newhead
insert newhead "<"
findtail: parse/all newhead " "
settail: copy findtail/1
remove settail settail/1
newtail: to-tag to-string reduce ["/" settail]
parse markup [to heads copy oldhead thru text to ""]
oldhead: find/last oldhead "<"
size: parse/all heads " "
parse markup
[
to oldhead mark: (replace mark size/1 ""
mark: insert mark newhead) :mark
to tails mark: (replace mark tails ""
mark: insert mark newtail) :mark
]
parse markup
[
to newhead copy heads to text
]
parse newhead
[
thru " " copy attname to "=" thru "=" copy attvalue to end
]clear newhead
]
setnodevalue: func [newtext][
size: length? text
parse/all markup [some
[
to heads thru heads to text mark:
(remove/part mark size
mark: insert mark newtext) :mark
(text: mark)]skip
]
]
setattribute: func [attrvar attrvalue]
[
findhead: parse/all heads " "
thishead: to-string findhead/1
parse markup
[
to thishead thru thishead
to attname mark: (replace mark attname ""
mark: insert mark attrvar) :mark
to attvalue mark: (replace mark attvalue ""
mark: insert mark attrvalue) :mark
]
attname: attrvar
attvalue: attrvalue
]
getchildnode: func [][
parse markup [
to heads copy childnode to tails (
replace childnode heads ""
remove childnode ">"
replace childnode tails ""
parse childnode
[
to "<" copy heads to ">" thru ">" copy text to "<" (text: to-string text)
]
hds: parse/all heads " " gettail: to-string hds/1
gettail: remove head gettail
tails: to-tag copy gettail insert tails "/"
node: to-string reduce [heads ">" text tails]
)]
]
getnextsibling: func [][
oldnode: copy/part (find markup text) (find/last markup "")
either find oldnode heads [
parse oldnode
[
thru text to heads copy nhead thru ">" copy text to "<"
]
parse nhead
[
thru " " copy attributename to "=" thru "=" copy attributevalue to ">"
]
node: to-string reduce [heads text tails]
]
[print reduce
[
heads "has no sibling...."
]
]
]
createnode: func [newnode][
tailnode: newnode
parse markup
[
to text thru text to tails thru tails objtail: to "<"
objtext: (change/part objtail reduce [newline newnode newline] :objtext)
(parse tailnode [some [thru ">" copy text to "" (getnodevalue text)]])
]
]
appendnode: func [newnode][
tailnode: newnode
endnode: find/last markup ""
parse markup
[
objtail: to endnode
objhead: (append objtail reduce [newnode newline] :objhead
parse endnode [to "" copy lastnode thru ">"]
replace markup lastnode ""
append markup lastnode)
(parse newnode [thru ">" copy text to "" (getnodevalue text)])
]
]
removenode: func [][either find markup node [
replace markup node " "
replace markup "^/^/" "^/"
][
print "Node not found"
]
]
vide/size: 550x440
view vide
halt