Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for row in e.items:
for cell in row:
if len(cell) == 1 and len(cell[0].items)==1:
text = cell[0].items[0].text
if text.isdigit():
cell[0].items[0].text = str(int(text)+1)
return e
def idea(e, doc):
selector = 'Table Items Rows Cells'
if any(type(a)==pf.Table for a in e.ancestors()):
pass
if __name__ == '__main__':
pf.toJSONFilter(add_one)
def main():
#tags = {'figure': figure, 'table': table}
pf.toJSONFilter(pf.yaml_filter, prepare=prepare, finalize=finalize,
tag='figure', function=figure)
"""
def prepare(doc):
doc.ignore = False
def comment(el, doc):
is_relevant = (type(el) == pf.RawBlock) and (el.format == 'html')
if is_relevant and re.search("", el.text):
doc.ignore = True
if doc.ignore:
if is_relevant and re.search("", el.text):
doc.ignore = False
return []
if __name__ == "__main__":
pf.toJSONFilter(comment, prepare=prepare)
if type(elem) == CodeBlock and 'ly' in elem.classes:
staffsize = int(elem.attributes.get('staffsize', '20'))
if doc.format == "latex":
if elem.identifier == "":
label = ""
else:
label = '\\label{' + elem.identifier + '}'
return latexblock(
'\\lily[staffsize=%s]{%s}' % (staffsize, code) +
label
)
else:
return Para(Image(url=png(code, staffsize)))
if __name__ == "__main__":
toJSONFilter(lily)
if elem.identifier == "":
label = ""
else:
label = '\\label{' + elem.identifier + '}'
return latexblock(
"\n\\smallskip\n{%\n" +
latexsnippet('\\gabcsnippet{' + elem.text + '}', elem.attributes) +
"%\n}" +
label
)
else:
return Para(Image(url=png(elem.text, latexsnippet('\\gabcsnippet', elem.attributes))))
if __name__ == "__main__":
toJSONFilter(gabc)
def deemph(elem, doc):
if type(elem) == Emph:
# Make Str elements in Emph uppercase
elem.walk(caps)
# Append them to Emph's parent (after the emph)
for i, item in enumerate(elem.content, elem.index + 1):
elem.parent.content.insert(i, item)
# Delete the emph
return []
if __name__ == "__main__":
toJSONFilter(deemph)
outfile = imagedir + '/' + sha1(code)
filetype = {'html': 'png', 'latex': 'pdf'}.get(doc.format, 'png')
src = outfile + '.' + filetype
if not os.path.isfile(src):
try:
os.mkdir(imagedir)
sys.stderr.write('Created directory ' + imagedir + '\n')
except OSError:
pass
tikz2image(code, filetype, outfile)
sys.stderr.write('Created image ' + src + '\n')
return Para(Image(url=src))
if __name__ == "__main__":
toJSONFilter(tikz)
filetype = {'html': 'png', 'latex': 'pdf'}.get(doc.format, 'png')
alt = Str(caption)
src = imagedir + '/' + filename + '.' + filetype
if not os.path.isfile(src):
try:
os.mkdir(imagedir)
sys.stderr.write('Created directory ' + imagedir + '\n')
except OSError:
pass
G.draw(src)
sys.stderr.write('Created image ' + src + '\n')
return Para(Image(alt, url=source, title=''))
if __name__ == "__main__":
toJSONFilter(graphviz)
def main():
pf.toJSONFilter(pf.yaml_filter, prepare=prepare, finalize=finalize,
tag='figure', function=figure)