为什么我需要Markdown? [英] Why do I need Markdown?

查看:132
本文介绍了为什么我需要Markdown?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我需要 Markdown 和前端编辑编辑器如 WMD ?降价对WMD编辑器发送的内容有什么作用?

Markdown如何将内容存储在后端?它是否像 * bold * 或其他格式一样?为什么我不能只做一个 html编码



对不起,如果我听起来很天真。

解决方案

退后一步,问一些更大的问题。 Markdown试图解决的问题是浏览器中丰富的编辑问题。考虑一下:在某些情况下,对于任何启用丰富文本的软件,它都必须以某种方式描述丰富程度,但可能是这样。



我们可以致电对丰富性的描述(我通过丰富性的描述,我的意思是这一段文本是粗体或这一段文本是一个超链接),我们可以将这种丰富性描述称为标记 - 它用meta标记文本richness。

富文本的实现可以采取两种方法,或者a。)将标记从用户隐藏或b)让他们访问标记。

对于那些选择隐藏它的人来说,最终的结果往往是所见即所得。用户无视幕后发生的事情。编辑器会照顾详细信息以MS Word为例,没有人将Word标记格式作为常规最终用户来操作。



对于选择公开标记的实现,标记语言是那么为了让用户互动它。例如,这样的标记语言就像HTML一样执行< tag> 或BB代码,像 [tag]

Markdown就是这些语言之一。



与前面提到的类型相反,Markdown已经试图设计自己,以便标记呈现通用的ASCII人已经使用。例如,人们通常会将其文本设置为off, * important * ,而Markdown中的这个表示法是一个斜体表示。



关于存储,正如斯蒂芬指出的那样,系统很可能会存储原始降价,因为用户很可能需要进行编辑,并且可以调用原始降价为了这个目的。

在我构建的大多数系统中,我存储了markdown,然后将其标准化为第二个字段,该字段缓存markdown的HTML呈现。这样我就不必为每个markdown字段进行markdown-> HTML呈现。它需要更多的空间,但我宁愿用户有更快的响应比使用更少的DB存储空间。



接受Markdown浏览器,因为它可以轻松包含需要过滤掉的< script> 标签。大多数降价实现还会识别与Markdown格式相混杂的HTML,因此为了安全起见,您需要确保您的输入和缓存已经过正确的消毒。


Why do I need a Markdown with a front edit editor like WMD? What does the markdown do to the content that’s sent from the WMD editor?
How does Markdown store the content in the backend? Is it the same way like *bold* or in some other format? Why can’t I just do an html encode?

Sorry if I sounded very naïve.

解决方案

It's probably helpful to take a step back and ask some of the larger questions. The issue Markdown is trying to solve is that of rich editing in the browser. Consider this: At some point, for any piece of software to enable rich text it has to describe the richness in a some manner, however that may be.

We could call that description of richness (by description of richness I mean like "this bit of text is bold" or "this bit of text is a hyperlink), we could call that description of richness "markup" -- it marks up the text with meta "richness".

Implementations of rich text can take on two approaches, either a.) hide the markup from the user or b.) let them have access to the markup.

For those who choose to hide it, the end result is very often WYSIWYG. The user is oblivious to what is happening behind the scenes. The editor takes care of the details. Think MS Word as an example. No one manipulates the Word markup format as a regular end user.

For implementations which choose to expose the markup, a markup language is then in order to allow users to interacat with it. Such markup languages would be things like HTML doing <tag> or BB code for example, doing things like [tag].

Markdown is one such of these languages.

As opposed to the former types I mentioned, Markdown has tried to design itself so that the markup renders common ASCII people already use. For example, it's common for people to asterisk their text to set it off, *important*, and this notation in Markdown is an indicator of italic.

In regards to storage, as Stephan pointed out, the system will most likely store the raw markdown, because the user will most likely need to have the possibility of editing, and the original markdown can be recalled for that purpose.

In most of the systems I've built, I store the markdown, and then normalize it to a 2nd field which caches the HTML rendering of the markdown. This way I don't have to do markdown->HTML rendering for every markdown field. It takes a little more space, but I'd rather the user have a faster response than use less DB storage space.

Care should also be taken when accepting Markdown from the browser, as it can easily contain <script> tags which need to be filtered out. Most markdown implementations will also recognize HTML intermingled with Markdown formatting, as so to be safe, you need to make sure your inputs and caches are sanitized properly.

这篇关于为什么我需要Markdown?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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