Skip to content

Commit

Permalink
generate the front page for wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 18, 2013
1 parent fdb3297 commit 3a03737
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
32 changes: 32 additions & 0 deletions topics/documents/wiki/genHome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import sys

h = [
'Concepts, languages, techniques',
'Tools, libraries, functions',
'Transformation operators'
]

c = [
['BGF','XBGF','ΞBGF','EXBGF','MegaL','LDF','XLDF','EDD',
'ANF','LCI','BTF','LCF','Rascal','Prolog','XML','XSD','Factorial Language']
,
['ANTLR2BGF', 'AppendXBGF', 'AsFix2BTF', 'BGF2BNF', 'BGF2DMS', 'BGF2dot', 'BGF2HTML', 'BGF2Rsc', 'BGF2SDF', 'BGF2TeX', 'BGF2TXL', 'BGFlc', 'BGFover', 'BGFpp', 'BGFreformat', 'BTF2BGF', 'BTF2src', 'BuildTestSetXml', 'CBGF', 'CBGF2', 'CBGF2CBNF', 'CBGF2XBGF', 'CheckBGF', 'CheckXBGF', 'DCG2BGF', 'Ecore2BGF', 'EDD2Rsc', 'EXBGF', 'EXBGF2XBGF', 'EXBGFover', 'ExtractOver', 'FindHoriz', 'GBTF', 'GDT', 'GDTM', 'GDTS', 'HTML2BGF', 'Java2BGF', 'LCI', 'LDF2BGF', 'LDF2HTML', 'LDF2PDF', 'LDF2SET', 'LDF2TEX', 'LDinc', 'LLL2BGF', 'MergeBGF', 'NIGDT', 'NormBGF', 'PDF2BGF', 'PlotBGF', 'Py2BGF', 'REPP', 'Rsc2BGF', 'RscD2BGF', 'RscS2BGF', 'SDF2BGF', 'ShowBGF', 'ShowG', 'ShowPNF', 'ShowRootProds', 'ShowT', 'ShowX', 'ShowXBGF', 'ShowXSD', 'Spec2BGF', 'SubGrammar', 'TDT', 'TnB', 'TokenOver', 'TXL2BGF', 'Validate', 'XBGF', 'XBGF2CBGF', 'XBGF2HTML', 'XBGF2TeX', 'XBGF2XBNF', 'XBGFI', 'XBGFlc', 'XBGFover', 'XBGFS', 'XBTF', 'XLLL', 'XML2BTF', 'XSD2BGF', 'XSD2LDF']
,
['Abridge', 'Abstractize', 'AddH', 'AddV', 'Anonymize', 'Appear', 'Chain', 'Concretize', 'Deanonymize', 'Define', 'Designate', 'Detour', 'Deyaccify', 'Disappear', 'Distribute', 'Downgrade', 'Dump', 'Eliminate', 'Equate', 'Extract', 'Factor', 'Fold', 'Horizontal', 'Import', 'Inject', 'Inline', 'Introduce', 'LAssoc', 'Massage', 'Narrow', 'Permute', 'Project', 'RAssoc', 'Redefine', 'Remove', 'RemoveH', 'RemoveV', 'RenameT', 'RenameL', 'RenameN', 'RenameS', 'Replace', 'Undefine', 'Unfold', 'Unite', 'Unlabel', 'Upgrade', 'Vertical', 'Widen', 'Yaccify']
]

l = len(h)
w = [max(len(h[i])+4,max(map(len,c[i]))) for i in range(0,l)]
c = map(sorted,c)
d = max(map(len,c))

f = open('texts/Home.md','w')
f.write('|**'+'**|**'.join(h)+'**|\n')
f.write('|'+'|'.join(['-'*v for v in w])+'|\n')
for i in range(0,l):
while(len(c[i])<d): c[i].append('')
f.write('\n'.join(['|'+'|'.join([c[i][j] and ('[['+c[i][j]+']]').center(w[i]) or ''.center(w[i]) for i in range(0,l)])+'|' for j in range(0,d)]))
f.close()
61 changes: 61 additions & 0 deletions topics/documents/wiki/html2md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

def removetags(s):
# return s
s = s.replace('&#8220;','“').replace('&#8221;','”')
# <span xmlns="" class="nt">
# s = s.replace('<span xmlns="" class="nt">','[[')
# s = s.replace('</span>',']]')
while s.find('<')>-1:
c = s.split('<')
# ```<a name="abridge" id="abridge">[[abridge]]</a>:
# '
c[0] = c[0]+c[1].split('>')[1]
if len(c)>2:
s = '<'.join([c[0]]+c[2:])
else:
s = c[0]
return s

f = open('index.html','r')
txt = {}
now = ''
raw = False
for r in f.readlines():
if not raw:
r = r.strip()
else:
r = r.replace('\n','')
if r.startswith('<pre>'):
raw = True
if r.find('</pre>')>-1:
raw = False
if r.startswith('<a name="') and r.endswith('</h3>'):
now = r.split('"')[1]
print 'Found',now+'!'
txt[now] = []
continue
if r.find('compatibility-section')>-1:
now = ''
continue
# refactor
if r.endswith('</h4>'):
r = '### '+r.split('<')[-2].split('>')[-1]
r = r.replace('<pre>','```')
r = r.replace('</pre>','```')
r = removetags(r)
# use
if now!='':
txt[now].append(r)
# print 'Proceessing',r[:20]+'... as',now
f.close()

# print txt

for k in txt.keys():
f = open('texts/'+k.capitalize()+'.md','w')
for r in txt[k]:
f.write(r.replace('&lt;','<').replace('&gt;','>')+'\n')
f.close()

2 changes: 1 addition & 1 deletion topics/documents/wiki/texts
Submodule texts updated from 1b1cf9 to 50fa7c

0 comments on commit 3a03737

Please sign in to comment.