Makefile fix (detect missing title)

This commit is contained in:
2023-02-01 14:05:22 +01:00
parent 480e63568b
commit e804ac4a62
2 changed files with 16 additions and 12 deletions

View File

@@ -1,10 +1,11 @@
SHELL := /bin/bash
# CSS to be included as stylesheets and alternate stylesheets
CSS := assets/ghost.css
ALTCSS := assets/ghost-dark.css assets/ghost-caca.css
CSS := assets/ghost-dark.css
ALTCSS := assets/ghost.css
TARGETS := $(patsubst %.md,%.html,$(wildcard *.md))
MDFILES := $(wildcard *.md)
TARGETS := $(patsubst %.md,%.html,$(MDFILES))
CSSINC := css.inc
# our main html5 template, mostly taken from :
@@ -22,8 +23,9 @@ TITLE = $(shell sed -n '0,/^\#/ s/^[\# ]*//p' $1)
OPTS = --standalone --include-in-header=$(CSSINC) --template=$(TEMPLATE) \
--from=gfm --to=html5
.PHONY: all html clean
.PHONY: titles all html clean
#all: $(CSSINC) titles html
all: $(CSSINC) html
html: $(TARGETS)
@@ -40,5 +42,10 @@ $(CSSINC): $(CSS) $(ALTCSS)
@$(foreach css,$(ALTCSS),$(call ADD_LINE,$(css),alternate stylesheet,$@))
%.html: %.md $(CSSINC)
@echo generating $@
@pandoc $(OPTS) --metadata=title:"$(call TITLE,$<)" -o $@ $<
@echo -n "generating $@... "
@if ! grep -q "^#" $< ; then \
echo "ERROR (no title), skipping." ; \
else \
pandoc $(OPTS) --metadata=title:"$(call TITLE,$<)" -o $@ $< ; \
echo done. ; \
fi