f22f483b74b4d9860652f2576d12740c5d2ed26a
Makefile
... | ... | @@ -6,10 +6,12 @@ NON_NETWORK_PAGES := $(shell ls wiki.d/* | grep -v Network\.) |
6 | 6 | PM_SAFE_PAGES := $(shell grep -vl "$(DIRECTIVES)" $(NON_NETWORK_PAGES)) |
7 | 7 | MD_SAFE_PAGES := $(patsubst wiki.d/%,%.md,$(PM_SAFE_PAGES)) |
8 | 8 | MD_GROUPED_PAGES := $(subst .,/,$(MD_SAFE_PAGES)) |
9 | -GROUPS=$(shell find [A-Z]* -type d) |
|
9 | +.SECONDARY: $(MD_GROUPED_PAGES) # don't delete .md files |
|
10 | + |
|
11 | +#GROUPS=$(shell find [A-Z]* -type d) |
|
12 | +GROUPS=Car |
|
10 | 13 | |
11 | 14 | WIKI := http://markferry.net/pmwiki/pmwiki.php |
12 | -MARKDOWNS := $(patsubst %.moin,%.md,$(DOCS)) |
|
13 | 15 | PMDOWN := ruby ~/src/pmdown/rb/convert_pm2md.rb |
14 | 16 | |
15 | 17 | # Construct a curl argument list to retrieve all URLs over a single connection |
... | ... | @@ -17,22 +19,26 @@ PMDOWN := ruby ~/src/pmdown/rb/convert_pm2md.rb |
17 | 19 | CURL_ALL := $(shell echo $(NAMES) | sed -e "s%\S\+%\'$(WIKI)/&?action=markdown\' -o &.md%g") |
18 | 20 | |
19 | 21 | .PHONY: FORCE help |
22 | +FORCE: ; |
|
20 | 23 | |
21 | 24 | default: help |
22 | 25 | help: |
23 | 26 | echo grep -vl "$(DIRECTIVES)" $(NON_NETWORK_PAGES) |
24 | 27 | |
25 | -%.md: FORCE |
|
28 | +%.md: %.raw FORCE |
|
29 | + sed -e "s%$(@D)\.%%g" $< \ |
|
30 | + | sed -f convert.sed \ |
|
31 | + > $@ |
|
32 | + |
|
33 | +%.raw: |
|
26 | 34 | mkdir -p $(dir $@) |
27 | 35 | curl "$(WIKI)?n=$(subst /,.,$(basename $@))&action=markdown" -o $@ |
28 | 36 | |
29 | 37 | all: $(MD_GROUPED_PAGES) |
30 | 38 | |
31 | -fix-links: |
|
39 | +fix-group-links: |
|
32 | 40 | for g in $(GROUPS); \ |
33 | 41 | do \ |
34 | - sed -i -e "s%$(WIKI)/$$g\.%%g" $$g/*.md ;\ |
|
35 | 42 | sed -i -e "s%$$g\.%%g" $$g/*.md ;\ |
36 | - sed -i -e "s%?action=edit%%" $$g/*.md ;\ |
|
37 | 43 | done |
38 | 44 |
convert.sed
... | ... | @@ -0,0 +1,17 @@ |
1 | +#!/usr/bin/sed |
|
2 | +# |
|
3 | +# Prepend a TOC |
|
4 | +# Print an extra first heading |
|
5 | +# Delete from 'On this page...' to the *first* first heading |
|
6 | +# |
|
7 | +/On this page.../{ |
|
8 | + i [[_TOC_]]\n |
|
9 | +}; |
|
10 | + |
|
11 | +/# 1./p |
|
12 | +/On this page/,/# 1./d |
|
13 | +/javascript:toggle/d |
|
14 | +/ #toc/d |
|
15 | + |
|
16 | +/?action=edit/d |
|
17 | +s%http://markferry.net/pmwiki/pmwiki.php?n=%% |