Skip to content

Commit 13e2dea

Browse files
committed
fixes #677
1 parent 1a4430e commit 13e2dea

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

fastcore/xml.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,16 @@ def _to_xml(elm, lvl=0, indent=True, do_escape=True):
189189
if sattrs: stag += f' {sattrs}'
190190

191191
cltag = '' if is_void else f'</{tag}>'
192+
stag_ = f'<{stag}>' if stag else ''
192193

193194
if not cs:
194-
if is_void: return f'{sp}<{stag}>{nl_end}'
195-
else: return f'{sp}<{stag}>{cltag}{nl_end}'
195+
if is_void: return f'{sp}{stag_}{nl_end}'
196+
else: return f'{sp}{stag_}{cltag}{nl_end}'
196197
if len(cs) == 1 and not isinstance(cs[0], (list, tuple, FT)) and not hasattr(cs[0], '__ft__'):
197198
content = esc_fn(cs[0])
198-
return f'{sp}<{stag}>{content}{cltag}{nl_end}'
199+
return f'{sp}{stag_}{content}{cltag}{nl_end}'
199200

200-
res = f'{sp}<{stag}>{nl}'
201+
res = f'{sp}{stag_}{nl}'
201202
for c in cs:
202203
res += _to_xml(c, lvl=lvl+2 if indent else 0, indent=indent, do_escape=do_escape)
203204
if not is_void: res += f'{sp}{cltag}{nl_end}'

nbs/03_xtras.ipynb

+9-2
Original file line numberDiff line numberDiff line change
@@ -1914,8 +1914,15 @@
19141914
"metadata": {},
19151915
"outputs": [],
19161916
"source": [
1917-
"from plum import Function\n",
1918-
"\n",
1917+
"from plum import Function"
1918+
]
1919+
},
1920+
{
1921+
"cell_type": "code",
1922+
"execution_count": null,
1923+
"metadata": {},
1924+
"outputs": [],
1925+
"source": [
19191926
"def f1(x): return \"Any\"\n",
19201927
"def f2(x:int): return \"Int\"\n",
19211928
"\n",

nbs/09_xml.ipynb

+5-4
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,16 @@
441441
" if sattrs: stag += f' {sattrs}'\n",
442442
"\n",
443443
" cltag = '' if is_void else f'</{tag}>'\n",
444+
" stag_ = f'<{stag}>' if stag else ''\n",
444445
"\n",
445446
" if not cs:\n",
446-
" if is_void: return f'{sp}<{stag}>{nl_end}'\n",
447-
" else: return f'{sp}<{stag}>{cltag}{nl_end}'\n",
447+
" if is_void: return f'{sp}{stag_}{nl_end}'\n",
448+
" else: return f'{sp}{stag_}{cltag}{nl_end}'\n",
448449
" if len(cs) == 1 and not isinstance(cs[0], (list, tuple, FT)) and not hasattr(cs[0], '__ft__'):\n",
449450
" content = esc_fn(cs[0])\n",
450-
" return f'{sp}<{stag}>{content}{cltag}{nl_end}'\n",
451+
" return f'{sp}{stag_}{content}{cltag}{nl_end}'\n",
451452
"\n",
452-
" res = f'{sp}<{stag}>{nl}'\n",
453+
" res = f'{sp}{stag_}{nl}'\n",
453454
" for c in cs:\n",
454455
" res += _to_xml(c, lvl=lvl+2 if indent else 0, indent=indent, do_escape=do_escape)\n",
455456
" if not is_void: res += f'{sp}{cltag}{nl_end}'\n",

nbs/nbdev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ website:
55
title: "fastcore"
66
site-url: "https://fastcore.fast.ai/"
77
description: "Python supercharged for fastai development"
8-
repo-branch: master
8+
repo-branch: main
99
repo-url: "https://github.com/AnswerDotAI/fastcore/"

0 commit comments

Comments
 (0)