如何在数据库中存储轻量级格式化(Textile,Markdown)? [英] How to store lightweight formatting (Textile, Markdown) in database?

查看:417
本文介绍了如何在数据库中存储轻量级格式化(Textile,Markdown)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在我正在开发的项目中实现轻量级格式化语言(可能是Textile,也许是Markdown),我很想知道如何将它存储在数据库中。



如果用户能够编辑他们发布的内容,我认为原始的,未转换的标记被存储是有意义的,以便用户不必编辑HTML下一次。但是,由于内容将比编辑的要多得多,所以存储内容的转换副本也是有意义的,以便在每个页面视图上不必通过Textile发送原件。



那么,通常的做法是将原始和转换的内容并排存储在数据库中?有更好的方法吗?



谢谢!

解决方案:




  • 每次查看=转换

  • 每次编辑=无处理



存储html




  • 每个视图=无处理

  • 每次编辑=转换为markdown并返回



同时存储


$ b b

  • 每个视图=无处理

  • 每次编辑=在编辑后转换为html



您必须权衡处理成本与存储成本。


I'm going to be implementing a lightweight formatting language (probably Textile, maybe Markdown) in a project I'm working on, and I'm wonder how best to store it in the database.

If the user is able to edit the content they're posting, it makes sense to me that the original, non-converted markup be stored so that the user doesn't have to edit HTML the next time around. But since the content is going to be displayed a whole lot more than edited, it also makes sense to store a converted copy of the content so that the original doesn't have to be sent through Textile on every page view.

So, is the common practice to store both the original and converted content side-by-side in the database? Is there a better way?

Thanks!

解决方案

Store markdown:

  • Every view = conversion
  • Every edit = no processing

Store html

  • Every view = no processing
  • Every edit = convert to markdown and back

Store both

  • Every view = no processing
  • Every edit = convert to html after edit

You have to weigh up your processing costs vs. your storage cost.

这篇关于如何在数据库中存储轻量级格式化(Textile,Markdown)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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