Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
- BlockWare
-
100+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
I am planning on making an HTML app that allows users to design forum posts the same simple way a user might create a Word document. It wouls be a lot easier for me if I understood what script reads the code of a post and returns what the post is supposed to look like.
Sorry if I am not being clear, and thanks for reading!
Note: If it is a PHP/backend script, only ST will be able to answer, I think.
Sorry if I am not being clear, and thanks for reading!
Note: If it is a PHP/backend script, only ST will be able to answer, I think.
- WooHooBoy
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
if you want the bbcode source https://scratch.mit.edu/discuss/post/1824006/source/
https://scratch.mit.edu/discuss/post/[post number]/source/
https://scratch.mit.edu/discuss/post/[post number]/source/
- BlockWare
-
100+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
https://scratch.mit.edu/discuss/post/1824006/source/That is definitely helpful, though not what I was looking for (my first post wasn't very clear). if you want the bbcode source
https://scratch.mit.edu/discuss/post/[post number]/source/
I'm looking for the script(s) that process(es) BBCode and then outputs a forum post.
- blob8108
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
Have a look at `convert_text_to_html` in https://github.com/LLK/s2forums/blob/master/djangobb_forum/util.py –that's part of the source code for the forums.
Alternatively, maybe you want to look at the postmarkup library the forums use to parse BBCode?
Alternatively, maybe you want to look at the postmarkup library the forums use to parse BBCode?

- BlockWare
-
100+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
https://github.com/LLK/s2forums/blob/master/djangobb_forum/util.py –that's part of the source code for the forums.Thanks! (I can follow the link due to my school's overprotective Internet filter) But where would I find the postmarkup library? Have a look at `convert_text_to_html` in
Alternatively, maybe you want to look at the postmarkup library the forums use to parse BBCode?
- blob8108
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
You can also find that by searching GitHub: where would I find the postmarkup library?https://github.com/frol/postmarkup
- BlockWare
-
100+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
Thanks!You can also find that by searching GitHub: where would I find the postmarkup library?https://github.com/frol/postmarkup
- Jonathan50
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
ಠ_ಠ I can follow the link due to my school's overprotective Internet filter
But where would I find the postmarkup library?https://code.google.com/archive/p/postmarkup/
- jTron
-
100+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
You asked how the preview button works—here's from a front-end perspective:
When you click the preview button your browser POSTs to https://scratch.mit.edu/discuss/preview/ with data={bbcode}. The response, it looks like, is actually pretty gnarly considering (couldn't they just send back the html?) but you basically get a huge mess of <link>s, inline css, scripts (jquery, scratchblocks2 + translations), inline js (module headerey and other type stuff at the top, then it looks like for scratchblocks near the bottom), and, somewhere in all this, your actual post (innerHTML of `.post_body_html`).
For this post so far hitting “preview” sets you back about 7.4KB (3.6 gzipped) (+252.5/79 the first time for all the linked cruft) which seems like quite a bit for just previewing a bit of text…
When you click the preview button your browser POSTs to https://scratch.mit.edu/discuss/preview/ with data={bbcode}. The response, it looks like, is actually pretty gnarly considering (couldn't they just send back the html?) but you basically get a huge mess of <link>s, inline css, scripts (jquery, scratchblocks2 + translations), inline js (module headerey and other type stuff at the top, then it looks like for scratchblocks near the bottom), and, somewhere in all this, your actual post (innerHTML of `.post_body_html`).
For this post so far hitting “preview” sets you back about 7.4KB (3.6 gzipped) (+252.5/79 the first time for all the linked cruft) which seems like quite a bit for just previewing a bit of text…
Last edited by jTron (March 2, 2016 00:58:09)
- -Io-
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
The preview sends you back the whole page that needs to go into the preview iframe. Also, the <link>s are for the css needed, since they use stuff like class=“bb-bold” You asked how the preview button works—here's from a front-end perspective:
When you click the preview button your browser POSTs to https://scratch.mit.edu/discuss/preview/ with data={bbcode}. The response, it looks like, is actually pretty gnarly considering (couldn't they just send back the html?) but you basically get a huge mess of <link>s, inline css, scripts (jquery, scratchblocks2 + translations), inline js (module headerey and other type stuff at the top, then it looks like for scratchblocks near the bottom), and, somewhere in all this, your actual post (innerHTML of `.post_body_html`).
For this post so far hitting “preview” sets you back about 7.4KB (3.6 gzipped) (+252.5/79 the first time for all the linked cruft) which seems like quite a bit for just previewing a bit of text…
- Dylan5797
-
1000+ posts
What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?
I wrote one, it's way smaller. It works but doesn't generate HTML, it returns an abstract syntax tree.
Perfect for spam checking
https://github.com/Dylan5797/BBCodeParser/blob/master/BBCodeParser.py
Perfect for spam checking

https://github.com/Dylan5797/BBCodeParser/blob/master/BBCodeParser.py
- Discussion Forums
- » Advanced Topics
-
» What script turns the BBCode into a readable forum post (how does the 'Preview' button work)?