我如何知道我是否需要使用 Markdown 库?

发布于 2024-08-05 00:10:58 字数 517 浏览 7 评论 0原文

我发现很多 Github 项目都使用 Markdown。我最初认为只有像 StackOverflow 这样的网站才需要这个库,这些网站允许用户添加可能包含源代码片段的评论或帖子。但有些应用程序似乎使用 Markdown,即使情况并非如此。

Markdown 是一种轻量级标记 语言,最初由约翰创造 格鲁伯和亚伦·斯沃茨提供帮助 最大可读性和 其输入和内容的“可发布性” 输出形式。语言需要很多 现有公约的线索 在电子邮件中标记纯文本。 Markdown 转换其标记文本 输入到有效的、格式正确的 XHTML 和 替换左尖括号 ('<') 和 & 符号及其 对应的字符实体 参考文献。

目前我正在编写一个网络应用程序,其中包含用户添加评论的功能。我是否应该为此使用 Markdown - 即使注释不包含源代码?

I've been finding that a lot of Github projects use Markdown. I originally thought this library was only needed on sites like StackOverflow that include the ability for users to add comments or posts that might include source code snippets. But some apps seem to use Markdown even when this is not the case.

Markdown is a lightweight markup
language, originally created by John
Gruber and Aaron Swartz to help
maximum readability and
"publishability" of both its input and
output forms. The language takes many
cues from existing conventions for
marking up plain text in email.
Markdown converts its marked-up text
input to valid, well-formed XHTML and
replaces left-pointing angle brackets
('<') and ampersands with their
corresponding character entity
references.

Currently I'm writing a web app that includes the ability for users to add comments. Is it possible that I should be using Markdown for this - even if the comments do not contain source code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以往的大感动 2024-08-12 00:10:58

需要 Markdown 与能否包含源代码无关。它只是一种格式化文本的方法,采用简单的格式,甚至在格式化程序不可用时也可以读取。历史上,论坛软件为此使用BB代码,这对许多用户来说相当麻烦,并且不提供“可读”功能。

无论如何,在这种情况下,您需要问自己的问题是:您想让您的用户设置评论格式吗?如果是,您需要一些格式化库。那么 Markdown 可能是个好主意。无论如何,它与人们在纯文本环境中倾向于标记的方式一致,例如用星号或下划线围绕强调的文本。

这也是某种保护,因为它用实体替换了 HTML 标记,基本上可以防止脚本攻击。

Needing Markdown has nothing to do with being able to include source code. It's just a way to format text, in a simple format that is even readable when the formatter is not available. Historically, forum software used BB code for this, which is quite cumbersome for many users and does not offer the "readable" feature.

Anyway, the question you need to ask yourself, in this case, is: Do you want to enable your users to format the comments? If yes, you need some formatting library. Markdown may be a good idea then. It lines up with how people tend to markup in text-only environments anyway, like surrounding emphasized text with asterisks or underscores.

It's some sort of protection as well, since it replaces HTML markup with entities, basically preventing scripting attacks.

欢烬 2024-08-12 00:10:58

如果您希望用户能够输入粗体斜体文本,或包含链接到其他页面,那么提供 Markdown 支持是一个很好的方法。这是否是你想要支持的东西取决于你,但它很有用,IMO。

If you want your users to be able to enter bold or italic text, or include links to other pages, then providing Markdown support is a good way to do that. Whether that's something you want to support is up to you, but it's useful, IMO.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文