Skip to content

Commit

Permalink
fixes #601
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 11, 2024
1 parent 9513aec commit 740e093
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion fastcore/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def __getattr__(self, k):
def get(self, k, default=None): return self[2].get(k.lstrip('_').replace('_', '-'), default)

# %% ../nbs/11_xml.ipynb
_specials = set('@.-!~:[](){}$%^&*+=|/?<>,`')

def attrmap(o):
if o=='_': return o
if o=='_' or (_specials & set(o)): return o
o = dict(htmlClass='class', cls='class', _class='class', klass='class',
_for='for', fr='for', htmlFor='for').get(o, o)
return o.lstrip('_').replace('_', '-')
Expand Down
4 changes: 3 additions & 1 deletion nbs/11_xml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
"outputs": [],
"source": [
"#| export\n",
"_specials = set('@.-!~:[](){}$%^&*+=|/?<>,`')\n",
"\n",
"def attrmap(o):\n",
" if o=='_': return o\n",
" if o=='_' or (_specials & set(o)): return o\n",
" o = dict(htmlClass='class', cls='class', _class='class', klass='class',\n",
" _for='for', fr='for', htmlFor='for').get(o, o)\n",
" return o.lstrip('_').replace('_', '-')"
Expand Down

0 comments on commit 740e093

Please sign in to comment.