|
1 | 1 | # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/11_xml.ipynb. |
2 | 2 |
|
3 | 3 | # %% auto 0 |
4 | | -__all__ = ['voids', 'XT', 'xt', 'to_xml', 'Html', 'Head', 'Title', 'Meta', 'Link', 'Style', 'Body', 'Pre', 'Code', 'Div', 'Span', |
5 | | - 'P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'Strong', 'Em', 'B', 'I', 'U', 'S', 'Strike', 'Sub', 'Sup', 'Hr', |
6 | | - 'Br', 'Img', 'A', 'Nav', 'Ul', 'Ol', 'Li', 'Dl', 'Dt', 'Dd', 'Table', 'Thead', 'Tbody', 'Tfoot', 'Tr', 'Th', |
7 | | - 'Td', 'Caption', 'Col', 'Colgroup', 'Form', 'Input', 'Textarea', 'Button', 'Select', 'Option', 'Label', |
8 | | - 'Fieldset', 'Legend', 'Details', 'Summary', 'Main', 'Header', 'Footer', 'Section', 'Article', 'Aside', |
9 | | - 'Figure', 'Figcaption', 'Mark', 'Small', 'Iframe', 'Object', 'Embed', 'Param', 'Video', 'Audio', 'Source', |
10 | | - 'Canvas', 'Svg', 'Math', 'Script', 'Noscript', 'Template', 'Slot'] |
| 4 | +__all__ = ['voids', 'XT', 'xt', 'to_xml', 'highlight', 'showtags', 'Html', 'Head', 'Title', 'Meta', 'Link', 'Style', 'Body', |
| 5 | + 'Pre', 'Code', 'Div', 'Span', 'P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'Strong', 'Em', 'B', 'I', 'U', 'S', |
| 6 | + 'Strike', 'Sub', 'Sup', 'Hr', 'Br', 'Img', 'A', 'Nav', 'Ul', 'Ol', 'Li', 'Dl', 'Dt', 'Dd', 'Table', 'Thead', |
| 7 | + 'Tbody', 'Tfoot', 'Tr', 'Th', 'Td', 'Caption', 'Col', 'Colgroup', 'Form', 'Input', 'Textarea', 'Button', |
| 8 | + 'Select', 'Option', 'Label', 'Fieldset', 'Legend', 'Details', 'Summary', 'Main', 'Header', 'Footer', |
| 9 | + 'Section', 'Article', 'Aside', 'Figure', 'Figcaption', 'Mark', 'Small', 'Iframe', 'Object', 'Embed', 'Param', |
| 10 | + 'Video', 'Audio', 'Source', 'Canvas', 'Svg', 'Math', 'Script', 'Noscript', 'Template', 'Slot'] |
11 | 11 |
|
12 | 12 | # %% ../nbs/11_xml.ipynb 2 |
13 | 13 | from .utils import * |
@@ -73,8 +73,14 @@ def to_xml(elm, lvl=0): |
73 | 73 | return res |
74 | 74 |
|
75 | 75 | # %% ../nbs/11_xml.ipynb 13 |
76 | | -@patch |
77 | | -def _repr_markdown_(self:XT): |
78 | | - try: from IPython import display |
79 | | - except ImportError: return repr(self) |
80 | | - return f'```html\n{to_xml(self)}\n```' |
| 76 | +def highlight(s, lang='html'): |
| 77 | + "Markdown to syntax-highlight `s` in language `lang`" |
| 78 | + return f'```{lang}\n{to_xml(s)}\n```' |
| 79 | + |
| 80 | +# %% ../nbs/11_xml.ipynb 14 |
| 81 | +def showtags(s): |
| 82 | + return f"""<code><pre> |
| 83 | +{escape(to_xml(s))} |
| 84 | +</code></pre>""" |
| 85 | + |
| 86 | +XT._repr_html_ = showtags |
0 commit comments