factor: [XML -> XML[[

locals-and-roots
Doug Coleman 2016-06-05 17:38:35 -07:00
parent 314f9a18bf
commit 4a09f254cf
37 changed files with 193 additions and 183 deletions

View File

@ -27,7 +27,7 @@ CONSTANT: tc-lisp-slides
{ $code
"USING: splitting xml.writer xml.syntax ;
{ \"one\" \"two\" \"three\" }
[ [XML <item><-></item> XML] ] map
[ XML[[ <item><-></item> XML]] ] map
<XML <doc><-></doc> XML> pprint-xml"
}
}

View File

@ -74,12 +74,12 @@ CHLOE: a
[
[ a-attrs ]
[ compile-children>xml-string ] bi
[ <unescaped> [XML <a><-></a> XML] second swap >>attrs ]
[ <unescaped> XML[[ <a><-></a> XML]] second swap >>attrs ]
[xml-code]
] compile-with-scope ;
CHLOE: base
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
compile-a-url [ XML[[ <base href=<->/> XML]] ] [xml-code] ;
: hidden-nested-fields ( -- xml )
nested-forms get " " join f like nested-forms-key
@ -93,7 +93,7 @@ CHLOE: base
_ render-hidden
hidden-nested-fields
form-modifications
[XML <div style="display: none;"><-><-><-></div> XML]
XML[[ <div style="display: none;"><-><-><-></div> XML]]
] [code] ;
: (compile-form-attrs) ( method action -- )
@ -122,7 +122,7 @@ CHLOE: form
[ hidden-fields ]
[ compile-children>xml-string ] tri
[
<unescaped> [XML <form><-><-></form> XML] second
<unescaped> XML[[ <form><-><-></form> XML]] second
swap >>attrs
write-xml
] [code]

View File

@ -23,7 +23,7 @@ M: recaptcha call-responder*
: (render-recaptcha) ( url -- xml )
dup
[XML
XML[[
<script type="text/javascript"
src=<->>
</script>
@ -36,7 +36,7 @@ M: recaptcha call-responder*
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge"/>
</noscript>
XML] ;
XML]] ;
: recaptcha-url ( secure? -- ? )
"https" "http" ? "://www.google.com/recaptcha/api/challenge" append

View File

@ -86,7 +86,7 @@ M: object modify-form drop f ;
: hidden-form-field ( value name -- xml )
over [
[XML <input type="hidden" value=<-> name=<->/> XML]
XML[[ <input type="hidden" value=<-> name=<->/> XML]]
] [ drop ] if ;
CONSTANT: nested-forms-key "__n" ;

View File

@ -218,7 +218,7 @@ CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');" ;
: render-code ( string mode -- xml )
[ string-lines ] dip htmlize-lines
[XML <pre><-></pre> XML] ;
XML[[ <pre><-></pre> XML]] ;
GENERIC: (write-farkup) ( farkup -- xml ) ;
@ -243,15 +243,15 @@ M: table (write-farkup) "table" farkup-inside ;
: write-link ( href text -- xml )
[ check-url link-no-follow? get "nofollow" and ] dip
[XML <a href=<-> rel=<->><-></a> XML] ;
XML[[ <a href=<-> rel=<->><-></a> XML]] ;
: write-image-link ( href text -- xml )
disable-images? get [
2drop
[XML <strong>Images are not allowed</strong> XML]
XML[[ <strong>Images are not allowed</strong> XML]]
] [
[ check-url ] [ f like ] bi*
[XML <img src=<-> alt=<->/> XML]
XML[[ <img src=<-> alt=<->/> XML]]
] if ;
: open-link ( link -- href text )
@ -267,15 +267,15 @@ M: code (write-farkup)
[ string>> ] [ mode>> ] bi render-code ;
M: line (write-farkup)
drop [XML <hr/> XML] ;
drop XML[[ <hr/> XML]] ;
M: line-break (write-farkup)
drop [XML <br/> XML] ;
drop XML[[ <br/> XML]] ;
M: table-row (write-farkup)
child>>
[ (write-farkup) [XML <td><-></td> XML] ] map
[XML <tr><-></tr> XML] ;
[ (write-farkup) XML[[ <td><-></td> XML]] ] map
XML[[ <tr><-></tr> XML]] ;
M: string (write-farkup) ;

View File

@ -199,7 +199,7 @@ M: link-test link-href drop "http://www.apple.com/foo&bar" ;
! Test xml in html components
{ } [
[XML <foo/> XML] "xmltest" set-value
XML[[ <foo/> XML]] "xmltest" set-value
] unit-test
{ "<foo/>" } [

View File

@ -46,10 +46,10 @@ M: label render*
singleton: hidden
M: hidden render*
drop [XML <input value=<-> name=<-> type="hidden"/> XML] ;
drop XML[[ <input value=<-> name=<-> type="hidden"/> XML]] ;
: render-field ( value name size type -- xml )
[XML <input value=<-> name=<-> size=<-> type=<->/> XML] ;
XML[[ <input value=<-> name=<-> size=<-> type=<->/> XML]] ;
TUPLE: field size ;
@ -77,12 +77,12 @@ TUPLE: textarea rows cols ;
M:: textarea render* ( value name area -- xml )
area rows>> :> rows
area cols>> :> cols
[XML
XML[[
<textarea
name=<-name->
rows=<-rows->
cols=<-cols->><-value-></textarea>
XML] ;
XML]] ;
! Choice
TUPLE: choice size multiple choices ;
@ -92,7 +92,7 @@ TUPLE: choice size multiple choices ;
: render-option ( text selected? -- xml )
"selected" and swap
[XML <option selected=<->><-></option> XML] ;
XML[[ <option selected=<->><-></option> XML]] ;
: render-options ( value choice -- xml )
[ choices>> value ] [ multiple>> ] bi
@ -103,10 +103,10 @@ M:: choice render* ( value name choice -- xml )
choice size>> :> size
choice multiple>> "true" and :> multiple
value choice render-options :> contents
[XML <select
XML[[ <select
name=<-name->
size=<-size->
multiple=<-multiple->><-contents-></select> XML] ;
multiple=<-multiple->><-contents-></select> XML]] ;
! Checkboxes
TUPLE: checkbox label ;
@ -116,9 +116,9 @@ TUPLE: checkbox label ;
M: checkbox render*
[ "true" and ] [ ] [ label>> ] tri*
[XML <input
XML[[ <input
type="checkbox"
checked=<-> name=<->><-></input> XML] ;
checked=<-> name=<->><-></input> XML]] ;
! Link components
GENERIC: link-title ( obj -- string ) ;
@ -142,7 +142,7 @@ TUPLE: link target ;
M: link render*
nip swap
[ target>> ] [ [ link-href ] [ link-title ] bi ] bi*
[XML <a target=<-> href=<->><-></a> XML] ;
XML[[ <a target=<-> href=<->><-></a> XML]] ;
! XMode code component
TUPLE: code mode ;

View File

@ -109,6 +109,6 @@ C: <validation-error-state> validation-error-state ;
: render-validation-errors ( -- )
form get errors>>
[
[ [XML <li><-></li> XML] ] map
[XML <ul class="errors"><-></ul> XML] write-xml
[ XML[[ <li><-></li> XML]] ] map
XML[[ <ul class="errors"><-></ul> XML]] write-xml
] unless-empty ;

View File

@ -22,10 +22,10 @@ M: empty-prolog write-xml drop ;
XML> <empty-prolog> >>prolog ;
: render-error ( message -- xml )
[XML <span class="error"><-></span> XML] ;
XML[[ <span class="error"><-></span> XML]] ;
: simple-link ( xml url -- xml' )
url-encode swap [XML <a href=<->><-></a> XML] ;
url-encode swap XML[[ <a href=<->><-></a> XML]] ;
: simple-image ( url -- xml )
url-encode [XML <img src=<-> /> XML] ;
url-encode XML[[ <img src=<-> /> XML]] ;

View File

@ -72,7 +72,7 @@ MACRO: make-css ( pairs -- str )
: span-tag ( xml style -- xml )
span-css-style
[ swap [XML <span style=<->><-></span> XML] ] unless-empty ; inline
[ swap XML[[ <span style=<->><-></span> XML]] ] unless-empty ; inline
: emit-html ( stream quot -- )
dip data>> push ; inline
@ -125,7 +125,7 @@ CONSTANT: pre-css "white-space: pre; font-family: monospace; " ;
: div-tag ( xml style -- xml' )
div-css-style
[ swap [XML <div style=<->><-></div> XML] ] unless-empty ;
[ swap XML[[ <div style=<->><-></div> XML]] ] unless-empty ;
: format-html-div ( string style stream -- )
[ [ div-tag ] [ object-link-tag ] bi ] emit-html ;
@ -159,7 +159,7 @@ M: html-writer stream-format
format-html-span ;
M: html-writer stream-nl
[ [XML <br/> XML] ] emit-html ;
[ XML[[ <br/> XML]] ] emit-html ;
M: html-writer make-span-stream
html-span-stream new-html-sub-stream ;
@ -173,10 +173,10 @@ M: html-writer make-cell-stream
M: html-writer stream-write-table
[
table-style swap [
[ data>> [XML <td valign="top" style=<->><-></td> XML] ] with map
[XML <tr><-></tr> XML]
[ data>> XML[[ <td valign="top" style=<->><-></td> XML]] ] with map
XML[[ <tr><-></tr> XML]]
] with map
[XML <table style="display: inline-table; border-collapse: collapse;"><-></table> XML]
XML[[ <table style="display: inline-table; border-collapse: collapse;"><-></table> XML]]
] emit-html ;
M: html-writer dispose drop ;

View File

@ -274,7 +274,7 @@ ARTICLE: "html.templates.chloe.extend.components.example" "An example of a custo
"As an example, let's develop a custom Chloe component which renders an image stored in a form value. Since the component does not require any configuration, we can define a singleton class:"
{ $code "singleton: image" }
"Now we define a method on the " { $link render* } " generic word which renders the image using " { $link { "xml.syntax" "literals" } } ":"
{ $code "M: image render* 2drop [XML <img src=<-> /> XML] ;" }
{ $code "M: image render* 2drop XML[[ <img src=<-> /> XML]] ;" }
"Finally, we can define a Chloe component:"
{ $code "COMPONENT: image" }
"We can use it as follows, assuming the current form has a value named " { $snippet "image" } ":"

View File

@ -19,7 +19,7 @@ CHLOE: write-title
drop
"head" tag-stack get member?
"title" tag-stack get member? not and
[ get-title [XML <title><-></title> XML] ]
[ get-title XML[[ <title><-></title> XML]] ]
[ get-title ] ?
[xml-code] ;
@ -33,7 +33,7 @@ CHLOE: style
CHLOE: write-style
drop [
get-style
[XML <style type="text/css"> <-> </style> XML]
XML[[ <style type="text/css"> <-> </style> XML]]
] [xml-code] ;
CHLOE: even

View File

@ -66,13 +66,13 @@ symbol: atom-feeds
: get-atom-feeds ( -- xml )
atom-feeds get [
[XML
XML[[
<link
rel="alternate"
type="application/atom+xml"
title=<->
href=<->/>
XML]
XML]]
] { } assoc>map ;
: write-atom-feeds ( -- )

View File

@ -60,14 +60,14 @@ TUPLE: file-responder root hook special index-names allow-listings ;
: file>html ( name -- xml )
dup link-info directory? [ "/" append ] when
dup [XML <li><a href=<->><-></a></li> XML] ;
dup XML[[ <li><a href=<->><-></a></li> XML]] ;
: directory>html ( path -- xml )
[ file-name ]
[ drop f ]
[
[ file-name ] [ [ natural-sort [ file>html ] map ] with-directory-files ] bi
[XML <h1><-></h1> <ul><-></ul> XML]
XML[[ <h1><-></h1> <ul><-></ul> XML]]
] tri
simple-page ;

View File

@ -11,30 +11,30 @@ GENERIC: diff-line ( obj -- xml ) ;
M: retain diff-line
item-string
[XML <td class="retain"><-></td> XML]
dup [XML <tr><-><-></tr> XML] ;
XML[[ <td class="retain"><-></td> XML]]
dup XML[[ <tr><-><-></tr> XML]] ;
M: insert diff-line
item-string [XML
item-string XML[[
<tr>
<td> </td>
<td class="insert"><-></td>
</tr>
XML] ;
XML]] ;
M: delete diff-line
item-string [XML
item-string XML[[
<tr>
<td class="delete"><-></td>
<td> </td>
</tr>
XML] ;
XML]] ;
: htmlize-diff ( diff -- xml )
[ diff-line ] map
[XML
XML[[
<table width="100%" class="comparison">
<tr><th>Old</th><th>New</th></tr>
<->
</table>
XML] ;
XML]] ;

View File

@ -119,14 +119,14 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ;
[ date>> timestamp>rfc3339 ]
[ description>> ]
} cleave
[XML
XML[[
<entry>
<title type="html"><-></title>
<link rel="alternate" href=<-> />
<published><-></published>
<content type="html"><-></content>
</entry>
XML] ;
XML]] ;
: feed>xml ( feed -- xml )
[ title>> ]

View File

@ -16,34 +16,34 @@ GENERIC: item>xml ( object -- xml ) ;
M: integer item>xml
dup 31 2^ neg 31 2^ 1 - between?
[ "Integers must fit in 32 bits" throw ] unless
[XML <i4><-></i4> XML] ;
XML[[ <i4><-></i4> XML]] ;
M: boolean item>xml
"1" "0" ? [XML <boolean><-></boolean> XML] ;
"1" "0" ? XML[[ <boolean><-></boolean> XML]] ;
M: float item>xml
number>string [XML <double><-></double> XML] ;
number>string XML[[ <double><-></double> XML]] ;
M: string item>xml
[XML <string><-></string> XML] ;
XML[[ <string><-></string> XML]] ;
: struct-member ( name value -- tag )
over string? [ "Struct member name must be string" throw ] unless
item>xml
[XML
XML[[
<member>
<name><-></name>
<value><-></value>
</member>
XML] ;
XML]] ;
M: hashtable item>xml
[ struct-member ] { } assoc>map
[XML <struct><-></struct> XML] ;
XML[[ <struct><-></struct> XML]] ;
M: array item>xml
[ item>xml [XML <value><-></value> XML] ] map
[XML <array><data><-></data></array> XML] ;
[ item>xml XML[[ <value><-></value> XML]] ] map
XML[[ <array><data><-></data></array> XML]] ;
TUPLE: base64 string ;
@ -51,11 +51,11 @@ C: <base64> base64 ;
M: base64 item>xml
string>> >base64
[XML <base64><-></base64> XML] ;
XML[[ <base64><-></base64> XML]] ;
: params ( seq -- xml )
[ item>xml [XML <param><value><-></value></param> XML] ] map
[XML <params><-></params> XML] ;
[ item>xml XML[[ <param><value><-></value></param> XML]] ] map
XML[[ <params><-></params> XML]] ;
: method-call ( name seq -- xml )
params

View File

@ -36,7 +36,7 @@ ARTICLE: { "xml.syntax" "literals" } "XML literals"
"The following words provide syntax for XML literals:"
{ $subsections
postpone\ <XML
postpone\ [XML
postpone\ XML[[
}
"These can be used for creating an XML literal, which can be used with variables or a fry-like syntax to interpolate data into XML."
{ $subsections { "xml.syntax" "interpolation" } } ;
@ -45,18 +45,18 @@ HELP: <XML
{ $syntax "<XML <?xml version=\"1.0\"?><document>...</document> XML>" }
{ $description "This gives syntax for literal XML documents. When evaluated, there is an XML document (" { $link xml } ") on the stack. It can be used for interpolation as well, if interpolation slots are used. For more information about XML interpolation, see " { $link { "xml.syntax" "interpolation" } } "." } ;
HELP: [XML
{ $syntax "[XML foo <x>...</x> bar <y>...</y> baz XML]" }
HELP: XML[[
{ $syntax "XML[[ foo <x>...</x> bar <y>...</y> baz XML]]" }
{ $description "This gives syntax for literal XML documents. When evaluated, there is an XML chunk (" { $link xml-chunk } ") on the stack. For more information about XML interpolation, see " { $link { "xml.syntax" "interpolation" } } "." } ;
ARTICLE: { "xml.syntax" "interpolation" } "XML interpolation syntax"
"XML interpolation has two forms for each of the words " { $link postpone\ <XML } " and " { $link postpone\ [XML } ": a fry-like form and a locals form. To splice locals in, use the syntax " { $snippet "<-variable->" } ". To splice something in from the stack, in the style of " { $vocab-link "fry" } ", use the syntax " { $snippet "<->" } ". An XML interpolation form may only use one of these styles."
"XML interpolation has two forms for each of the words " { $link postpone\ <XML } " and " { $link postpone\ XML[[ } ": a fry-like form and a locals form. To splice locals in, use the syntax " { $snippet "<-variable->" } ". To splice something in from the stack, in the style of " { $vocab-link "fry" } ", use the syntax " { $snippet "<->" } ". An XML interpolation form may only use one of these styles."
$nl
"These forms can be used where a tag might go, as in " { $snippet "[XML <foo><-></foo> XML]" } " or where an attribute might go, as in " { $snippet "[XML <foo bar=<->/> XML]" } ". When an attribute is spliced in, it is not included if the value is " { $snippet "f" } " and if the value is not a string, the value is put through " { $link present } ". Here is an example of the fry style of XML interpolation:"
"These forms can be used where a tag might go, as in " { $snippet "XML[[ <foo><-></foo> XML]]" } " or where an attribute might go, as in " { $snippet "XML[[ <foo bar=<->/> XML]]" } ". When an attribute is spliced in, it is not included if the value is " { $snippet "f" } " and if the value is not a string, the value is put through " { $link present } ". Here is an example of the fry style of XML interpolation:"
{ $example
"USING: splitting xml.writer xml.syntax ;
\"one two three\" \" \" split
[ [XML <item><-></item> XML] ] map
[ XML[[ <item><-></item> XML]] ] map
<XML <doc><-></doc> XML> pprint-xml"
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@ -96,12 +96,12 @@ $nl
{ $example "USING: xml.syntax inverse ;
: dispatch ( xml -- string )
{
{ [ [XML <a><-></a> XML] ] [ \"a\" prepend ] }
{ [ [XML <b><-></b> XML] ] [ \"b\" prepend ] }
{ [ [XML <b val='yes'/> XML] ] [ \"yes\" ] }
{ [ [XML <b val=<->/> XML] ] [ \"no\" prepend ] }
{ [ XML[[ <a><-></a> XML]] ] [ \"a\" prepend ] }
{ [ XML[[ <b><-></b> XML]] ] [ \"b\" prepend ] }
{ [ XML[[ <b val='yes'/> XML]] ] [ \"yes\" ] }
{ [ XML[[ <b val=<->/> XML]] ] [ \"no\" prepend ] }
} switch ;
[XML <a>pple</a> XML] dispatch write"
XML[[ <a>pple</a> XML]] dispatch write"
"apple" } ;
HELP: XML-NS:

View File

@ -55,7 +55,7 @@ XML-NS: foo http://blah.com
y
<foo/>
</x>" } [
[let "one" :> a "two" :> c "y" :> x [XML <-x-> <foo/> XML] :> d
[let "one" :> a "two" :> c "y" :> x XML[[ <-x-> <foo/> XML]] :> d
<XML
<x> <-a-> <b val=<-c->/> <-d-> </x>
XML> pprint-xml>string
@ -75,7 +75,7 @@ XML-NS: foo http://blah.com
</item>
</doc>" } [
"one two three" " " split
[ [XML <item><-></item> XML] ] map
[ XML[[ <item><-></item> XML]] ] map
<XML <doc><-></doc> XML> pprint-xml>string
] unit-test
@ -85,38 +85,38 @@ XML-NS: foo http://blah.com
<XML <x number=<-> false=<-> url=<-> string=<-> word=<->/> XML>
pprint-xml>string ] unit-test
{ "<x>3</x>" } [ 3 [XML <x><-></x> XML] xml>string ] unit-test
{ "<x></x>" } [ f [XML <x><-></x> XML] xml>string ] unit-test
{ "<x>3</x>" } [ 3 XML[[ <x><-></x> XML]] xml>string ] unit-test
{ "<x></x>" } [ f XML[[ <x><-></x> XML]] xml>string ] unit-test
[ [XML <-> XML] ] must-infer
[ [XML <foo><-></foo> <bar val=<->/> XML] ] must-infer
[ XML[[ <-> XML]] ] must-infer
[ XML[[ <foo><-></foo> <bar val=<->/> XML]] ] must-infer
{ xml-chunk } [ [ [XML <foo/> XML] ] first class-of ] unit-test
{ xml-chunk } [ [ XML[[ <foo/> XML]] ] first class-of ] unit-test
{ xml } [ [ <XML <foo/> XML> ] first class-of ] unit-test
{ xml-chunk } [ [ [XML <foo val=<->/> XML] ] third class-of ] unit-test
{ xml-chunk } [ [ XML[[ <foo val=<->/> XML]] ] third class-of ] unit-test
{ xml } [ [ <XML <foo val=<->/> XML> ] third class-of ] unit-test
{ 1 } [ [ [XML <foo/> XML] ] length ] unit-test
{ 1 } [ [ XML[[ <foo/> XML]] ] length ] unit-test
{ 1 } [ [ <XML <foo/> XML> ] length ] unit-test
{ "" } [ [XML XML] concat ] unit-test
{ "" } [ XML[[ XML]] concat ] unit-test
{ "foo" } [ [XML <a>foo</a> XML] [ [XML <a><-></a> XML] ] undo ] unit-test
{ "foo" } [ [XML <a bar='foo'/> XML] [ [XML <a bar=<-> /> XML] ] undo ] unit-test
{ "foo" "baz" } [ [XML <a bar='foo'>baz</a> XML] [ [XML <a bar=<->><-></a> XML] ] undo ] unit-test
{ "foo" } [ XML[[ <a>foo</a> XML]] [ XML[[ <a><-></a> XML]] ] undo ] unit-test
{ "foo" } [ XML[[ <a bar='foo'/> XML]] [ XML[[ <a bar=<-> /> XML]] ] undo ] unit-test
{ "foo" "baz" } [ XML[[ <a bar='foo'>baz</a> XML]] [ XML[[ <a bar=<->><-></a> XML]] ] undo ] unit-test
: dispatch ( xml -- string )
{
{ [ [XML <a><-></a> XML] ] [ "a" prepend ] }
{ [ [XML <b><-></b> XML] ] [ "b" prepend ] }
{ [ [XML <b val='yes'/> XML] ] [ "byes" ] }
{ [ [XML <b val=<->/> XML] ] [ "bno" prepend ] }
{ [ XML[[ <a><-></a> XML]] ] [ "a" prepend ] }
{ [ XML[[ <b><-></b> XML]] ] [ "b" prepend ] }
{ [ XML[[ <b val='yes'/> XML]] ] [ "byes" ] }
{ [ XML[[ <b val=<->/> XML]] ] [ "bno" prepend ] }
} switch ;
{ "apple" } [ [XML <a>pple</a> XML] dispatch ] unit-test
{ "banana" } [ [XML <b>anana</b> XML] dispatch ] unit-test
{ "byes" } [ [XML <b val="yes"/> XML] dispatch ] unit-test
{ "bnowhere" } [ [XML <b val="where"/> XML] dispatch ] unit-test
{ "baboon" } [ [XML <b val="something">aboon</b> XML] dispatch ] unit-test
{ "apple" } [ XML[[ <a>pple</a> XML]] dispatch ] unit-test
{ "banana" } [ XML[[ <b>anana</b> XML]] dispatch ] unit-test
{ "byes" } [ XML[[ <b val="yes"/> XML]] dispatch ] unit-test
{ "bnowhere" } [ XML[[ <b val="where"/> XML]] dispatch ] unit-test
{ "baboon" } [ XML[[ <b val="something">aboon</b> XML]] dispatch ] unit-test
{ "apple" } [ <XML <a>pple</a> XML> dispatch ] unit-test
{ "apple" } [ <XML <a>pple</a> XML> body>> dispatch ] unit-test
@ -129,7 +129,7 @@ XML-NS: foo http://blah.com
} switch ;
{ "apple" } [ <XML <a>pple</a> XML> dispatch-doc ] unit-test
{ "apple" } [ [XML <a>pple</a> XML] dispatch-doc ] unit-test
{ "apple" } [ XML[[ <a>pple</a> XML]] dispatch-doc ] unit-test
{ "apple" } [ <XML <a>pple</a> XML> body>> dispatch-doc ] unit-test
! Make sure nested XML documents interpolate correctly

View File

@ -173,8 +173,8 @@ PRIVATE>
SYNTAX: <XML
"XML>" [ string>doc ] parse-def ;
SYNTAX: [XML
"XML]" [ string>chunk ] parse-def ;
SYNTAX: XML[[
"XML]]" [ string>chunk ] parse-def ;
use: vocabs.loader

View File

@ -3,7 +3,7 @@ accessors xml.data xml.traversal xml.writer generic sequences.deep multiline ;
in: xml.tests
CONSTANT: sub-tag
T{ name f f "sub" "http://littledan.onigirihouse.com/namespaces/replace" }
T{ name f f "sub" "http://littledan.onigirihouse.com/namespaces/replace" } ;
symbol: ref-table

View File

@ -48,7 +48,7 @@ HELP: pprint-xml
HELP: indenter
{ $var-description "Contains the string which is used for indenting in the XML prettyprinter. For example, to print an XML document using " { $snippet "%%%%" } " for indentation, you can use the following:" }
{ $example "USING: xml.syntax xml.writer namespaces ;
[XML <foo>bar</foo> XML] \"%%%%\" indenter [ pprint-xml ] with-variable " "
XML[[ <foo>bar</foo> XML]] \"%%%%\" indenter [ pprint-xml ] with-variable " "
<foo>
%%%%bar
</foo>" } ;
@ -56,9 +56,9 @@ HELP: indenter
HELP: sensitive-tags
{ $var-description "Contains a sequence of " { $link name } "s where whitespace should be considered significant for prettyprinting purposes. The sequence can contain " { $link string } "s in place of names. For example, to preserve whitespace inside a " { $snippet "pre" } " tag:" }
{ $example "USING: xml.syntax xml.writer namespaces ;
[XML <html> <head> <title> something</title></head><body><pre>bing
XML[[ <html> <head> <title> something</title></head><body><pre>bing
bang
bong</pre></body></html> XML] { \"pre\" } sensitive-tags [ pprint-xml ] with-variable"
bong</pre></body></html> XML]] { \"pre\" } sensitive-tags [ pprint-xml ] with-variable"
"
<html>
<head>

View File

@ -71,8 +71,8 @@ in: xml.writer.tests
{ } [
{ 1 2 3 4 } [
[ number>string ] [ sq number>string ] bi
[XML <tr><td><-></td><td><-></td></tr> XML]
] map [XML <h2>Timings</h2> <table><-></table> XML]
XML[[ <tr><td><-></td><td><-></td></tr> XML]]
] map XML[[ <h2>Timings</h2> <table><-></table> XML]]
pprint-xml
] unit-test

View File

@ -7,7 +7,7 @@ in: xmode.code2html
[
[ str>> ] [ id>> ] bi [
name>> swap
[XML <span class=<->><-></span> XML]
XML[[ <span class=<->><-></span> XML]]
] when*
] map ;
@ -21,7 +21,7 @@ in: xmode.code2html
: default-stylesheet ( -- xml )
"resource:basis/xmode/code2html/stylesheet.css"
utf8 file-contents
[XML <style><-></style> XML] ;
XML[[ <style><-></style> XML]] ;
:: htmlize-stream ( path stream -- xml )
stream stream-lines

View File

@ -9,6 +9,11 @@
"cocoa.subclassing" "cocoa" "cocoa.apple-script" "gobject-introspection" } diff
[ dup <vocab-link> . flush vocab>literals ] map-zip
"resource:tools" vocabs-from
{ "help.syntax" "help.tips" "tools.test" "tools.walker"
"vocabs.git" } diff
[ dup <vocab-link> . flush vocab>literals ] map-zip
"resource:language" vocabs-from
{ "constructors" "descriptive" "eval" "functors" "literals"

View File

@ -16,23 +16,23 @@ in: codebook
CONSTANT: codebook-style
{
{ COMMENT1 [ [XML <i><font color="#555555"><-></font></i> XML] ] }
{ COMMENT2 [ [XML <i><font color="#555555"><-></font></i> XML] ] }
{ COMMENT3 [ [XML <i><font color="#555555"><-></font></i> XML] ] }
{ COMMENT4 [ [XML <i><font color="#555555"><-></font></i> XML] ] }
{ DIGIT [ [XML <font color="#333333"><-></font> XML] ] }
{ FUNCTION [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ KEYWORD1 [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ KEYWORD2 [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ KEYWORD3 [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ KEYWORD4 [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ LABEL [ [XML <b><font color="#333333"><-></font></b> XML] ] }
{ LITERAL1 [ [XML <font color="#333333"><-></font> XML] ] }
{ LITERAL2 [ [XML <font color="#333333"><-></font> XML] ] }
{ LITERAL3 [ [XML <font color="#333333"><-></font> XML] ] }
{ LITERAL4 [ [XML <font color="#333333"><-></font> XML] ] }
{ MARKUP [ [XML <b><font color="#333333"><-></font></b> XML] ] }
{ OPERATOR [ [XML <b><font color="#111111"><-></font></b> XML] ] }
{ COMMENT1 [ XML[[ <i><font color="#555555"><-></font></i> XML]] ] }
{ COMMENT2 [ XML[[ <i><font color="#555555"><-></font></i> XML]] ] }
{ COMMENT3 [ XML[[ <i><font color="#555555"><-></font></i> XML]] ] }
{ COMMENT4 [ XML[[ <i><font color="#555555"><-></font></i> XML]] ] }
{ DIGIT [ XML[[ <font color="#333333"><-></font> XML]] ] }
{ FUNCTION [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
{ KEYWORD1 [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
{ KEYWORD2 [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
{ KEYWORD3 [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
{ KEYWORD4 [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
{ LABEL [ XML[[ <b><font color="#333333"><-></font></b> XML]] ] }
{ LITERAL1 [ XML[[ <font color="#333333"><-></font> XML]] ] }
{ LITERAL2 [ XML[[ <font color="#333333"><-></font> XML]] ] }
{ LITERAL3 [ XML[[ <font color="#333333"><-></font> XML]] ] }
{ LITERAL4 [ XML[[ <font color="#333333"><-></font> XML]] ] }
{ MARKUP [ XML[[ <b><font color="#333333"><-></font></b> XML]] ] }
{ OPERATOR [ XML[[ <b><font color="#111111"><-></font></b> XML]] ] }
[ drop ]
}
@ -70,7 +70,7 @@ TUPLE: code-file
: toc-list ( files -- list )
[ name>> ] map natural-sort [
[ file-html-name ] keep
[XML <li><a href=<->><-></a></li> XML]
XML[[ <li><a href=<->><-></a></li> XML]]
] map ;
! insert zero-width non-joiner between all characters so words can wrap anywhere
@ -82,7 +82,7 @@ TUPLE: code-file
: htmlize-tokens ( tokens line# -- html-tokens )
swap [
[ str>> zwnj ] [ id>> ] bi codebook-style case
] map [XML <tt><font size="-2" color="#666666"><-></font> <-></tt> XML]
] map XML[[ <tt><font size="-2" color="#666666"><-></font> <-></tt> XML]]
"\n" 2array ;
: line#>string ( i line#len -- i-string )
@ -141,10 +141,10 @@ TUPLE: code-file
name file-html-name :> filename
i 2 + number>string :> istr
[XML <navPoint class="book" id=<-filename-> playOrder=<-istr->>
XML[[ <navPoint class="book" id=<-filename-> playOrder=<-istr->>
<navLabel><text><-name-></text></navLabel>
<content src=<-filename-> />
</navPoint> XML]
</navPoint> XML]]
] map-index :> file-nav-points
<XML <?xml version="1.0" encoding="UTF-8" ?>
@ -164,10 +164,10 @@ TUPLE: code-file
files [
name>> file-html-name dup
[XML <item id=<-> href=<-> media-type="text/html" /> XML]
XML[[ <item id=<-> href=<-> media-type="text/html" /> XML]]
] map :> html-manifest
files [ name>> file-html-name [XML <itemref idref=<-> /> XML] ] map :> html-spine
files [ name>> file-html-name XML[[ <itemref idref=<-> /> XML]] ] map :> html-spine
<XML <?xml version="1.0" encoding="UTF-8" ?>
<package

View File

@ -69,11 +69,11 @@ M: pathname url-of
: help-stylesheet ( stylesheet -- xml )
"vocab:help/html/stylesheet.css" ascii file-contents
swap "\n" glue [XML <style><-></style> XML] ;
swap "\n" glue XML[[ <style><-></style> XML]] ;
: help-navbar ( -- xml )
"conventions" >link topic>filename
[XML
XML[[
<div class="navbar">
<b> Factor Documentation </b> |
<a href="/">Home</a> |
@ -84,7 +84,7 @@ M: pathname url-of
</form>
<a href="http://factorcode.org" style="float:right; padding: 4px;">factorcode.org</a>
</div>
XML] ;
XML]] ;
: bijective-base26 ( n -- name )
[ dup 0 > ] [ 1 - 26 /mod char: a + ] "" produce-as nip reverse! ;

View File

@ -8,7 +8,7 @@ in: mason.report
: git-link ( id -- link )
[ "http://github.com/factor/factor/commit/" "" prepend-as ] keep
[XML <a href=<->><-></a> XML] ;
XML[[ <a href=<->><-></a> XML]] ;
: common-report ( -- xml )
target-os get
@ -17,7 +17,7 @@ in: mason.report
disk-usage
build-dir
current-git-id get git-link
[XML
XML[[
<h1>Build report for <->/<-></h1>
<table>
<tr><td>Build machine:</td><td><-></td></tr>
@ -25,14 +25,14 @@ in: mason.report
<tr><td>Build directory:</td><td><-></td></tr>
<tr><td>GIT ID:</td><td><-></td></tr>
</table>
XML] ;
XML]] ;
: with-report ( quot -- )
[ "report" utf8 ] dip
'[
common-report
_ call( -- xml )
[XML <html><body><-><-></body></html> XML]
XML[[ <html><body><-><-></body></html> XML]]
write-xml
] with-file-writer ; inline
@ -44,13 +44,13 @@ in: mason.report
error [ error. ] with-string-writer :> error
file utf8 400 file-tail :> output
[XML
XML[[
<h2><-what-></h2>
Build output:
<pre><-output-></pre>
Launcher error:
<pre><-error-></pre>
XML]
XML]]
] with-report
status-error ;
@ -73,30 +73,30 @@ in: mason.report
html-help-time-file
} [
dup eval-file nanos>time
[XML <tr><td><-></td><td><-></td></tr> XML]
] map [XML <h2>Timings</h2> <table><-></table> XML] ;
XML[[ <tr><td><-></td><td><-></td></tr> XML]]
] map XML[[ <h2>Timings</h2> <table><-></table> XML]] ;
: error-dump ( heading vocabs-file messages-file -- xml )
[ eval-file ] dip over empty? [ 3drop f ] [
[ ]
[ [ [XML <li><-></li> XML] ] map [XML <ul><-></ul> XML] ]
[ [ XML[[ <li><-></li> XML]] ] map XML[[ <ul><-></ul> XML]] ]
[ utf8 file-contents ]
tri*
[XML <h1><-></h1> <-> Details: <pre><-></pre> XML]
XML[[ <h1><-></h1> <-> Details: <pre><-></pre> XML]]
] if ;
: benchmarks-table ( assoc -- xml )
[
1,000,000,000 /f
[XML <tr><td><-></td><td><-></td></tr> XML]
XML[[ <tr><td><-></td><td><-></td></tr> XML]]
] { } assoc>map
[XML
XML[[
<h2>Benchmarks</h2>
<table>
<tr><th>Benchmark</th><th>Time (seconds)</th></tr>
<->
</table>
XML] ;
XML]] ;
: successful-report ( -- )
[

View File

@ -56,18 +56,18 @@ symbol: time-std
: info-table ( alist -- html )
[
first2 dupd 1000000 /f
[XML
XML[[
<tr><td><a href=<->><-></a></td><td><-> seconds</td></tr>
XML]
] map [XML <table border="1"><-></table> XML] ;
XML]]
] map XML[[ <table border="1"><-></table> XML]] ;
: report-broken-pages ( -- html )
broken-pages get info-table ;
: report-network-failures ( -- html )
network-failures get [
dup [XML <li><a href=<->><-></a></li> XML]
] map [XML <ul><-></ul> XML] ;
dup XML[[ <li><a href=<->><-></a></li> XML]]
] map XML[[ <ul><-></ul> XML]] ;
: slowest-pages-table ( -- html )
slowest-pages get info-table ;
@ -76,31 +76,31 @@ symbol: time-std
mean-time get
median-time get
time-std get
[XML
XML[[
<table border="1">
<tr><th>Mean</th><td><-> seconds</td></tr>
<tr><th>Median</th><td><-> seconds</td></tr>
<tr><th>Standard deviation</th><td><-> seconds</td></tr>
</table>
XML] ;
XML]] ;
: report-timings ( -- html )
slowest-pages-table
timing-summary-table
[XML
XML[[
<h3>Slowest pages</h3>
<->
<h3>Summary</h3>
<->
XML] ;
XML]] ;
: generate-report ( -- html )
url get dup
report-broken-pages
report-network-failures
report-timings
[XML
XML[[
<h1>Spider report</h1>
URL: <a href=<->><-></a>
@ -112,7 +112,7 @@ symbol: time-std
<h2>Load times</h2>
<->
XML] ;
XML]] ;
: spider-report ( spider -- html )
[ "Spider report" f ] dip

View File

@ -38,4 +38,4 @@ M: fuzz-test-failure summary
PRIVATE>
TEST: fuzz-test
test: fuzz-test

View File

@ -114,6 +114,11 @@ SYNTAX: TEST:
[ "(" ")" surround search '[ _ parse-test ] ] bi
define-syntax ;
SYNTAX: test:
scan-token
[ create-word-in ]
[ "(" ")" surround search '[ _ parse-test ] ] bi
define-syntax ;
>>
: fake-unit-test ( quot -- test-failures )
@ -164,11 +169,11 @@ PRIVATE>
: with-test-directory ( ..a quot: ( ..a -- ..b ) -- ..b )
[ cleanup-unique-directory ] with-temp-directory ; inline
TEST: unit-test
TEST: must-infer-as
TEST: must-infer
TEST: must-fail-with
TEST: must-fail
test: unit-test
test: must-infer-as
test: must-infer
test: must-fail-with
test: must-fail
M: test-failure error. ( error -- )
{

View File

@ -5,7 +5,7 @@ mason.email webapps.mason.backend ;
in: webapps.mason.backend.watchdog
: crashed-builder-body ( crashed-builders -- string content-type )
[ os/cpu [XML <li><-></li> XML] ] map
[ os/cpu XML[[ <li><-></li> XML]] ] map
<XML
<html>
<body>

View File

@ -6,10 +6,10 @@ webapps.mason.utils ;
in: webapps.mason.downloads
CONSTANT: CRASHED
[XML <span style="background-color: yellow;">CRASHED</span> XML]
XML[[ <span style="background-color: yellow;">CRASHED</span> XML]]
CONSTANT: BROKEN
[XML <span style="background-color: red; color: white;">BROKEN</span> XML]
XML[[ <span style="background-color: red; color: white;">BROKEN</span> XML]]
: builder-status ( builder -- status/f )
{
@ -22,10 +22,10 @@ CONSTANT: BROKEN
[ os/cpu ] sort-with
[
[ report-url ] [ os/cpu ] [ builder-status ] tri
[XML <li><a href=<->><-></a> <-></li> XML]
XML[[ <li><a href=<->><-></a> <-></li> XML]]
] map
[ [XML <p>No machines.</p> XML] ]
[ [XML <ul><-></ul> XML] ]
[ XML[[ <p>No machines.</p> XML]] ]
[ XML[[ <ul><-></ul> XML]] ]
if-empty ;
: <dashboard-action> ( -- action )

View File

@ -9,8 +9,8 @@ in: webapps.mason.grids
: render-grid-cell ( cpu os quot -- xml )
call( cpu os -- url label )
2dup and
[ link [XML <td class="supported"><div class="bigdiv"><-></div></td> XML] ]
[ 2drop [XML <td class="doesnotexist" /> XML] ]
[ link XML[[ <td class="supported"><div class="bigdiv"><-></div></td> XML]] ]
[ 2drop XML[[ <td class="doesnotexist" /> XML]] ]
if ;
CONSTANT: oses
@ -27,21 +27,21 @@ CONSTANT: cpus
}
: render-grid-header ( -- xml )
oses values [ [XML <th align='center' scope='col'><-></th> XML] ] map ;
oses values [ XML[[ <th align='center' scope='col'><-></th> XML]] ] map ;
:: render-grid-row ( cpu quot -- xml )
cpu second oses keys [| os | cpu os quot render-grid-cell ] map
[XML <tr><th align='center' scope='row'><-></th><-></tr> XML] ;
XML[[ <tr><th align='center' scope='row'><-></th><-></tr> XML]] ;
:: render-grid ( quot -- xml )
render-grid-header
cpus [ quot render-grid-row ] map
[XML
XML[[
<table id="downloads" cellspacing="0">
<tr><th class="nobg">OS/CPU</th><-></tr>
<->
</table>
XML] ;
XML]] ;
: package-date ( filename -- date )
"." split1 drop 16 tail* 6 head* ;

View File

@ -9,7 +9,7 @@ in: webapps.mason.package
: building ( builder string -- xml )
swap current-git-id>> git-link
[XML <-> for <-> XML] ;
XML[[ <-> for <-> XML]] ;
: status-string ( builder -- string )
dup status>> {

View File

@ -20,4 +20,4 @@ in: webapps.mason.report
[ URL" report" ] dip
[ os>> "os" set-query-param ]
[ cpu>> "cpu" set-query-param ] bi
[XML <a href=<->>Latest build report</a> XML] ;
XML[[ <a href=<->>Latest build report</a> XML]] ;

View File

@ -7,7 +7,7 @@ webapps.mason.version.data xml.syntax ;
in: webapps.mason.utils
: link ( url label -- xml )
[XML <a href=<->><-></a> XML] ;
XML[[ <a href=<->><-></a> XML]] ;
: validate-os/cpu ( -- )
{
@ -35,7 +35,7 @@ in: webapps.mason.utils
?
] [ drop f ] if
] bi
2array sift [ [XML <li><-></li> XML] ] map [XML <ul><-></ul> XML] ;
2array sift [ XML[[ <li><-></li> XML]] ] map XML[[ <ul><-></ul> XML]] ;
: download-url ( string -- string' )
"http://downloads.factorcode.org/" prepend ;