【问题标题】:Jekyll for podcast/xml - processing changes tag cases and contentJekyll for podcast/xml - 处理更改标签案例和内容
【发布时间】:2016-07-19 20:50:28
【问题描述】:

我正在尝试使用 Jekyll 使用我的某些博客文章创建有效的播客提要。但是我在 Jekyll 更改某些 xml 标签的大小写和格式时遇到了麻烦

这是我为每个提要item 提供的模板:

    {% for post in site.posts %}
    {% if post.layout == "podcast" %}
    <item>
        <title>{{post.title}}</title>
        <description>
            {{post.title}}

            {{ post.overview | xml_escape}}
        </description>
        <content:encoded>
            {{post.title}}<br />
            {{ post.overview | xml_escape}}<br />
            {{ post.content }}
        </content:encoded>
        <guid>{{ site.url }}{{ post.url }}</guid>
        <link>{{ site.url }}{{ post.url }}</link>
        <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S GMT" }}</pubDate>
        <itunes:image href="{{ site.url }}{{ post.thumb }}" />
        <enclosure url="{{ post.mp3link }}" length="{{ post.length }}" type="audio/mpeg" />
    </item>
    {% endif %}
    {% endfor %}

相关部分是这两个标签:

<link>{{ post.url }}</link>
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S GMT" }}</pubDate>

在输出中,它们的输出如下:

<link />http://www.example.com/
<pubdate>Fri, 30 Oct 2015 00:00:00 GMT</pubdate>

链接似乎被格式化为 html 的 head 部分中的 link 标记,并且 pubDate 不再是驼峰式大小写,因此根据 rss 标准无效:https://validator.w3.org/feed/docs/rss2.html#hrelementsOfLtitemgt

是否需要传递某种标志或缺少某些功能?

其他标签正在处理中(图像、附件、guid 等)。

我正在使用:

  • 杰基尔 2.5.3
  • 红宝石 1.9.3p484
  • Linux Mint 17

【问题讨论】:

    标签: ruby jekyll


    【解决方案1】:

    您一定是在其他地方破坏了 XML。请发布完整的文件,否则很难非常具体。

    这是我的:

    播客:

    <pubDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S GMT" }}</pubDate>
    <link>{{ site.url }}</link>
    

    播客剧集:

    <link>{{ site.url }}{{ post.url }}</link>
    <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S EST" }}</pubDate>
    

    【讨论】:

    • 我更新了问题的更多细节。但是 Jekyll 在输出文件中改变的只是这两个标签。文件/提要的其余部分是有效的。一般来说,Jekyll 会尝试“修复”标签的大小写,但 pubDate 是那里唯一的驼峰式标签,它解释了为什么它被更改为 pubdate。想知道是否有一个标志或配置问题我可以通过来防止这种情况,在文档中没有找到它至于link 标签,我不确定为什么会这样。
    猜你喜欢
    • 1970-01-01
    • 2018-03-29
    • 2014-12-25
    • 2013-10-10
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多