Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def RawBlock(format, string):
"""Overwrite pandocfilters RawBlock so that html5
and html raw output both use the html writer.
"""
if format == 'html5':
format = 'html'
return pf.RawBlock(format, string)
if table['is_unnumbered']:
if fmt in ['latex', 'beamer']:
# Use the no-prefix-table-caption environment
return [RawBlock('tex',
r'\begin{tablenos:no-prefix-table-caption}'),
Table(*(value if len(value) == 5 else value[1:])),
RawBlock('tex', r'\end{tablenos:no-prefix-table-caption}')]
return None # Nothing to do
attrs = table['attrs']
ret = None
if fmt in ['latex', 'beamer']:
if table['is_tagged']: # A table cannot be tagged if it is unnumbered
has_tagged_tables = True
ret = [RawBlock('tex', r'\begin{tablenos:tagged-table}[%s]' % \
references[attrs.id].num),
AttrTable(*value),
RawBlock('tex', r'\end{tablenos:tagged-table}')]
elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3'):
if LABEL_PATTERN.match(attrs.id):
# Enclose table in hidden div
pre = RawBlock('html', '<div class="tablenos" id="%s">'%attrs.id)
post = RawBlock('html', '</div>')
ret = [pre, AttrTable(*value), post]
elif fmt == 'docx':
# As per http://officeopenxml.com/WPhyperlink.php
bookmarkstart = \
RawBlock('openxml',
''
%attrs.id)
bookmarkend = \
def latex(s):
return pf.RawBlock('latex', s)
def latex(s):
return pf.RawBlock('latex', s)
def latex(x):
return RawBlock('tex', x)
def html(x):
return RawBlock('html', x)
attrs = table['attrs']
ret = None
if fmt in ['latex', 'beamer']:
if table['is_tagged']: # A table cannot be tagged if it is unnumbered
has_tagged_tables = True
ret = [RawBlock('tex', r'\begin{tablenos:tagged-table}[%s]' % \
references[attrs.id].num),
AttrTable(*value),
RawBlock('tex', r'\end{tablenos:tagged-table}')]
elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3'):
if LABEL_PATTERN.match(attrs.id):
# Enclose table in hidden div
pre = RawBlock('html', '<div class="tablenos" id="%s">'%attrs.id)
post = RawBlock('html', '</div>')
ret = [pre, AttrTable(*value), post]
elif fmt == 'docx':
# As per http://officeopenxml.com/WPhyperlink.php
bookmarkstart = \
RawBlock('openxml',
''
%attrs.id)
bookmarkend = \
RawBlock('openxml', '')
ret = [bookmarkstart, AttrTable(*value), bookmarkend]
return ret
if self.to in ('latex', 'pdf', 'beamer'):
if 'text/latex' in all_data.keys():
key = 'text/latex'
data = all_data[key]
if key == 'text/plain':
# ident, classes, kvs
blocks = plain_output(data, self.pandoc_extra_args, pandoc)
elif key == 'text/latex':
blocks = [RawBlock('latex', data)]
elif key == 'text/html':
blocks = [RawBlock('html', data)]
elif key == 'application/javascript':
script = ''.format(
data)
blocks = [RawBlock('html', script)]
elif key.startswith('image') or key == 'application/pdf':
blocks = [self.wrap_image_output(chunk_name, data, key,
attrs)]
else:
blocks = tokenize_block(data, self.pandoc_extra_args)
output_blocks += blocks
return output_blocks