我应该将存储的Markdown转换为HTML,还是仅存储HTML? [英] Should I convert stored Markdown to HTML, or should I just store HTML?

查看:247
本文介绍了我应该将存储的Markdown转换为HTML,还是仅存储HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Markdown 似乎比HTML更容易编写和编辑.我见过的所有HTML编辑器都会输出大量不必要的垃圾. Markdown看起来更干净.

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.

这就是我要考虑的事情:将markdown存储在数据库中,然后使用 PHP Markdown ,然后将其输出到Web浏览器.

Here is what I'm thinking of doing: storing markdown in the database, converting it to HTML with PHP Markdown, then outputting that to the web browser.

一个问题是,每次 页面都必须执行此操作.这似乎有点贵.

One problem is that it would have to do this every time a page is requested. This seems somewhat expensive.

这是个好主意吗?还是有一种更有效的方法来做到这一点?

Is this a good idea? or is there a more efficient way to do this?

推荐答案

作为一个实际示例,Stack Overflow支持Markdown(如您所知),但是将两者和Markdown以及呈现的HTML存储在数据库.由于呈现的HTML始终是相同的,因此这使得提供页面的速度更快.帖子的创建频率比显示给用户的频率要低得多.

As a practical example, Stack Overflow supports Markdown (as you know), but stores both the Markdown and the rendered HTML in the database. This makes it much faster to serve pages, because the rendered HTML is always the same. Posts are created much less frequently than they are shown to users.

这篇关于我应该将存储的Markdown转换为HTML,还是仅存储HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