-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrulesToPHPBB.py
41 lines (36 loc) · 1.37 KB
/
rulesToPHPBB.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
# A script to help generating the forum post for the rulebook.
with open('rules.md') as rules:
in_list = False
for line in rules.read().split('\n'):
if line.startswith('* '):
if not in_list:
in_list = True
print('[list]')
line = '[*] ' + line[2:]
elif in_list:
print('[/list]')
in_list = False
if line.startswith('# The Rulebook') or line.startswith('# Schedule Summary'):
line = '[b][size=200]{}[/size][/b]'.format(line[2:])
elif line.startswith('# '):
line = '[b][size=150]{}[/size][/b]'.format(line[2:])
elif line.startswith('## '):
line = '[b]{}[/b]'.format(line[3:])
elif line.startswith('### '):
line = '[b]{}[/b]'.format(line[4:])
if line == '- [The Rulebook](#the-rulebook)':
continue
elif line.startswith('- ['):
line = re.sub(r'^[^\[]*\[([^\]]*).*$', '[b]\\1[/b]', line)
elif line.strip().startswith('- ['):
line = re.sub(r'^[^\[]*\[([^\]]*).*$', '\\1', line)
print(line)
if in_list:
print('[/list]')
print('''[size=200]Changes to the rulebook since last season[/size]
Key:
[color=#0000FF]Text added[/color]
[color=#FF0000]Text removed[/color]''')