Should I convert stored Markdown to HTML, or should I just store HTML?

后端 未结 4 1794
闹比i
闹比i 2021-02-02 16:13

Markdown seems to be easier to write and edit than HTML. All HTML editors I\'ve seen output a ton of unnecessary junk. Markdown seems cleaner.

Here is what I\'m thinking

4条回答
  •  悲&欢浪女
    2021-02-02 16:57

    I recently completed a project very similar to what you are asking. Rather than store full-blown HTML in the database, I opted to store marked-down html on the filesystem using a proprietary API, much like MongoDB. The beauty of the storing marked-down vs full-blown is the foot-print on the filesystem is much smaller, and if you ever needed to view the raw markdown, it is much easier to read. When a user edits html, I render the full-blown so they can see what it looks like.

    There have been other suggestions of storing both, which I don't quite agree with. If you are looking to improve the performance by not having to markup the marked-down version for every request, then I would consider caching the full-blown version every-time it's edited. Storing both marked-down and full-blown defeats the purpose of marking-down, as you pay the penalty in disk-space and/or database ops.

提交回复
热议问题