fix(epub): 修复生成 EPUB 后目录跳转错误 - #401
Open
AldenWangExis wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
我在本地用
make epub生成 EPUB 后发现,阅读器里的目录索引跳转不正确:点击多个章节目录项时,都会跳到首页附近,而不是对应章节正文。问题原因是 EPUB 构建时,pandoc 没有把 Hugo front matter 里的
title当作章节标题处理;同时网站目录页里的链接标题被写入了 EPUB TOC,导致目录项指向了目录页中的链接位置。检查生成结果时还发现,Hugo 的calloutshortcode 也会原样出现在 EPUB 正文里。本 PR 做了以下处理:
title转成真实的 H1。calloutshortcode 转成普通 Markdown 引用块。--split-level=1让 pandoc 按章节拆分 EPUB 正文。part-ii、part-iii在 EPUB 输入列表中的顺序。本地验证:
验证结果:EPUB 可以正常生成,正文已按章节拆分,目录项能跳转到对应章节,
nav.xhtml中没有缺失锚点,正文中也不再残留 Hugo shortcode。