evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

A block helper can return a string. It needn't be logged as a problem. #140

Closed eviltrout closed 10 years ago

eviltrout commented 10 years ago

My previous pull request to not surround HTML with paragraphs was not accepted. It contained this other fix which I think is still worth having on its own: JsonML supports strings of text, not just tags.

This patch changes the warning message to not complain when the text is a string either.

ashb commented 10 years ago

Trying to think if this breaks the JsonML format we've got (well makes it inconsistent) or not - in your previous PR for instance it could be 'fixed' by just doing return [ this.processInline(block) ] but my brain isn't working properly right now and I can't reason one way or another.

Anyone else care to weigh in?

eviltrout commented 10 years ago

I just tested it and the previous method also complained when I return [ this.processInline(block) ] without this patch.

ashb commented 10 years ago

Yeah that wouldn't work - its not a valid block in JsonML. I said my brain wasn't working right?

So I guess the question is should a block-level markdown element be able to return a string literal?

eviltrout commented 10 years ago

I think so, yes. It's rare but sometimes you just want to return a string without a tag. The renderer and everything works perfectly with it as far as I can tell in my tests with Discourse. The only issue seems to be the debugging message :)