On Oct 5, 2010, at 5:05 PM, Pat Maddox wrote:
> I'm trying to do something which (I think) is very simple: I just want to run
> a line of text through Markdown and get the output.
>
> I've spent all day reading through the code for OSProcess and CommandShell.
> It took me a while, but I finally figured out I can run a command and get its
> output with:
>
> UnixProcess waitForCommandOutput: 'ls ~'
>
> The next problem I'm having is getting markdown to run on an arbitrary
> string. If I go into my shell and do:
>
> $ /usr/local/bin/markdown <<END
>> # This is a heading
>> This is a paragraph with _emphasis_
>> END
> <h1>This is a heading</h1>
>
> Then I get the output that I expect:
> <p>This is a paragraph with <em>emphasis</em></p>
>
> I can't figure out how to do this with OSProcess though. I've tried:
>
> UnixProcess waitForCommand: ('/usr/local/bin/markdown <<END
> hello world
> END')
>
> but with no luck. I've also tried using OSProcess at a lower level, setting
> up the stream input object, but it seems to require a reference to an actual
> file, rather than just a stream.
>
> Anyone have any ideas? I want to take an arbitrary string and use that as
> the input to my markdown command, and then store that output in an instance
> variable. I could use some help.
>
> Thanks,
> Pat
Okay I've got something which appears to work fine.
(OSProcess thisOSProcess command: '/usr/local/bin/markdown' input: '#this is a
heading
this is a paragraph _with emphasis_') output
Kind of a painful day, but glad to be moving on :)
Pat
_______________________________________________
Pharo-users mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users