描述和内容之间的区别:RSS2 中的编码标签

发布于 2024-12-01 22:20:25 字数 192 浏览 2 评论 0原文

RSS 2.0 格式规范中的 标记和 标记之间有何区别(如果有)?

其中一个比另一个更重要吗?

我应该在我的 Feed 中同时使用这两种方法还是一种就足够了?

What is the difference, if any, between the <description> tag and the <content:encoded> tag in RSS 2.0 format specifications?

Is one more important than the other?

Should I be using both in my feeds or one will suffice?

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

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

发布评论

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

评论(4

無心 2024-12-08 22:20:25

标签用于帖子摘要,但仅限于纯文本。没有标记。

如果您转义标签或将内容包装在:

<![CDATA[ post body goes <strong>here</strong> ]]>

但是 你真的不应该这样做

如果您想要标记,则应该使用 并使用 ]]> 包装器在这里。

content:encoded 元素可以与 description 元素结合使用,以提供项目的完整内容以及较短的摘要。在这种方法下,项目的完整文本显示在 content:encoded 中,摘要显示在 description 中。

###RSS 最佳实践简介:内容:编码

简而言之, 代表 摘要和帖子的其余部分位于 中。

由于某些读者可能不支持预期的标签,因此您通常会在 中看到整个帖子,而不是两者的混合。

The <description> tag is for the summary of the post, but in plain text only. No markup.

You can get around that if you escape the tags or wrap the content in:

<![CDATA[ post body goes <strong>here</strong> ]]>

But you're not really supposed to be doing that.

If you want markup, you're supposed to use <content:encoded> and use the <![CDATA[ and ]]> wrappers here.

The content:encoded element can be used in conjunction with the description element to provide an item's full content along with a shorter summary. Under this approach, the complete text of the item is presented in content:encoded and the summary in description.

###RSS Best Practices Profile: content:encoded

In short, <description> is for the summary and the rest of the post is in <content:encoded>.

Since some readers may not support the tags as expected, you usually see the entire post in <description> and not a mix of the two.

清引 2024-12-08 22:20:25

之前的答案是不正确的。

RSS 2.0 规范非常清楚,您可以对的值进行编码。元素。

一个项目本身也可能是完整的,如果是这样,则描述
包含文本(允许使用实体编码的 HTML;请参阅示例),并且
链接和标题可以省略。项目的所有元素都是
可选,但必须至少包含标题或说明之一
存在。

The previous answer is incorrect.

The RSS 2.0 spec is very clear that you can encode the value of the <description> element.

An item may also be complete in itself, if so, the description
contains the text (entity-encoded HTML is allowed; see examples), and
the link and title may be omitted. All elements of an item are
optional, however at least one of title or description must be
present.

゛清羽墨安 2024-12-08 22:20:25

@random 给出的答案有一定道理,但最终情况很复杂(如果不令人困惑的话),如 RSS 2.0 规范,在决定如何处理 description 而不是 / 或在其他时候与 content:encoded 一起处理时>。

TLDR:当内容制作者愿意同时包含文本摘要和更完整的内容时,情况就解决了:使用 description 获得更简单的文本摘要,并使用 content:encoded< /code> 以获得更完整的 html 内容。但是,当他们只想包含两者之一(仅包含摘要或仅包含更完整的内容)时,则应该使用 description 标签,在这种情况下,事情仍然不明确!在我看来,这是一个最不幸的决定,这意味着您必须包含更完整的 html 内容才能清楚地了解这一点,否则, description 标签将一如既往地含糊不清。

不想在 Feed 中使用 item 摘要的发布商应该使用 description 元素来表示项目的完整内容,而不是 content:encoded 因为它拥有最广泛的支持。

使用摘要的发布商应将摘要存储在描述中,将完整内容存储在 content:encoded 中,在 item 中首先对 description 进行排序。对于没有摘要的项目,完整内容应存储在 description 中。

人们必须慢慢思考这一切的含义,但我认为这些是要点:

  1. 如果只给出这两个标签之一,则它必须是描述< /代码> 标签。
  2. 这意味着如果没有将 description 标签放置在其旁边(实际上是在其上方),则 content:encoded 永远不应该存在。
  3. 不幸的是,这意味着当只有一个标签(必须是 description)时,情况仍然像以前一样模棱两可:即 description 仍然是一个简单的文本摘要,或者更完整的html内容,你不可能知道!
  4. 当两者都给出时,这是唯一一次消除歧义:那么 description 应该是一个更简单的摘要,而 content:encoded 将包含更完整的 html 内容。

或者也许我读错了。

我个人认为这个决定是非常不幸的。显然,他们这样做是为了保持向后兼容性,因此当时的读者总是能够读取一些描述(因为尚不支持 content:encoded,或者不广泛)。但这样做,他们基本上阻碍了这一点。现在一切都已经过去了,但我认为他们本可以做的,在两全其美的同时,向 description 添加一个属性,例如: .因此,如果 (请注意,他们指定 content:encoded 对于更完整的 html 内容始终),那么它指定description 只是一个更简单的摘要,生产者不必也提供完​​整的内容以便读者了解此标签的类型。而老读者可能会忽略这个额外的属性。桥下流水,但我们可以梦想。

因此,就目前情况而言,在我看来一切都完全悬而未决,**除非*包含两个标签,只有这样你才能做出正确的假设。

PS 至于完整内容和摘要内容的区别,请参见他们的原来的讨论< /a> 在 description 标签上。

