You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
525 B
30 lines
525 B
9 years ago
|
from __future__ import print_function
|
||
|
import re, sys
|
||
|
|
||
|
|
||
|
def urlify (t):
|
||
|
return t.replace(" ", "_") + ".html"
|
||
|
|
||
|
def linkify (src, urlify=urlify):
|
||
|
|
||
|
collect = []
|
||
|
|
||
|
def s (m):
|
||
|
contents = m.group(1)
|
||
|
collect.append(contents)
|
||
|
link = urlify(contents)
|
||
|
return "[[<a class=\"wikilink\" href=\"{0}\">{1}</a>]]".format(link, contents)
|
||
|
|
||
|
src = re.sub(r"\[\[([\w_\- ]+?)\]\]", s, src)
|
||
|
return (src, collect)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
src = sys.stdin.read()
|
||
|
src, links = linkify(src)
|
||
|
|
||
|
for l in links:
|
||
|
print (l)
|
||
|
|
||
|
print (src)
|