Help me understand: the post cooking process

I would be very glad if someone could help me understand how the post cooking process works. Especially I am interested in this part:

why does post processing happen after the post got cooked already?
Maybe we can go through the process of what would need to be done to add a feature like oneboxes or “quotes of specific users” if it wouldnt exist yet. So I came accross Prettytext discourse/app/assets/javascripts/pretty-text at f9608c0af5f7b1109117a5aba979acb00c28cf9a · discourse/discourse · GitHub
which handles to- and from- markdown conversion and the rendering of the preview box. I also found the rebake function in the post model in the backend:

which calls the cook method of the postanalyzer:

this function runs the javascript markdown conversion in the backend

my thought was, that it is done this way so there is less code duplication, but then I discovered the


that I linked at the top. It seems like some processing is done in javascript only, while some of it is done in javascript and ruby as well in the CookedPostProcessor. So to summarize: 1.You need to have to and from markdown conversion rules (seems like its in javascript only) need to have some code to create the html(some of it javascript but some of it also ruby) I am interested to know why (2.) is done partly in javascript and partly in ruby. Maybe you can give me an example. I would also be very happy if you can correct false assumptions I made in this post.
Thaaaanks! :smiley:


To begin with, just see the js console network tab, to know what is captured on the frontend and passed to the server when a post is created. Which means that all of the data sent to the rails api are processed further by rails. Then in the posts table, you will see raw and cooked columns which tells you the unprocessed and processed form of the post.


Okay, thanks for your answer. I think I will just explore this piece by piece. I think maybe this “reason about it from first principles”-approach that I took does not work because this grew out of historical reasons.

1 Like