+class HTMLMarkup (object):
+ texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*-
+@c This file was generated by translation-status.py -- DO NOT EDIT!
+@ignore
+ Translation of GIT committish: 0
+@end ignore
+
+'''
+ texi_footer = '''
+'''
+ def texi (self, string):
+ return (self.texi_header
+ + '''
+@ifnothtml
+Translation status currently only available in HTML.
+@end ifnothtml
+'''
+ + string
+ + self.texi_footer)
+ def entity (self, name, string='', attributes=[]):
+ attr_list = ''.join ([' %s="%s"' % x for x in attributes])
+ return '<%(name)s%(attr_list)s>%(string)s</%(name)s>' % locals ()
+ def paragraph (self, string=''):
+ return self.entity ('p', string)
+ def table (self, string):
+ return self.entity ('table', string, [('align', 'center'), ('border', '2')])
+ def row (self, string, attributes=[]):
+ return self.entity ('tr', string, attributes)
+ headrow = row
+ def headcell (self, string, attributes=[]):
+ return self.entity ('th', string, attributes)
+ def cell (self, string='', attributes=[]):
+ return self.entity ('td', string, attributes)
+ def newline (self, attributes=[]):
+ return self.entity ('br', '', attributes)[:-5]
+ def span (self, string, attributes=[]):
+ return self.entity ('span', string, attributes)
+ def small (self, string, attributes=[]):
+ return self.entity ('small', string, attributes)
+ def emph (self, string, attributes=[]):
+ return self.entity ('em', string, attributes)
+
+class TexiMarkup (HTMLMarkup):
+ def texi (self, string):
+ return (self.texi_header
+ + self.html ('''
+<style type="text/css"><!--
+th { border: 1px solid black; text-align: center; }
+td { border: 1px solid black; text-align: center; }
+!--></style>
+''')
+ + self.columnfraction_disaster (self.itemtab_disaster (string))
+ + self.texi_footer)
+ def itemtab_disaster (self, string):
+ return string.replace ('''item \n@tab ''', '''item
+''')
+ def columnfraction_disaster (self, string):
+ if False:
+ # nice trick for html-only
+ return string.replace ('@multitable', '@multitable @columnfractions 0 0 0 0 0 0 0 0 0 0')
+ tables = re.findall ('(?s)(@multitable)(.*?)(@item)', string)
+ for t in tables:
+ columns = len (re.findall ('(?s)(\n@tab)', t[1])) + 1
+ columnfractions = '@columnfractions ' + (' ' + str (1.0/columns)) * columns
+ string = string.replace ('@multitable\n',
+ '@multitable %(columnfractions)s\n' % locals (), 1)
+ return string
+ def entity (self, name, string='', attributes=[]):
+ return '''
+@%(name)s
+%(string)s
+@end %(name)s''' % locals ()
+ def paragraph (self, string=''):
+ return '''
+%(string)s''' % locals ()
+ def table (self, string):
+ # Ugh, makeinfo is fine without @columnfractions
+ # but texi2html 1.82 barfs: `empty multicolumn'
+ return (self.entity ('multitable', string))
+ def headrow (self, string, attributes=[]):
+ return '''
+@headitem ''' + string
+ def row (self, string, attributes=[]):
+ return '''
+@item ''' + string
+ def cell (self, string='', attributes=[]):
+ return '''
+@tab ''' + string
+ headcell = cell
+ def newline (self):
+ return '''
+@*
+'''
+ def html (self, string):
+ return self.entity ('ifhtml', self.entity ('html', string))
+ def nothtml (self, string):
+ return self.entity ('ifnothtml', string)
+ def span (self, string, attributes=[]):
+ return (self.html (HTMLMarkup ().span (string, attributes))
+ + self.nothtml (string))
+ def small (self, string, attributes=[]):
+ return (self.html (HTMLMarkup ().small (string, attributes))
+ + self.nothtml (string))
+ def command (self, name, string):
+ return '@%(name)s{%(string)s}' % locals ()
+ def emph (self, string, attributes=[]):
+ return self.command ('emph', string)