From 3a037372978c7b6604de701bf2111079d3e965a6 Mon Sep 17 00:00:00 2001 From: grammarware Date: Fri, 18 Jan 2013 13:01:44 +0100 Subject: [PATCH] generate the front page for wiki --- topics/documents/wiki/genHome.py | 32 +++++++++++++++++ topics/documents/wiki/html2md.py | 61 ++++++++++++++++++++++++++++++++ topics/documents/wiki/texts | 2 +- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100755 topics/documents/wiki/genHome.py create mode 100755 topics/documents/wiki/html2md.py diff --git a/topics/documents/wiki/genHome.py b/topics/documents/wiki/genHome.py new file mode 100755 index 00000000..225b551d --- /dev/null +++ b/topics/documents/wiki/genHome.py @@ -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]) + # s = s.replace('','[[') + # s = s.replace('',']]') + while s.find('<')>-1: + c = s.split('<') + # ```[[abridge]]: + # ' + 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('
'):
+		raw = True
+	if r.find('
')>-1: + raw = False + if r.startswith('-1: + now = '' + continue + # refactor + if r.endswith(''): + r = '### '+r.split('<')[-2].split('>')[-1] + r = r.replace('
','```')
+	r = r.replace('
','```') + 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('<','<').replace('>','>')+'\n') + f.close() + diff --git a/topics/documents/wiki/texts b/topics/documents/wiki/texts index 1b1cf95c..50fa7cb3 160000 --- a/topics/documents/wiki/texts +++ b/topics/documents/wiki/texts @@ -1 +1 @@ -Subproject commit 1b1cf95cb51025628837235c056812997504b611 +Subproject commit 50fa7cb3d94cc5de5e866c9ab5e213826bbafa6d