英文:
Ruby has problem with single file trying to parse YAML (frontmatter) from Jekyll project
问题
在大多数文件中,我成功地使用以下代码解析了前置元数据:
YAML.load_file(stringForFilePath, permitted_classes: ['Date'])
但在一个文件上,我收到了以下错误:
控制字符不允许在第1行第1列 (Psych::SyntaxError)
我尝试过以下方法:
- 将前置元数据/YAML 放入验证器中检查错误。
- 删除整个前置元数据,然后放入一个基本的存根。
- 检查文件编码(UTF-8,与其他正常工作的文件相同)。
- 检查行结束符(CLRF,与其他正常工作的文件相同)。
- 从文件中删除所有非ASCII字符(例如HTML,在前置元数据中没有)。
英文:
So I am successfully parsing frontmatter with
YAML.load_file(stringForFilePath, permitted_classes: ['Date'])
on a whole bunch of files except on a single file I get this error:
control characters are not allowed at line 1 column 1 (Psych::SyntaxError)
Things I have tried:
- Putting the frontmatter / YAML in a validator to check for errors
- Deleting the entire frontmatter and put in a basic stub in its place.
- Checked the file encoding (UTF-8 same as other files that are working)
- Checked the line endings (CLRF same as other files that are working)
- Removing every non-ASCII character from the file (e.g. the HTML, there was none in frontmatter)
答案1
得分: 0
问题出在我的HTML正文中有一个不可打印/不可见的控制字符,非常难以追踪。我尝试了一些第三方工具,它们没有检测到它,直到我更新了我的文本编辑器,我才终于能够找到它。
英文:
Problem was with a non-printing/invisible control character in my HTML body that was very hard to track down. Some 3rd party tools I tried didn't pick it up and it wasn't until I updated my text editor was I finally able to find it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论