当多个 Markdown 文件中的任何一个发生更改时,我正在尝试使用 Makefile 来编译 PDF:
# Compile report
source := draft
output := dist
sources := $(wildcard $(source)/*.md)
objects := $(patsubst %.md,%.pdf,$(subst$(source),$(output),$(sources)))
all: $(objects)
report-print.md: $(source)/%.md
cat draft/*.md | pandoc \
--variable geometry:a4paper \
--number-sections \
--toc \
--f markdown \
-s \
-o dist/report-print.pdf \
.PHONY : clean
clean:
rm -f $(output)/*.pdf
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
make: *** No rule to make target `dist/01-title.pdf', needed by `all'. Stop.
Run Code Online (Sandbox Code Playgroud)
该文件draft/01-title.md是源文件之一。
您没有.pdf从一个.md文件创建一个文件的规则。这很好,因为那不是你想做的。你想创建一个单一pdf的文件中所有的.md文件(据我所知)。所以,抛弃所有的objects东西;您不需要创建所有这些单独的pdf文件。
还有许多其他小问题:您没有创建与目标相同的文件名(report-print.mdvs. $(output)/report-print.pdf),您应该使用自动变量等)
您的 makefile 将只是:
source := draft
output := dist
sources := $(wildcard $(source)/*.md)
all: $(output)/report-print.pdf
$(output)/report-print.pdf: $(sources)
cat $^ | pandoc \
--variable geometry:a4paper \
--number-sections \
--toc \
--f markdown \
-s \
-o $@
.PHONY : clean
clean:
rm -f $(output)/*.pdf
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
749 次 |
| 最近记录: |