How to store source code samples in MongoDb, so I can display it correctly?

306 views Asked by At

all! I'm making a website similar to StackOverflow in the MEAN architecture, where users can submit some text, that contains stings of rich text, but can also contain snippets of code.

Currently, I'm storing contents of these posts in our mongo base, using a schema like this:

{
    .
    .
    .
    content : String
    .
    .
    .
}

A sample piece of content:

here is some text, <b> some of it is also bold.</b>
there are also breaks, usually before entering formatted code:
<pre> <code> here is some code
it
has to look
    formatted in the way the user posted it
</code> </pre>

how do I store it in my base and dispaly it in my jade, so it would look like this below?


here is some text, some of it is also bold. there are also breaks, usually before entering formatted code:

  here is some code
it
has to look
    formatted in the way the user posted it
 

Thank you!

0

There are 0 answers