! Copyright (C) 2004, 2009 Chris Double, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: io io.styles kernel namespaces prettyprint quotations
-sequences strings words xml.entities compiler.units effects
-xml.data urls math math.parser combinators
-present fry io.streams.string xml.writer html ;
+USING: io.styles kernel present sequences words xml.entities ;
IN: html.elements
SYMBOL: html
<<
-: elements-vocab ( -- vocab-name ) "html.elements" ;
+CONSTANT: elements-vocab "html.elements"
: html-word ( name def effect -- )
- #! Define 'word creating' word to allow
- #! dynamically creating words.
- [ elements-vocab create ] 2dip define-declared ;
+ ! Define 'word creating' word to allow
+ ! dynamically creating words.
+ [ elements-vocab create-word ] 2dip define-declared ;
: <foo> ( str -- <str> ) "<" ">" surround ;
: def-for-html-word-<foo> ( name -- )
- #! Return the name and code for the <foo> patterned
- #! word.
+ ! Return the name and code for the <foo> patterned
+ ! word.
dup <foo> swap '[ _ <foo> write-html ]
- (( -- )) html-word ;
+ ( -- ) html-word ;
: <foo ( str -- <str ) "<" prepend ;
: def-for-html-word-<foo ( name -- )
- #! Return the name and code for the <foo patterned
- #! word.
+ ! Return the name and code for the <foo patterned
+ ! word.
<foo dup '[ _ write-html ]
- (( -- )) html-word ;
+ ( -- ) html-word ;
: foo> ( str -- foo> ) ">" append ;
: def-for-html-word-foo> ( name -- )
- #! Return the name and code for the foo> patterned
- #! word.
- foo> [ ">" write-html ] (( -- )) html-word ;
+ ! Return the name and code for the foo> patterned
+ ! word.
+ foo> [ ">" write-html ] ( -- ) html-word ;
: </foo> ( str -- </str> ) "</" ">" surround ;
: def-for-html-word-</foo> ( name -- )
- #! Return the name and code for the </foo> patterned
- #! word.
- </foo> dup '[ _ write-html ] (( -- )) html-word ;
+ ! Return the name and code for the </foo> patterned
+ ! word.
+ </foo> dup '[ _ write-html ] ( -- ) html-word ;
: <foo/> ( str -- <str/> ) "<" "/>" surround ;
: def-for-html-word-<foo/> ( name -- )
- #! Return the name and code for the <foo/> patterned
- #! word.
+ ! Return the name and code for the <foo/> patterned
+ ! word.
dup <foo/> swap '[ _ <foo/> write-html ]
- (( -- )) html-word ;
+ ( -- ) html-word ;
: foo/> ( str -- str/> ) "/>" append ;
: def-for-html-word-foo/> ( name -- )
- #! Return the name and code for the foo/> patterned
- #! word.
- foo/> [ "/>" write-html ] (( -- )) html-word ;
+ ! Return the name and code for the foo/> patterned
+ ! word.
+ foo/> [ "/>" write-html ] ( -- ) html-word ;
: define-closed-html-word ( name -- )
- #! Given an HTML tag name, define the words for
- #! that closable HTML tag.
+ ! Given an HTML tag name, define the words for
+ ! that closable HTML tag.
dup def-for-html-word-<foo>
dup def-for-html-word-<foo
dup def-for-html-word-foo>
def-for-html-word-</foo> ;
: define-open-html-word ( name -- )
- #! Given an HTML tag name, define the words for
- #! that open HTML tag.
+ ! Given an HTML tag name, define the words for
+ ! that open HTML tag.
dup def-for-html-word-<foo/>
dup def-for-html-word-<foo
def-for-html-word-foo/> ;
: define-attribute-word ( name -- )
dup "=" prepend swap
- '[ _ write-attr ] (( string -- )) html-word ;
+ '[ _ write-attr ] ( string -- ) html-word ;
! Define some closed HTML tags
[