I'm writing a small markdown editor for OS X. So far I can convert the markdown to HTML and get it appearing in my web view. What I haven't managed yet is to get syntax-highlighting up and running. I'm using kramdown
to do the markdown -> HTML bit, and its docs suggest that the highlighting can be accomplished with rouge or coderay. I've gone with rouge, but haven't had much success. Here's how I set up the task:
func newTask() -> NSTask {
var task = NSTask()
task.launchPath = "/usr/bin/kramdown"
task.arguments = [
"--syntax-highlighter", "rouge",
"--syntax-highlighter-opts", "{line_numbers : true, disable : false, default_lang : python}"]
var inPipe = NSPipe()
var outPipe = NSPipe()
task.standardInput = inPipe
task.standardOutput = outPipe
return task
}
And here's an example of my markdown:
~~~ ruby
def what?
42
end
~~~
When I run the task I don't get any error messages, and I can toggle line numbers using the arguments I pass to --syntax-highlighter-opts
, so I think the syntax of the arguments is correct, but something else clearly isn't - I can extract the html, but there's no syntax highlighting.