如何在MongoDb中存储源代码示例,以便我可以正确显示它?

时间:2018-12-09 19:24:54

标签: javascript node.js mongodb express meanjs

全部! 我正在建立一个类似于MEAN体系结构中的StackOverflow的网站,用户可以在其中提交一些文本,其中包含富文本格式的字符串,但也可以包含代码片段。

目前,我正在使用以下模式将这些帖子的内容存储在我们的mongo库中:

{
    .
    .
    .
    content : String
    .
    .
    .
}

样本内容

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>

我如何将其存储在我的底座中并将其分散在我的玉器中,所以它在下面看起来像这样?


这是一些文本,其中一些也是粗体。 通常在输入格式化代码之前也有休息时间:

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

谢谢!

0 个答案:

没有答案