11# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/11_xml.ipynb.
22
33# %% auto 0
4- __all__ = ['named' , ' voids' , 'XT' , 'xt' , 'to_xml' , 'Html' , 'Head' , 'Title' , 'Meta' , 'Link' , 'Style' , 'Body' , 'Pre' , 'Code' , 'Div' ,
5- 'Span' , ' P' , 'H1' , 'H2' , 'H3' , 'H4' , 'H5' , 'H6' , 'Strong' , 'Em' , 'B' , 'I' , 'U' , 'S' , 'Strike' , 'Sub' , 'Sup' ,
6- 'Hr' , ' Br' , 'Img' , 'A' , 'Nav' , 'Ul' , 'Ol' , 'Li' , 'Dl' , 'Dt' , 'Dd' , 'Table' , 'Thead' , 'Tbody' , 'Tfoot' , 'Tr' ,
7- 'Th' , ' Td' , 'Caption' , 'Col' , 'Colgroup' , 'Form' , 'Input' , 'Textarea' , 'Button' , 'Select' , 'Option' , 'Label' ,
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' ,
88 'Fieldset' , 'Legend' , 'Details' , 'Summary' , 'Main' , 'Header' , 'Footer' , 'Section' , 'Article' , 'Aside' ,
99 'Figure' , 'Figcaption' , 'Mark' , 'Small' , 'Iframe' , 'Object' , 'Embed' , 'Param' , 'Video' , 'Audio' , 'Source' ,
1010 'Canvas' , 'Svg' , 'Math' , 'Script' , 'Noscript' , 'Template' , 'Slot' ]
@@ -23,37 +23,33 @@ def _attrmap(o):
2323 return o .lstrip ('_' ).replace ('_' , '-' )
2424
2525# %% ../nbs/11_xml.ipynb 5
26- named = set ( 'a button form frame iframe img input map meta object param select textarea' . split ())
26+ class XT ( list ): pass
2727
2828# %% ../nbs/11_xml.ipynb 6
29- class XT (list ): patch
30-
31- # %% ../nbs/11_xml.ipynb 7
3229def xt (tag :str , * c , ** kw ):
3330 "Create an XML tag structure `[tag,children,attrs]` for `toxml()`"
3431 if len (c )== 1 and isinstance (c [0 ], types .GeneratorType ): c = tuple (c [0 ])
3532 kw = {_attrmap (k ):str (v ) for k ,v in kw .items () if v is not None }
36- if tag in named and 'id' in kw and 'name' not in kw : kw ['name' ] = kw ['id' ]
3733 return XT ([tag .lower (),c ,kw ])
3834
39- # %% ../nbs/11_xml.ipynb 8
35+ # %% ../nbs/11_xml.ipynb 7
4036_g = globals ()
4137_all_ = ['Html' , 'Head' , 'Title' , 'Meta' , 'Link' , 'Style' , 'Body' , 'Pre' , 'Code' ,
42- 'Div' , 'Span' , 'P' , 'H1' , 'H2' , 'H3' , 'H4' , 'H5' , 'H6' , 'Strong' , 'Em' , 'B' ,
43- 'I' , 'U' , 'S' , 'Strike' , 'Sub' , 'Sup' , 'Hr' , 'Br' , 'Img' , 'A' , 'Link' , 'Nav' ,
44- 'Ul' , 'Ol' , 'Li' , 'Dl' , 'Dt' , 'Dd' , 'Table' , 'Thead' , 'Tbody' , 'Tfoot' , 'Tr' ,
45- 'Th' , 'Td' , 'Caption' , 'Col' , 'Colgroup' , 'Form' , 'Input' , 'Textarea' ,
46- 'Button' , 'Select' , 'Option' , 'Label' , 'Fieldset' , 'Legend' , 'Details' ,
47- 'Summary' , 'Main' , 'Header' , 'Footer' , 'Section' , 'Article' , 'Aside' , 'Figure' ,
48- 'Figcaption' , 'Mark' , 'Small' , 'Iframe' , 'Object' , 'Embed' , 'Param' , 'Video' ,
49- 'Audio' , 'Source' , 'Canvas' , 'Svg' , 'Math' , 'Script' , 'Noscript' , 'Template' , 'Slot' ]
38+ 'Div' , 'Span' , 'P' , 'H1' , 'H2' , 'H3' , 'H4' , 'H5' , 'H6' , 'Strong' , 'Em' , 'B' ,
39+ 'I' , 'U' , 'S' , 'Strike' , 'Sub' , 'Sup' , 'Hr' , 'Br' , 'Img' , 'A' , 'Link' , 'Nav' ,
40+ 'Ul' , 'Ol' , 'Li' , 'Dl' , 'Dt' , 'Dd' , 'Table' , 'Thead' , 'Tbody' , 'Tfoot' , 'Tr' ,
41+ 'Th' , 'Td' , 'Caption' , 'Col' , 'Colgroup' , 'Form' , 'Input' , 'Textarea' ,
42+ 'Button' , 'Select' , 'Option' , 'Label' , 'Fieldset' , 'Legend' , 'Details' ,
43+ 'Summary' , 'Main' , 'Header' , 'Footer' , 'Section' , 'Article' , 'Aside' , 'Figure' ,
44+ 'Figcaption' , 'Mark' , 'Small' , 'Iframe' , 'Object' , 'Embed' , 'Param' , 'Video' ,
45+ 'Audio' , 'Source' , 'Canvas' , 'Svg' , 'Math' , 'Script' , 'Noscript' , 'Template' , 'Slot' ]
5046
5147for o in _all_ : _g [o ] = partial (xt , o .lower ())
5248
53- # %% ../nbs/11_xml.ipynb 13
49+ # %% ../nbs/11_xml.ipynb 10
5450voids = set ('area base br col command embed hr img input keygen link meta param source track wbr' .split ())
5551
56- # %% ../nbs/11_xml.ipynb 14
52+ # %% ../nbs/11_xml.ipynb 11
5753def to_xml (elm , lvl = 0 ):
5854 "Convert `xt` element tree into an XML string"
5955 if isinstance (elm , tuple ): return '\n ' .join (to_xml (o ) for o in elm )
@@ -76,7 +72,7 @@ def to_xml(elm, lvl=0):
7672 if tag not in voids : res += f'{ sp } { cltag } \n '
7773 return res
7874
79- # %% ../nbs/11_xml.ipynb 16
75+ # %% ../nbs/11_xml.ipynb 13
8076@patch
8177def _repr_markdown_ (self :XT ):
8278 try : from IPython import display
0 commit comments