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

Support EPUB/pub-manifest input formats #110

Merged
merged 6 commits into from Jan 25, 2021

Conversation

spring-raining
Copy link
Member

@spring-raining spring-raining commented Jan 23, 2021

About

closes #63

This pull request adds supporting the input of EPUB (.epub, .opf), Publication manifest (.json). Also, publication manifests generated by Vivliostyle CLI will be set valid encodingFormat for XHTML inputs.

@spring-raining spring-raining changed the title feat: Support various input formats Support EPUB/pub-manifest input formats Jan 24, 2021
@spring-raining spring-raining marked this pull request as ready for review January 24, 2021 10:29
@spring-raining
Copy link
Member Author

このPRによりこちらの問題も解消されます。 #107 (comment)

@MurakamiShinyu
Copy link
Member

EPUBサポートもできてすばらしいです。

以下、テストして気がついた点です。(これらは別のissue/pullreqで対応予定かとも思いますが)

"Exporting webbook format from EPUB or OPF file is not supported." なのに "Built successfully."

$ vivliostyle build epubdir/EPUB/package.opf -f webbook -o wbdir
◡ Collecting build config
Exporting webbook format from EPUB or OPF file is not supported. Skipping.
🎉 Built successfully.

EPUBにユーザースタイルシートを指定することができない

EPUBを組版する場合、ユーザースタイルシートを指定したい(ノンブルや柱をつける、ページ余白を調整、大きな画像をページ内に収める、などのために必要)。
--theme オプションでスタイルシートを指定できるかと考えて次のように指定したが、--theme 指定は無視されるようだ:

$ vivliostyle build epubsample.epub --size A5 --theme epubstyle.css -o output.pdf

--theme オプションは markdown から HTML に変換するときに HTML に <link rel="stylesheet" ...> を入れるためのもので、markdown以外のinputの場合には無視するというのは理解できる。その場合、--theme オプションとは別にCSS組版用のスタイルシートを vivliostyle/core に渡すオプションが必要。

Vivliostyle Viewer では style= で追加スタイルシート、 userStyle= でユーザースタイルシートの指定が可能。それと同様のことがCLIでもできるとよい。
参考: https://docs.vivliostyle.org/#/user-guide#additional-style-sheets

input が HTML ファイルの場合に一時ファイルの生成は不要ではないか

build および preview コマンドで、コマンドラインで指定する input がひとつの HTML ファイルの場合、その HTML ファイルが存在するディレクトリに一時ファイルが生成されるようです。

たとえば input が "index.html" の場合、.vs-1611552228310.publication.json のような pub-manifest ファイルと、.vs-1611552228310.index.html のような HTML ファイルが生成されます。 HTMLファイルのほうは、元の input と内容が同一の単なるコピーのようです。

inputがmarkdownである場合は、HTMLファイルへの変換を伴うので一時ファイルの生成が必要なのは分かりますが、inputがHTMLファイルの場合は不要でないでしょうか。次の問題があります:

  • input の HTML ファイルが書き込みができないディレクトリにある場合にエラーになる
  • input が file でも Web の URL でも同じように処理するということができない

また、 Error: Could not parse CSS stylesheet (#105) の問題も、不必要に HTML ファイルの内容をチェックしていることと関係ありそうです。

pub-manifest ファイルを使わない WebBook などのために --book オプションが必要

WebBook support in v3 (#64) で、pub-manifestの.jsonファイルを指定することのほか、pub-manifest ファイルを使わない WebBook の HTML ファイルを指定できるように、Book mode (--book option) を復活させる提案をしています。
このオプションが指定された場合 input のURLをそのまま vivliostyle/core の CoreViewer.loadPublication() に渡すとよいと思います。そうすると次のように処理されます:

  • input が epub-unzipped のディレクトリなら EPUB コンテンツとして処理
  • HTML内のmetaタグでpub-manifestが指定されていたらそれを使用
  • pub-manifest無しの場合、HTML内の目次をpub-manifestの代わりに使用

@spring-raining
Copy link
Member Author

どれも問題だと認識していますが、今回のPRでは手に余りそうなので一旦マージしてしまいます。

ちなみに、

build および preview コマンドで、コマンドラインで指定する input がひとつの HTML ファイルの場合、その HTML ファイルが存在するディレクトリに一時ファイルが生成されるようです。

この動作は、将来 --theme オプションに対応させる際にlinkタグの埋め込みが必要になるため一時ファイルを作成する実装になっています。

@spring-raining spring-raining merged commit b58dcf0 into develop Jan 25, 2021
@spring-raining spring-raining deleted the feat/various-input-format branch January 25, 2021 15:44
@MurakamiShinyu
Copy link
Member

@spring-raining

この動作は、将来 --theme オプションに対応させる際にlinkタグの埋め込みが必要になるため一時ファイルを作成する実装になっています。

--theme オプションが指定されているときだけその動作になるとよいと思います。

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

Successfully merging this pull request may close these issues.

None yet

2 participants