同步发表于 Limitless Ping
使用 jekyll-feed
所产生的 feed.xml
出现 PCDATA invalid Char value 8 错误,造成解析失败。
原因
使用 RSS
消息来源订阅文章时,来源要产生一个描述档,让订阅器可以知道来源的资讯,这个描述档使用 XML version 1.0 的格式写成,你会看到类似下面这样的内容:
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" > <generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator> <link href="https://peterhpchen.github.io/feed.xml" rel="self" type="application/atom+xml" /> <link href="https://peterhpchen.github.io/" rel="alternate" type="text/html" /> <updated>2020-03-16T12:38:36+08:00</updated> <id>https://peterhpchen.github.io/feed.xml</id> <title type="html">Limitless Ping</title> <subtitle>Personal GitHub Page</subtitle> <entry> <title type="html">从 Blogger 迁移至 jekyll</title> <link href="https://peterhpchen.github.io/2020/03/15/jekyll-blogger-import.html" rel="alternate" type="text html" title="从 Blogger 迁移至 jekyll" /> <published>2020-03-15T00:00:00+08:00</published> <updated>2020-03-15T00:00:00+08:00</updated> <id>https://peterhpchen.github.io/2020/03/15/jekyll-blogger-import</id> <content type="html" xml:base="https://peterhpchen.github.io/2020/03/15/jekyll-blogger-import.html"> ... </content> <author> <name></name> </author> <category term="jekyll" /> <category term="blogger" /> <category term="github-page" /> <summary type="html">最近在迁移 Blogger 中的旧文章到 jekyll 的 GitHub page 上,本文纪录如何输出 Blogger 的文章并输入至 jekyll 中,并将原本 Blogger 的页面导至新的 jekyll 页面。</summary> </entry> ...</feed>
可以看到描述档中包含文章的内容,jekyll-feed
会自动由文章产生这个描述档,但是有些字元在 XML 中是非法的,像是这个错误中的 value 8 指的就是 U+0008
这个控制字元 Backspace 。
解法
只要把非法字元删除即可解决此问题,使用 Visual Studio Code 的 Search 功能将 Backspace 删去: