Make allowances for plots and dataframes in MDX
_test_html = """<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>"""
assert HTMLdf.search(_test_html)
assert not HTMLdf.search('<div></div>')
By default, HTML is incompatible with MDX. We place HTML in a code block and wrap it with the a custom component so that the static site generator can render it.
c, _ = run_preprocessor([HTMLEscape], 'test_files/pandas.ipynb', display_results=True)
assert '<HTMLOutputBlock' in c and '</HTMLOutputBlock>' in c and 'center' not in c
assert '```html\n<div>' in c and '</div>\n```' in c
c, _ = run_preprocessor([ImageSave, ImagePath], 'test_files/matplotlib.ipynb', display_results=True)
assert '![png](_matplotlib_files/output_0_1.png)' in c
c, _ = run_preprocessor([ImageSave, ImagePath], 'test_files/altair_jpeg.ipynb')
assert '![svg](_altair_jpeg_files/output_0_0.svg' in c