Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toc.html generation option #66

Closed
MurakamiShinyu opened this issue Jul 26, 2020 · 1 comment
Closed

toc.html generation option #66

MurakamiShinyu opened this issue Jul 26, 2020 · 1 comment

Comments

@MurakamiShinyu
Copy link
Member

MurakamiShinyu commented Jul 26, 2020

vivliostyle.config.js の toc: true により目次のHTMLファイル toc.html が生成されて、それが manifest.json の readingOrder の先頭項目になります。
これにより、組版される文書の先頭に目次がつきます。

現状(CLI 3.0.0-pre.2 で確認)の目次HTMLファイル生成には次の問題があるため、あまり有用ではありません:

  • 目次のHTMLにthemeのスタイルシートが適用されない(<link rel="stylesheet"...> がない)。
    • 目次のスタイルを指定できない。
    • 本のページサイズなどがテーマのCSSの @page { size: } で指定されている場合、目次ページに適用されない。

以下、改善案:

  • <link href="テーマの.css" rel="stylesheet"> を出力する
  • 生成されるHTMLファイルは出版物のトップのHTML(Web Publicationの primary entry page)ということになるので
    • デフォルトのファイル名は "index.html" のほうがよい
    • HTMLの title と h1 見出しには出版物のタイトルがあったほうがよい

例:

<html lang="ja">
<head>
<title>本のタイトル</title>
<link href="manifest.json" rel="manifest" type="application/webpub+json">
<link href="theme.css" rel="stylesheet">
</head>
<body>
<h1>本のタイトル</h1>

<nav id="toc" role="doc-toc">
<h2>目次</h2>
<ul>
  <li><a href="chapter1.html">第1章</a></li>
  <li><a href="chapter2.html">第2章</a></li>
</ul>
</nav>
</body>
</html>
@uetchy
Copy link
Member

uetchy commented Jul 30, 2020

<link href="テーマの.css" rel="stylesheet"> を出力する

👍 良いですね!こちらは比較的小さなバグです。

もう一つの問題についてですが、現状のtoc: trueではオーダーが強制的に最初になってしまい、例えば表紙やprefaceの後に目次を置きたいなどのコントロールが出来ないので修正が必要です。
アイディアとして、例えばvivliostyle.config.jsentryにToC用のidentifierを定義し、その位置にtoc.htmlを差し込めるようにすると自由度が上がります。その場合はタイトルは不要ですが、<h2>目次</h2>はあったほうが良いでしょう(言語はlanguageによって変わるようにする)。もしそのような仕様にする場合は、tocオプションを廃止して、目次identifierがentryに存在した時点で自動で目次を生成した方が自然ですね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants