summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rwxr-xr-xscripts/html_wiki.py66
2 files changed, 68 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 857f8e4..36fb89b 100644
--- a/Makefile
+++ b/Makefile
@@ -64,6 +64,8 @@ file:
make CMD=task FILES=${PARAM} HTML=$(subst yaml,html,$(subst projects,html,${PARAM})) myhtml
summary:
make CMD=summary FILES=projects/${PARAM} HTML=html/${PARAM}/summary.html myhtml
+wikis:
+ make CMD=wiki FILES="${PARAM}" HTML=$(addprefix html/,$(subst .wiki,.html,${PARAM})) myhtml
basic:
make HTML_OPTION1="${HTML_OPTION1}" HTML_OPTION2="${HTML_OPTION2}" FILE=${FILE} ${FILE}
@@ -71,8 +73,6 @@ noparam:
make HTML_OPTION1=${PARAM} HTML_OPTION2="${PRODIR}" FILE=html/${PARAM}.html basic
finds:
make HTML_OPTION1="${EXP1} ${PARAM}" HTML_OPTION2="$(shell ${FIND} ${EXP2} ${PARAM})" FILE=html/${PARAM}.html basic
-wikis:
- make HTML_OPTION1=wiki HTML_OPTION2="${PARAM}" FILE=$(addprefix html/,$(subst .wiki,.html,${PARAM})) basic
menu:
make HTML_OPTION1="menu ${BSP}" HTML_OPTION2="" FILE=html/menu.html basic
clean:
diff --git a/scripts/html_wiki.py b/scripts/html_wiki.py
new file mode 100755
index 0000000..1c84643
--- /dev/null
+++ b/scripts/html_wiki.py
@@ -0,0 +1,66 @@
+#! /usr/bin/env python3
+#===============================
+#
+# html_wiki
+#
+# 2021/02/09 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+#===============================
+import textile
+import sys
+import re
+
+import html_base
+from html_base import html
+#====================================
+#
+# periject_html
+#
+#====================================
+class periject_html(html_base.myhtml):
+
+ def __init__(self):
+ super().__init__()
+
+ #--------------------
+ # print
+ #--------------------
+ def print(self, argv):
+ # remove this script
+ argv.pop(0)
+
+ with open(argv[0], "r") as f:
+ text = f.read()
+
+ # parse http[s]
+ text = re.sub(r'(\s+)http://(.*)(\s+)', r'\1"http://\2":http://\2\3', text)
+ text = re.sub(r'(\s+)https://(.*)(\s+)', r'\1"https://\2":https://\2\3', text)
+
+ # parse img
+ text = re.sub(r'!(\S+)!', r'!../../wiki/\1!', text)
+
+ # [[foo bar]]
+ # -> "foo bar":foo_bar.html
+ while 1:
+ hit = re.search(r'\[\[.*\]\]', text)
+
+ if (not hit):
+ break;
+
+ link = text[hit.start()+2:hit.end()-2]
+ link = "\"{}\":{}.html".format(link, re.sub(r' ', r'_', link))
+
+ text = text[:hit.start()] + link + text[hit.end():]
+
+ # textile
+ self.print_css("html/wiki")
+ with html("body"):
+ print(textile.textile(text))
+
+#====================================
+#
+# As command
+#
+#====================================
+if __name__=='__main__':
+ # html_wiki.py wiki/xxx.wiki
+ periject_html().print(sys.argv)