forked from mortie/housecat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeHTML
More file actions
36 lines (27 loc) · 746 Bytes
/
Copy pathMakeHTML
File metadata and controls
36 lines (27 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Make HTML files from markdown
# Will only convert .md files
HTMLDIR?=input/
MDDIR?=raw/
# Verbosity
V?=0
MARK:=cmark
CMDPRE:=@
ifneq ($(V), 0)
CMDPRE:=
endif
MDS:=$(shell find $(MDDIR) -type f -name "*.md")
HTMLS:=$(patsubst $(MDDIR)%.md,$(HTMLDIR)%.html,$(MDS))
CONFS:=$(shell find $(MDDIR) -type f -name "*.conf")
FINALCONFS:=$(patsubst $(MDDIR)%.conf,$(HTMLDIR)%.conf,$(CONFS))
all: $(HTMLS) $(FINALCONFS)
$(HTMLDIR)%.html: $(MDDIR)%.md
$(CMDPRE)mkdir -p "$(dir $@)"
$(CMDPRE)sed -ne '/^#/,$$ p' "$<" | $(MARK) > "$@".tmp
$(CMDPRE)sed '/^#/Q' "$<" | cat - "$@".tmp > "$@"
$(CMDPRE)rm "$@".tmp
$(HTMLDIR)%.conf: $(MDDIR)%.conf
$(CMDPRE)mkdir -p "$(dir $@)"
$(CMDPRE)cp "$<" > "$@"
clean:
@rm -rf $(HTMLDIR)
.PHONY: clean all