The answer given by @random has some truth to it, but ultimately the situation is complex (if not confusing), as specified within the RSS 2.0 spec, when deciding how to handle description instead of / or at other times alongside of content:encoded.

TLDR: When a content producer is willing to include BOTH a textual summary AS WELL as fuller content, then the situation is cleared up: Use description for the simpler textual summary, and content:encoded for the fuller html content. But when they only want to include one of the two, only summary or only fuller content, then they are SUPPOSED to use the description tag for this, in which case things remain ambiguous! A most unfortunate decision in my estimate, it means you HAVE to include fuller-html content to have clarity on this, otherwise, the description tag is just as ambiguous as ever.

Publishers who don't want to employ item summaries in their feeds SHOULD use the description element for an item's full content rather than content:encoded because it has the widest support.

Publishers who employ summaries SHOULD store the summary in description and the full content in content:encoded, ordering description first within the item. On items with no summary, the full content SHOULD be stored in description.

One has to slow-cook meditate on what this all meant, but I think these are the take-away points:

  1. If only one of these two tags is given, it MUST be the description tag.
  2. That means content:encoded SHOULD NEVER exist without a description tag placed alongside (and actually above) it.
  3. Unfortunately this means that when there is only one tag (which must be description), that the situation remains as ambiguous as ever: I.e. description continues to be EITHER a simple textual summary, OR a fuller html content, you can't know!
  4. When BOTH are given, that's the only time the ambiguity is removed: Then description should be a simpler summary, and content:encoded will container fuller html content.

Or maybe I read this all wrong.

Personally I think this decision was very unfortunate. They obviously did this to keep backwards compatibility, so readers at the time would be able to always have some description to read from (since content:encoded was not yet supported, or not widely). But in so doing, they basically handicapped this. It's water under the bridge by now, but I think what they could have done, while getting the best of both worlds, was to add an attribute to description like: <description type="html | text">. So if <description type="text"> (note they specify content:encoded is always for fuller html content) then it's specifying description is just a simpler summary, and the producer does NOT have to also give full-content in-order for readers to know the type of this tag. While older readers would have just ignored this extra attribute. Water under the bridge, but we can dream.

So as it stands, it seems to me everything is completely up in the air, **unless* BOTH tags are included, only then can you make the right assumptions.

P.S. As for the distinction between full content and summary content, see their original discussion on the description tag.

平生欢 2024-12-08 22:20:25

我应该在我的 Feed 中同时使用两者还是其中一个就足够了?

我测试了流行的播客客户端(2024 年),这些是我的结果。这并没有解决协议规定应该做什么,而只是解决了实践中实际要做的事情。

请注意,我没有尝试所有的组合。如果其他人尝试过其他组合,请随时将它们添加到我的表中(或作为评论)。特别是,我的播客软件不允许我不使用 ,因此我没有单独测试 会发生什么。

的客户端测试标签显示了使用 显示了吗?
Spotify(Android 和 Web)N/A
Spotify(Android 和 Web)& <描述>是的,在剧集本身中是的,在剧集列表中
Pocket Casts (Android)、
AntennaPod (Android)
N/A
Pocket Casts (Android)、
AntennaPod (Android)
<代码><内容:编码> & <描述>
podcasts.apple.com、
podcastaddict.com、
tunein.com、
music.amazon.ca
(没有尝试)(没有尝试)
podcasts.apple.com、
podcastaddict.com、
tunein.com、
music.amazon.ca
<内容:编码> &noyes

主要要点是:

  1. 不同的播客客户端以不同的方式处理这些标签。
  2. 如果您同时使用两者,您实际上并不知道用户实际上会看到什么。
  3. 如果您单独使用 ,用户将会看到它(至少这是我在有限测试中看到的

因此,我的建议是:

  • 仅使用 标签
  • 使用这两个标签,但在每个标签中放入相同的内容(这样你就知道用户会看到什么)

就我个人而言,我会选择单独 因为我想在我的内容中添加 HTML 格式。

Should I be using both in my feeds or one will suffice?

I tested popular podcast clients (in 2024) and these are my results. This does not address what the protocols state should be done, but only what is actually done in practice.

Note that I didn't try all combinations of things. If someone else has tried other combinations, feel free to add them to my table (or as a comment). In particular, my podcasting software doesn't allow me to not use <content:encoded>, so I didn't test what happens with <description> alone.

client(s) testedtags used<content:encoded> shown?<description> shown?
Spotify (Android & Web)<content:encoded>yesN/A
Spotify (Android & Web)<content:encoded> & <description>yes, within episode itselfyes, in episodes list
Pocket Casts (Android),
AntennaPod (Android)
<content:encoded>yesN/A
Pocket Casts (Android),
AntennaPod (Android)
<content:encoded> & <description>noyes
podcasts.apple.com,
podcastaddict.com,
tunein.com,
music.amazon.ca
<content:encoded>(didn't try)(didn't try)
podcasts.apple.com,
podcastaddict.com,
tunein.com,
music.amazon.ca
<content:encoded> & <description>noyes

The main takeaways are:

  1. Different podcast clients handle these tags differently.
  2. If you use both, you don't really know what your users will actually see.
  3. If you use <content:encoded> alone, users will see it (at least that's what I saw in limited testing)

Thus, my suggestion is either:

  • use only the <content:encoded> tag
  • use both tags, but put the same content in each (so you know what users will see)

Personally, I'm going with <content:encoded> alone because I want to put HTML formatting in my content.

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