diff --git a/scripts/unlizeToNotebook.py b/scripts/unlizeToNotebook.py index df30aff42724dc43acdbb23c6cfcc7f2eb3a34d1..584b9ceb8e4470ab62b4acb5eb0340d9a8d3e1f1 100755 --- a/scripts/unlizeToNotebook.py +++ b/scripts/unlizeToNotebook.py @@ -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__':