[squeak-dev] Markdown for Squeak

Ramon Leon ramon.leon at allresnet.com
Tue Aug 26 04:12:00 UTC 2008


> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org 
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On 
> Behalf Of Benjamin Pollack
> Sent: Monday, August 25, 2008 7:30 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: [squeak-dev] Markdown for Squeak
> 
> Has anyone ever written a Markdown engine for Squeak? I was 
> unable to find anything that looked promising on SqueakSource 
> or in the 3.10 Universe, but I'm having a difficult time 
> believing no one's ever written one before.
> 
> Thanks,
> --Benjamin

Why bother?  Just shell out to Markdown.pl with OSProcess.  Markdown is a
big ball of complex regex and I don't think Squeak's regex support fully
supports everything Pearl's does.  Add this extension to UnixProcess class
side

pipeString: aString throughCommand: aCommandString 
    | pipe1 pipe2 input output src dest child result delay |
    pipe1 := OSPipe blockingPipe.
    pipe2 := OSPipe nonBlockingPipe.
    input := pipe1 reader.
    output := pipe2 writer.
    src := pipe1 writer.
    dest := pipe2 reader.
    child := self forkJob: aCommandString arguments: nil environment: nil
descriptors: {  input. output. nil  } .
    input close.
    output close.
    src nextPutAll: aString.
    src close.
    delay := 10 milliSeconds asDelay.
    [ child isComplete ] whileFalse: [ delay wait ].
    result := dest upToEnd.
    dest close.
    child sigterm.    "Tell the child to exit"
    ^ result withSqueakLineEndings 

Then you can just do ...

    UnixProcess pipeString: someContent throughCommand: 'Markdown.pl'

And you're good to go, assuming you've put Markdown.pl in your images
directory.

Ramon Leon
http://onsmalltalk.com




More information about the Squeak-dev mailing list