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 custom unified processor in vivliostyle.config.js #526

Conversation

Mura-Mi
Copy link
Contributor

@Mura-Mi Mura-Mi commented Oct 4, 2024

fix #124

vivliostyle.config.js に documentProcessor 属性を追加し、これが設定されている場合はMarkdownをHTMLに変換する処理をこの関数が生成する unified Processor とするようにしました。また、この機能を活用した example を追加しました。

実装する上で以下が気になったので、レビューいただけると幸いです。

  • Unified プラグインが新しいものだと、async/await 対応されているので、processor.processSync ができないことがありました。markdown.tsprocessMarkdown 関数を呼んでいる箇所は async だったので、processMarkdown も async 化しました。
  • テスト
    • MergedConfig に関数がそのまま残るケースは今回が初のようです(toc 属性の関数は MergedConfig を構築する際に呼び出され、MergedConfig の属性としては残らない)。MergedConfig のスナップショットテストは documentProcessor 属性が関数であることしか確認できませんので、一旦 snapshot の expected を編集しています。この方針で問題ないでしょうか。
    • その他、今回の変更に合わせたテストをどうすればよいかわからないのでご教示いただけると助かります。
  • コミット時に pretty-check が失敗していました。対処のために pretty-quick のバージョンを上げました
  • 命名など: DocumentProcessorFactory ちょっと重苦しい漢字の名前ですが違和感ないでしょうか

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@spring-raining spring-raining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRありがとうございます! srcとtestsの変更はこちらの実装方針で大丈夫です。

Comment on lines 3 to 14
description

> created by [create-book](https://github.com/vivliostyle/create-book).

## References

- VFM <https://vivliostyle.github.io/vfm/#/vfm>
- Vivliostyle CLI <https://github.com/vivliostyle/vivliostyle-cli#readme>
- Vivliostyle Themes <https://github.com/vivliostyle/themes#readme>
- Awesome Vivliostyle <https://github.com/vivliostyle/awesome-vivliostyle#readme>
- Vivliostyle (GitHub) <https://github.com/vivliostyle>
- Vivliostyle <https://vivliostyle.org>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらのexampleの説明を追加してもらえますか?

@@ -0,0 +1,130 @@
# Logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このgitignoreの内容は他のexampleと同様に以下のように変更してもらえますか?

/publication.json
package-lock.json
yarn.lock
pnpm-lock.yaml

また、このgitignoreの変更に合わせて以下のファイルはgitの管理から削除してください。

  • package-lock.json
  • publication.json

@Mura-Mi Mura-Mi requested a review from spring-raining October 5, 2024 09:36
Copy link
Member

@spring-raining spring-raining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良さそうです。ありがとうございます!

@spring-raining spring-raining merged commit 4a79a07 into vivliostyle:main Oct 5, 2024
1 check passed
@Mura-Mi Mura-Mi deleted the issue-124-support-custom-unified-processor branch October 5, 2024 13:03
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.

Provide feature that changing Markdown processor to other than VFM
3 participants