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
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev-bounces@lists.squeakfoundation.org] On Behalf Of Benjamin Pollack Sent: Monday, August 25, 2008 7:30 PM To: squeak-dev@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
I think most people who need markdown write their own parser by hand. I'm pretty sure you can't make a correct Markdown parser with regular expressions, and if you use a parser framework it needs to be pretty powerful. In Squeak, I think Ometa would work well; I don't know if MEPS could do it.
If it helps, here are some (non-Squeak) markdown parser experiments:
http://joyful.com/darcsweb/darcsweb.cgi?r=markdown;a=summary
squeak-dev@lists.squeakfoundation.org