2025/02/12 追記
Vivliostyle CLIでVFM以外のunified Processorを使用できるように拡張されたため、現在ではそちらを利用したほうがシームレスに行えます。
過去の情報
ある程度詳細を指定してHTMLを出力できるマークアップ言語であれば何でもVivliostyleによるCSS組版フローに組み込めます。一例として、AsciiDocで書いてVivliostyleで組版する手順を紹介します。
AsciiDoctorではAsciiDocから直接PDFを出力することもできますが、HTMLを出力してVivliostyleを通せばさらに詳細な組版を行うこともできます。
> cmd /c ver
Microsoft Windows [Version 10.0.22631.3737]
> wsl tree .
.
├── Makefile
├── manuscript.adoc
├── manuscript.pdf
└── style.css
0 directories, 5 files
AsciiDocter、Vivliostyle CLIの他に、watchdogに付属するwatchmedoを使用しています。pipxでインストールしておくのがよいでしょう。
Makefile
MANUSCRIPT=manuscript
STYLESHEET=style.css
ifeq ($(OS),Windows_NT)
ifeq ($(SHELL),/bin/sh)
# MSYS2 make
RM=rm -f
BACKGROUND_PREVIEW=vivliostyle preview $(MANUSCRIPT).html &
else
# GnuWin32 make
RM=del /Q
# Press ctrl+c once (or twice), then y followed by enter to quit.
BACKGROUND_PREVIEW=powershell -Command "Start-Process -FilePath vivliostyle.cmd -ArgumentList 'preview $(MANUSCRIPT).html' -NoNewWindow"
endif
else
RM=rm -f
BACKGROUND_PREVIEW=vivliostyle preview $(MANUSCRIPT).html &
endif
.PHONY: all build-html build preview watch clean
all: build
$(MANUSCRIPT).html: $(MANUSCRIPT).adoc
asciidoctor \
--verbose \
--attribute stylesheet=$(STYLESHEET) \
--attribute last-update-label! \
--attribute lang=ja \
$<
$(MANUSCRIPT).pdf: $(MANUSCRIPT).html
vivliostyle build $< --output $@
build-html: $(MANUSCRIPT).html
build: $(MANUSCRIPT).pdf
preview: $(MANUSCRIPT).html
$(BACKGROUND_PREVIEW)
watchmedo shell-command \
--drop \
--patterns="*.adoc" \
--command="make build-html" \
.
clean:
$(RM) $(MANUSCRIPT).html $(MANUSCRIPT).pdf
make preview
を立ち上げておけば、おおもとのAsciiDocの変更に応じてVivliostyleのプレビューが更新されます。
GnuWin32 makeでのプレビューのバックグラウンド実行についてよい方法を知っていたら教えてください。