Commit 5f087c81 authored by Thijs Damsma's avatar Thijs Damsma Committed by GitHub

Inline toggleDiv

Inlined the toggleDiv function to workaround that jupyterlab doesn't support script tags in html.
parent 40d2c834
......@@ -79,14 +79,6 @@ class AnnotationCCodeWriter(CCodeWriter):
css.append(HtmlFormatter().get_style_defs('.cython'))
return '\n'.join(css)
_js = """
function toggleDiv(id) {
theDiv = id.nextElementSibling
if (theDiv.style.display != 'block') theDiv.style.display = 'block';
else theDiv.style.display = 'none';
}
""".strip()
_css_template = textwrap.dedent("""
body.cython { font-family: courier; font-size: 12; }
......@@ -141,9 +133,6 @@ class AnnotationCCodeWriter(CCodeWriter):
<style type="text/css">
{css}
</style>
<script>
{js}
</script>
</head>
<body class="cython">
<p><span style="border-bottom: solid 1px grey;">Generated by Cython {watermark}</span>{more_info}</p>
......@@ -151,7 +140,7 @@ class AnnotationCCodeWriter(CCodeWriter):
<span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br />
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
''').format(css=self._css(), js=self._js, watermark=Version.watermark,
''').format(css=self._css(), watermark=Version.watermark,
filename=os.path.basename(source_filename) if source_filename else '',
more_info=coverage_info)
]
......@@ -253,7 +242,12 @@ class AnnotationCCodeWriter(CCodeWriter):
calls['py_macro_api'] + calls['pyx_macro_api'])
if c_code:
onclick = " onclick='toggleDiv(this)'"
onclick = textwrap.dedent('''
onclick="
this.nextElementSibling.style.display != 'block' ?
this.nextElementSibling.style.display = 'block' :
this.nextElementSibling.style.display = 'none'
"''').replace('\n', '')
expandsymbol = '+'
else:
onclick = ''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment