diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-12-05 17:54:12 +0900 |
---|---|---|
committer | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-12-09 11:40:19 +0900 |
commit | e21bbbe516921e227f92a79aee8f907ee2563828 (patch) | |
tree | 843c3d69b31dfbf04f759572a92204a81c70082e /scripts | |
parent | 43717ae31ee76dab029cc6ba0aa07e6cd7688a55 (diff) |
Wiki support 1st version
Renesas contracted service provider will stop Redmine at 2021.
But, We want to keep it. This patch start to support Wiki at PeriJect.
100% compatible is difficult, but some of them can be.
These are known un-compatiblity.
- list "-" doesn't work
- line "---" doesn't work
- [[link]] doesn't work (periject supports similar one)
- !image! doesn't work (periject supports similar one)
- <pre>...</pre> doesn't allow white line
- {{toc}} doesn't work
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/myhtml.py (renamed from scripts/html.py) | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/scripts/html.py b/scripts/myhtml.py index 07727d0..d395cb8 100755 --- a/scripts/html.py +++ b/scripts/myhtml.py @@ -5,6 +5,7 @@ # # 2019/02/18 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> #=============================== +import textile import sys import os import re @@ -13,7 +14,6 @@ import base import find import view import datetime - #==================================== # # html @@ -257,6 +257,13 @@ class periject_html(base.base): self.__summary(dir, self.top() + "/" + dir, find.find([dir]).get()) #-------------------- + # menu_wiki + #-------------------- + def menu_wiki(self): + html("a", {"target":"_blank", + "href":"./wiki/top.html"}).print("Peri Peri Wiki") + + #-------------------- # menu_folder #-------------------- def menu_folder(self, current): @@ -319,6 +326,9 @@ class periject_html(base.base): def menu(self): with html("body"): + html("h1").print("Wiki") + self.menu_wiki() + html("h1").print("Folder") with html("ul"): self.menu_folder("./projects") @@ -339,6 +349,38 @@ class periject_html(base.base): datetime.datetime.now().strftime("%Y/%m/%d %H:%M"))) #-------------------- + # wiki + #-------------------- + def wiki(self, argv): + + 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 + print("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../wiki/css\">") + print(textile.textile(text)) + + #-------------------- # body #-------------------- def body(self): @@ -657,6 +699,8 @@ class periject_html(base.base): elif (cmd == "bsp"): # ./script/find.py -a | xargs ./script/html.py bsp self.bsp(sys.argv) + elif (cmd == "wiki"): + self.wiki(sys.argv) #==================================== # |