Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

BUILD-MARKUP

 [1/2] from: al::bri::xtra::co::nz at: 4-Aug-2002 13:42


Brett wrote:
> I also feel that BUILD-MARKUP should be able to accept a block as input.
It feels limiting that code inside <%...%> will only be bound to the global context. I may have mentioned this before but there's my ML dialect which creates HTML markup from Rebol words, paths and other values. It makes the HTML/XHTML look like Rebol script. For example, the Envelope function my Rebol/Wiki: Envelope: func [Title [string!] Body [block!]] [ content-type 'text/html print newline print ML compose/deep [ <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> html [ head [ title (Title) link/rel/type/href "stylesheet" "text/css" (Stylesheet) script/type/language/src "text/javascript" "JavaScript" %Wiki.js "" ] body/onload/id "SetColumnHeight (HtmlElement)" "HtmlElement" [(Body)] ] ] quit ] The view page function uses the above and looks something like: Envelope Title compose/deep either file? Page [ [ (Folder_Buttons Page) div/id "Center_Column" [ ( eText/Wiki/Base read Wiki_Folder/:Page rejoin [ CGI/Script-File #"?" ] ) ] div/id "Commands" [ (Random_Page/GUI) (Search/GUI Title) (Edit_Page/GUI Page) ] ] And it's done through a nice and simple parser as shown below. Andrew Martin ICQ: 26227169 http://valley.150m.com/ -><- ML: function [Dialect [block!]] [String Values_Rule Values Value Tag] [ String: make string! 40000 Values_Rule: [ ; Caution! The 'none word below is replaced in the 'parse rule below! none [ set Value any-type! ( Tag: next next Tag insert Tag Value Value: none ) ] ; Caution! The 'opt word below is replaced in the 'parse rule below! opt [ set Value [ decimal! | file! | block! | string! | char! | money! | time! | issue! | tuple! | date! | email! | pair! | logic! | integer! | url! ] ] ] Values: make block! 10 parse Dialect [ any [ [ set Tag tag! ( Values_Rule/1: 0 ; Replace 'none word in 'Values_Rule above. Values_Rule/3: either any [ ; Replace 'opt word... #"/" = last Tag ; empty tag. #"?" = first Tag ; XML tag. #"!" = first Tag ; DOCTYPE tag. ] [0] [1] ) | set Tag [path! | word!] ( Tag: to-block get 'Tag Values_Rule/1: -1 + length? Tag ; Replace 'none word in 'Values_Rule above. Values_Rule/3: 'opt ; Replace 'opt word... ) ] (Value: none) Values_Rule ( Tag: head Tag either none? Value [ if not tag? Tag [ Tag: build-tag Tag ] if all [ #"/" <> last Tag #"?" <> first Tag #"!" <> first Tag ] [ append Tag " /" ] append String Tag append String newline ] [ repend String [ either block? Value [newline] [""] either tag? Tag [Tag] [Build-Tag Tag] either block? Value [ML Value] [Value] to-tag join #"/" first either tag? Tag [to-block Tag] [Tag] ] ] Values_Rule/1: none ) | none! ; Ignore 'none values. | set Value any-type! (append String Value) ] end ] String ]

 [2/2] from: brett:codeconscious at: 4-Aug-2002 16:30


Hi Andrew,
> Brett wrote: > > I also feel that BUILD-MARKUP should be able to accept a block as input. > It feels limiting that code inside <%...%> will only be bound to the
global
> context. > > I may have mentioned this before but there's my ML dialect which creates > HTML markup from Rebol words, paths and other values. It makes the > HTML/XHTML look like Rebol script.
Thanks for your scripts. Yes, the form of your markup dialect was one of the things in my mind that prompted my statement above. The other thing that seems a bit odd to me is that BUILD-MARKUP cannot take as input, the output from LOAD/MARKUP. But perhaps the oddness is in my expectations :^) Brett.