Skip to content
Snippets Groups Projects
Commit 5f66c8f0 authored by David Rouquet's avatar David Rouquet
Browse files

Add text identifier (num) to notebook cells

parent 082f2a97
No related branches found
No related tags found
No related merge requests found
Pipeline #239 passed
......@@ -26,12 +26,13 @@ def unlizeXmlNb(input, output, template, lang, dry_run):
tags = ['title', 'text_body', 'term', 'meaning']
for t in tags:
for node in doc.xpath('//'+t):
num = str(node.xpath('../@id')[0])
if node.text:
# Add
unl = unlize(nestedBody2Str(node), lang, dry_run)
addCell(nb, unl)
addCell(nb, unl, num)
else:
addCell(nb, getText(node, 'unl'))
addCell(nb, getText(node, 'unl'), num)
# We execute the notebook
#resources = {}
#exec_nb, resources = ExecutePreprocessor(timeout=-1).preprocess(nb, resources)
......@@ -45,11 +46,12 @@ def getText(node, tag):
except IndexError:
return ''
def addCell(nb, unl):
code = """unldata = \"\"\"
def addCell(nb, unl, num=''):
code = """num = \"{num}\"
unldata = \"\"\"
{unl}
\"\"\"
displayUnl(unldata)""".format(unl=unl.strip())
displayUnl(unldata)""".format(num=num,unl=unl.strip())
nb['cells'].append(new_code_cell(code))
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment