-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.readme
71 lines (53 loc) · 1.78 KB
/
Makefile.readme
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Makefile.markdown_readme
# Objective: Convert <README.adoc> to <README.md>.
# Motivation: SourceHut does not support readme files in AsciiDoc, only plain
# text and Markdown (Commonmark).
# By Marcos Cruz (programandala.net)
# Last modified 20241106T1621+0100.
# See change log at the end of the file.
# Requirements {{{1
# ==============================================================
# Asciidoctor (by Dan Allen, Sarah White et al.)
# http://asciidoctor.org
# Pandoc (by John MaFarlane)
# http://pandoc.org
# Config {{{1
# ==============================================================
# Input variable, set by <Makefile>:
#
# readme_title = title of the README file, usually the name of the project
# Convert README to Markdown {{{1
# ==============================================================
.PHONY: readme
readme: README.md
.PHONY: cleanreadme
cleanreadme:
rm -f README.md
# XXX FIXME Somehow `pandoc --from docbook --to commonmark` ignores the main
# title and makes section headings level 1. A workaround is used with `echo`
# and `sed`:
README.md: tmp/README.db
echo "# $(readme_title)\n" > $@
pandoc \
--from docbook \
--to commonmark \
$< \
| sed -e 's/^#\(.\+\)/##\1/' >> $@
tmp/README.db: README.adoc
asciidoctor \
--backend docbook \
--out-file=$@ $<
tmp/README.html: README.adoc
asciidoctor \
--backend html5 \
--embedded \
--out-file=$@ $<
# ==============================================================
# Change log {{{1
# 2024-09-03: Start as part of the Makefile of project Fendo
# (http://programandala.net/en.program.fendo.html): Remove the rules to build
# the <README.html> required by Fossil; add rules to build a <README.md> for
# SourceHut.
#
# 2024-11-06: Extract the rules to <Makefile.readme> in order to share the code
# with other projects.