Working with different needs in raw/cooked content

pr-welcome

#1

I’m using only the API of Discourse with a custom UI.

I want to support some custom Markdown extensions which I’d like the “cooked” content of a post to honor. I think there are probably a few ways to do this:

  1. Get Discourse to use a custom Markdown parser
  2. When posting, convert the Markdown to HTML before submitting it to the Discourse API
  3. Getting access to the “raw” post in addition to the “cooked” post after it’s been submitted

1 won’t work for me if it requires a code change to Discourse, because I’d like to use the hosted version.
2 is fine, but we’re still largely limited by what gets “cooked”. For example, we may want to show some dynamic content.

Increasingly I think just getting access to the raw content of the original post (3) is probably what I want. Is there a way to do this? Can “cooking” content be disabled via a setting, or the “raw” content obtained via some API call?


Wiki sync plugin
(Sam Saffron) #2

What are the exact changes to md you are after?


#3

That’s not totally determined yet, but it’s likely that some content will be rendered dynamically which suggests we won’t want the “cooked” version to be static HTML.

I think what we really want is the ability to control what we’re cooking, since we obviously don’t want to throw away whatever sanitation work is done in the process. In our case, we’d probably want to convert “raw” markdown to “cooked” markdown (with whatever scrubbing/moderation happens in that process left intact).

I don’t know if this is on the roadmap or what the timeline is, but failing that, it would at least be useful to be able to get access to the “raw” submission content. Is this possible?


(Mittineague) #4

Something like this?

* open in new tab
https://meta.discourse.org/raw/46723


#5

Yes, but doing that for every post is going to get expensive. Ideally I want a way to get this off the topic API (t/:topicId.json)

BTW, how do you know about that route? Is there some better API documentation than this topic: Discourse API Documentation


(Mittineague) #6

I guess mostly because I’ve spent a lot of time here, I’ve read a lot of posts and I’ve read a good number of lines of code.

But also because when I was looking at how post revision history works (note the “raw” button) it could be seen (using the browsers dev tools) that a “raw” route was used.

Well, I don’t if it’s better. That’s subjective. But there’s this.


(Erlend Sogge Heggen) #7

This request has come up a couple of times now. @marktheis & co also wants this: