aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel.thompson@linaro.org>2016-05-12 20:48:57 +0100
committerDaniel Thompson <daniel.thompson@linaro.org>2016-05-12 20:48:57 +0100
commit5024cfd96249a087e569bd59bbb751994a1ccdf8 (patch)
tree20be583369b6ff1695e17755db18b93413fabe14
Initial revision.
See README.md for details. Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
-rw-r--r--Makefile28
-rw-r--r--README.md15
-rw-r--r--split-topics.py18
-rw-r--r--wordpressify.py19
4 files changed, 80 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b2cd19b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+#
+# Split out pages from the FAQ nursery ready to copy to wordpress
+#
+
+MD = $(wildcard *.md)
+HTML = $(MD:%.md=%.html)
+WP = $(HTML:%.html=%.wp)
+
+all : 96boards-wiki
+ cd 96boards-wiki && git pull
+ python split-topics.py 96boards-wiki/The-FAQ-nursery.md
+ $(MAKE) _all
+
+# We need to do a double level make to ensure the wildcards get
+# re-evaluated after we split out the topics from the wiki.
+_all : $(WP)
+
+96boards-wiki :
+ git clone https://github.com/96boards/documentation.wiki 96boards-wiki
+
+clean :
+ $(RM) $(MD) $(HTML)
+
+%.html : %.md
+ cmark $< > $@
+
+%.wp : %.html
+ python wordpressify.py $< > $@
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1f5920d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+This repo is a quick hack to automatically prepare the FAQ nursery (on the
+96boards github wiki) and convert it to a form that can be copy 'n pasted
+onto the 96boards forum. It splits out the first level heading from the
+FAQ nursery, converts the resulting markdown fragments into HTML and then
+sanitizes the output so it contains only tags suitable for uploading
+to the forum.
+
+The idea behind the tool is to commit the .wp files every time the forum
+is updated. This results in a workflow to update the forum as follows:
+
+ make
+ git diff
+ <manually update the forum from the .wp files>
+ git commit -a "Contents of the forum as of $(date)"
+
diff --git a/split-topics.py b/split-topics.py
new file mode 100644
index 0000000..1f9b9e5
--- /dev/null
+++ b/split-topics.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import sys
+
+for fname in sys.argv[1:]:
+ with open(fname) as f:
+ g = open('front-matter.md', 'w')
+
+ for ln in f.readlines():
+ if ln.strip().startswith('# '):
+ g.close()
+ gname = ln[1:].strip().replace(' ', '-')+'.md'
+ g = open(gname, 'w')
+ continue
+
+ g.write(ln)
+
+ g.close()
diff --git a/wordpressify.py b/wordpressify.py
new file mode 100644
index 0000000..a2678bf
--- /dev/null
+++ b/wordpressify.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+from __future__ import print_function
+
+import sys
+
+for fname in sys.argv[1:]:
+ with open(fname) as f:
+ for ln in f.readlines():
+ ln = ln.rstrip()
+
+ ln = ln.replace('</p>', '')
+ ln = ln.replace('<p>', '\n')
+ ln = ln.replace('<h2>', '<strong>')
+ ln = ln.replace('</h2>', '</strong>')
+ ln = ln.replace('<h3>', '<strong>')
+ ln = ln.replace('</h3>', '</strong>')
+
+ print(ln)