Skip to content
Advertisement

How can I create bold and italic text etc… Like stackoverflow?

How would I create a post mechanism on my website like stackoverflow with bold text and italic text and other customization like that? Right now my php database has this table for posts :

JavaScript

I have stuff for files and text, but I don’t know how I would store the bold/normal text.

And how would I take in those inputs? For the moment I have this code to collect the information from the frontend and then put it in the database :

html code :

JavaScript

my javascript code :

JavaScript

Then I just have some basic php sql query to insert everything. I don’t know how to do this, and I also don’t know how to do the post images like stackoverflow does it. Do they create another row with a list of all the image descriptions? Thanks for answering! I know this is a long question!

Advertisement

Answer

The markup language used to set the formatting here on SO is called Markdown.

There is a variety of different JS libraries that can convert markdown text into HTML, which then can be inserted into your desired elements.

Here is an example using markedjs.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement