本文整理汇总了Python中moire.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: table
def table(self, arg):
s = '\\begin{table}[h]\n\\begin{center}\n\\begin{tabular}{|'
max_tds = 0
for tr in arg[0]:
if isinstance(tr, list):
tds = 0
for td in tr:
if isinstance(td, list):
tds += 1
if tds > max_tds:
max_tds = tds
for k in range(max_tds):
s += 'p{2cm}|'
s += '}\n\\hline\n'
for tr in arg[0]:
if isinstance(tr, list):
tds = []
for td in tr:
if isinstance(td, list):
tds.append(td)
for td in tds[:-1]:
s += parse(td) + ' & '
s += parse(tds[-1])
s += ' \\\\\n\\hline\n'
s += '\\end{tabular}\n\\end{center}\n\\end{table}\n'
return s
示例2: header
def header(self, arg, number):
s = ''
if number == 1:
parsed = parse(arg[0])
s += parsed + '\n' + '=' * len(parsed)
elif number == 2:
parsed = parse(arg[0])
s += parsed + '\n' + '-' * len(parsed)
else:
s += (number * '#') + ' ' + parse(arg[0]) + ' ' + (number * '#')
return s
示例3: shortlist
def shortlist(self, arg):
s = '\\begin{itemize}[itemsep=-0.5ex]\n'
for item in arg[0]:
if isinstance(item, list):
s += '\\item ' + parse(item) + '\n\n'
s += '\\end{itemize}\n\n'
return s
示例4: list
def list(self, arg):
s = '<ul>'
for item in arg[0]:
if isinstance(item, list):
s += '<li>' + parse(item, inblock=True) + '</li>'
s += '</ul>'
return s
示例5: books
def books(self, arg):
s = '\\begin{thebibliography}{0}\n\n'
for item in arg[0]:
if isinstance(item, list):
s += '\\bibitem{' + item[0][0] + '} ' + parse(item[1]) + '\n\n'
s += '\\end{thebibliography}\n\n'
return s
示例6: ordered
def ordered(self, arg):
s = '\\begin{ordered}\n'
for item in arg[0]:
if isinstance(item, list):
s += '\\item ' + parse(item[0]) + '\n\n'
s += '\\end{ordered}\n'
return s
示例7: href
def href(self, arg):
s = ''
link = arg[0][0]
if link[0] == '#':
link = link[1:]
if len(arg) == 1:
s += '\\href {' + link + '} {' + link + '}'
else:
s += '\\href {' + link + '} {' + parse(arg[1]) + '}'
return s
示例8: body
def body(self, arg):
def justify(text, width):
k = ''
i = 0
for a in text:
k += a
if i % width == 0:
k += '\n'
i += 1
return k
return parse(arg[0], inblock=True, depth=1) + '\n'
示例9: b
def b(self, arg): return '<b>' + parse(arg[0]) + '</b>'
def br(self, arg): return '<br />'
示例10: image
def image(self, arg):
return '<img src="' + arg[0][0] + '" alt="' + parse(arg[1]) + '" />'
示例11: td
def td(self, arg): return '| ' + parse(arg[0])
def tt(self, arg): return '{\\f1 ' + parse(arg[0]) + '}'
示例12: tt
def tt(self, arg): return '{\\f1 ' + parse(arg[0]) + '}'
def u(self, arg): return '\\ul ' + parse(arg[0]) + '\\ul0\n'
示例13: pre_shortlist
def pre_shortlist(self, arg):
for item in arg[0]:
if isinstance(item, list):
parse(item, mode='pre_')
示例14: u
def u(self, arg): return '\\ul ' + parse(arg[0]) + '\\ul0\n'
def quote(self, arg): return parse(arg[0])
示例15: text
def text(self, arg): return '\\par\\pard\\qj' + parse(arg[0]) + '\n'
def br(self, arg): return '\\par\\pard'