[squeak-dev] Xtreams-Parsing - ALHtml5Canvas for XML.Element

Chris Cunnington smalltalktelevision at gmail.com
Wed Dec 26 20:57:01 UTC 2012


In an effort to write a WikiGenerator class for Xtreams-Parsing I 
decided to substitute ALHtml5Canvas for XML.Element. It's sort of all 
over the place, but fun.

WikiGenerator>>bold: first
     <action: 'Bold' arguments: #(2)>
     |str canvas|
     str := String new writing.
     first do: [:each| str put: each ].
     str close.
     canvas := ALHtml5Canvas on: String new writing.
     canvas b: str contents.
     ^canvas stream contents


It's coming along [1] but needs refactoring in ways I can't see yet. 
Getting a string out of an OrderedCollection of chars is a pain. And I 
have a feeling that owing to the use pragmas, I can't use ivars.

Actually, this is a model of how somebody uses Xtreams when they don't 
understand Terminals and Transforms. Oh, well. I think I'm all in for 
today.

Chris


[1]
         input := 'Single paragraph with *bold* and _italic_ text and a 
[link]' reading.

         wikiParser parse: 'Page' stream: input actor:  WikiGenerator new

  an OrderedCollection(an OrderedCollection($S $i $n $g $l $e Character 
space $p $a $r $a $g $r $a $p $h Character space $w $i $t $h Character 
space '<b>bold</b>' Character space $a $n $d Character space 
'<i>italic</i>' Character space $t $e $x $t Character space $a $n $d 
Character space $a Character space '<a>link</a>'))


More information about the Squeak-dev mailing list