vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Streaming functionality? #106

Closed txdv closed 12 years ago

txdv commented 12 years ago

Are there any plans for streaming functionality?

I have encountered something as what I perceived was a bug: I had a list like this:

  1. a very long sentence

My program was reading chunks out of a file and rendered them immediately.

while (r = read(512)) {
  sd_markdown_render(output_buffer, r, 512);
}

Unfortunately a chunk ended right in a list element, so afterwards I got an output looking like that:

[list] [il]a very lo[/il] [/list]

(some spaces) ng sentence.

So I realized that I have to read the entire file instead of rendering chunk-wise, which is not the best approach if you are writing for example streaming applications in node.js.

Streaming functionality would come in handy in many scenarios. Are there any plans, to do that?

vmg commented 12 years ago

Markdown has ambiguous syntax that cannot be parsed through streaming. You need the full document to make sense of it, meaning unlimited backtrack and lookeahead. There is no way this can be implemented. Sorry!

txdv commented 11 years ago

I just took a look on the yajl parser, I think that you need unlimited backtrack and lookahead for parsing json as well, but somehow it managed to cope with it. Is there something I am missing?