python-fasthtml 0.1.8__tar.gz → 0.1.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_fasthtml-0.1.8/python_fasthtml.egg-info → python_fasthtml-0.1.10}/PKG-INFO +2 -2
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/__init__.py +1 -1
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/_modidx.py +8 -8
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/cli.py +4 -4
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/components.py +29 -29
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/components.pyi +8 -8
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/core.py +94 -103
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/fastapp.py +3 -3
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/oauth.py +10 -10
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/svg.py +2 -2
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/xtend.py +64 -62
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/xtend.pyi +15 -15
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10/python_fasthtml.egg-info}/PKG-INFO +2 -2
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/SOURCES.txt +1 -1
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/requires.txt +1 -1
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/settings.ini +3 -2
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/LICENSE +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/MANIFEST.in +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/README.md +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/authmw.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/common.py +0 -0
- /python_fasthtml-0.1.8/fasthtml/xt.py → /python_fasthtml-0.1.10/fasthtml/ft.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/js.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/live_reload.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/starlette.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/fasthtml/toaster.py +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/not-zip-safe +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/setup.cfg +0 -0
- {python_fasthtml-0.1.8 → python_fasthtml-0.1.10}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-fasthtml
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
4
4
|
Summary: The fastest way to create an HTML app
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/fasthtml
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: fastcore>=1.
|
|
18
|
+
Requires-Dist: fastcore>=1.6.0
|
|
19
19
|
Requires-Dist: python-dateutil
|
|
20
20
|
Requires-Dist: starlette>0.33
|
|
21
21
|
Requires-Dist: oauthlib
|
|
@@ -16,10 +16,10 @@ d = { 'settings': { 'branch': 'main',
|
|
|
16
16
|
'fasthtml.components.fill_dataclass': ('components.html#fill_dataclass', 'fasthtml/components.py'),
|
|
17
17
|
'fasthtml.components.fill_form': ('components.html#fill_form', 'fasthtml/components.py'),
|
|
18
18
|
'fasthtml.components.find_inputs': ('components.html#find_inputs', 'fasthtml/components.py'),
|
|
19
|
-
'fasthtml.components.
|
|
20
|
-
'fasthtml.components.
|
|
21
|
-
'fasthtml.components.
|
|
22
|
-
'fasthtml.components.
|
|
19
|
+
'fasthtml.components.ft_html': ('components.html#ft_html', 'fasthtml/components.py'),
|
|
20
|
+
'fasthtml.components.ft_hx': ('components.html#ft_hx', 'fasthtml/components.py'),
|
|
21
|
+
'fasthtml.components.html2ft': ('components.html#html2ft', 'fasthtml/components.py'),
|
|
22
|
+
'fasthtml.components.show': ('components.html#show', 'fasthtml/components.py')},
|
|
23
23
|
'fasthtml.core': { 'fasthtml.core.Beforeware': ('core.html#beforeware', 'fasthtml/core.py'),
|
|
24
24
|
'fasthtml.core.Beforeware.__init__': ('core.html#beforeware.__init__', 'fasthtml/core.py'),
|
|
25
25
|
'fasthtml.core.FastHTML': ('core.html#fasthtml', 'fasthtml/core.py'),
|
|
@@ -33,6 +33,9 @@ d = { 'settings': { 'branch': 'main',
|
|
|
33
33
|
'fasthtml.core.MiddlewareBase.__call__': ('core.html#middlewarebase.__call__', 'fasthtml/core.py'),
|
|
34
34
|
'fasthtml.core.RouteX': ('core.html#routex', 'fasthtml/core.py'),
|
|
35
35
|
'fasthtml.core.RouteX.__init__': ('core.html#routex.__init__', 'fasthtml/core.py'),
|
|
36
|
+
'fasthtml.core.RouteX._endp': ('core.html#routex._endp', 'fasthtml/core.py'),
|
|
37
|
+
'fasthtml.core.RouteX._resp': ('core.html#routex._resp', 'fasthtml/core.py'),
|
|
38
|
+
'fasthtml.core.RouteX._xt_resp': ('core.html#routex._xt_resp', 'fasthtml/core.py'),
|
|
36
39
|
'fasthtml.core.RouterX': ('core.html#routerx', 'fasthtml/core.py'),
|
|
37
40
|
'fasthtml.core.RouterX.__init__': ('core.html#routerx.__init__', 'fasthtml/core.py'),
|
|
38
41
|
'fasthtml.core.RouterX.add_route': ('core.html#routerx.add_route', 'fasthtml/core.py'),
|
|
@@ -51,12 +54,9 @@ d = { 'settings': { 'branch': 'main',
|
|
|
51
54
|
'fasthtml.core._list': ('core.html#_list', 'fasthtml/core.py'),
|
|
52
55
|
'fasthtml.core._mk_list': ('core.html#_mk_list', 'fasthtml/core.py'),
|
|
53
56
|
'fasthtml.core._send_ws': ('core.html#_send_ws', 'fasthtml/core.py'),
|
|
54
|
-
'fasthtml.core._wrap_ep': ('core.html#_wrap_ep', 'fasthtml/core.py'),
|
|
55
57
|
'fasthtml.core._wrap_req': ('core.html#_wrap_req', 'fasthtml/core.py'),
|
|
56
|
-
'fasthtml.core._wrap_resp': ('core.html#_wrap_resp', 'fasthtml/core.py'),
|
|
57
58
|
'fasthtml.core._wrap_ws': ('core.html#_wrap_ws', 'fasthtml/core.py'),
|
|
58
59
|
'fasthtml.core._ws_endp': ('core.html#_ws_endp', 'fasthtml/core.py'),
|
|
59
|
-
'fasthtml.core._xt_resp': ('core.html#_xt_resp', 'fasthtml/core.py'),
|
|
60
60
|
'fasthtml.core.cookie': ('core.html#cookie', 'fasthtml/core.py'),
|
|
61
61
|
'fasthtml.core.date': ('core.html#date', 'fasthtml/core.py'),
|
|
62
62
|
'fasthtml.core.flat_xt': ('core.html#flat_xt', 'fasthtml/core.py'),
|
|
@@ -68,6 +68,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
68
68
|
'fasthtml.core.snake2hyphens': ('core.html#snake2hyphens', 'fasthtml/core.py'),
|
|
69
69
|
'fasthtml.core.str2int': ('core.html#str2int', 'fasthtml/core.py')},
|
|
70
70
|
'fasthtml.fastapp': {},
|
|
71
|
+
'fasthtml.ft': {},
|
|
71
72
|
'fasthtml.js': {},
|
|
72
73
|
'fasthtml.live_reload': {},
|
|
73
74
|
'fasthtml.oauth': { 'fasthtml.oauth.GitHubAppClient': ('oauth.html#githubappclient', 'fasthtml/oauth.py'),
|
|
@@ -86,7 +87,6 @@ d = { 'settings': { 'branch': 'main',
|
|
|
86
87
|
'fasthtml.starlette': {},
|
|
87
88
|
'fasthtml.svg': {},
|
|
88
89
|
'fasthtml.toaster': {},
|
|
89
|
-
'fasthtml.xt': {},
|
|
90
90
|
'fasthtml.xtend': { 'fasthtml.xtend.A': ('xtend.html#a', 'fasthtml/xtend.py'),
|
|
91
91
|
'fasthtml.xtend.AX': ('xtend.html#ax', 'fasthtml/xtend.py'),
|
|
92
92
|
'fasthtml.xtend.Card': ('xtend.html#card', 'fasthtml/xtend.py'),
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['railway_link', 'railway_deploy']
|
|
5
5
|
|
|
6
|
-
# %% ../nbs/04_cli.ipynb
|
|
6
|
+
# %% ../nbs/04_cli.ipynb
|
|
7
7
|
from fastcore.utils import *
|
|
8
8
|
from fastcore.script import call_parse, bool_arg
|
|
9
9
|
from subprocess import check_output, run
|
|
10
10
|
|
|
11
11
|
import json
|
|
12
12
|
|
|
13
|
-
# %% ../nbs/04_cli.ipynb
|
|
13
|
+
# %% ../nbs/04_cli.ipynb
|
|
14
14
|
@call_parse
|
|
15
15
|
def railway_link():
|
|
16
16
|
"Link the current directory to the current project's Railway service"
|
|
@@ -23,12 +23,12 @@ def railway_link():
|
|
|
23
23
|
cmd = f"railway link -e {env} -p {prj} -s {svc}"
|
|
24
24
|
res = check_output(cmd.split())
|
|
25
25
|
|
|
26
|
-
# %% ../nbs/04_cli.ipynb
|
|
26
|
+
# %% ../nbs/04_cli.ipynb
|
|
27
27
|
def _run(a, **kw):
|
|
28
28
|
print('#', ' '.join(a))
|
|
29
29
|
run(a)
|
|
30
30
|
|
|
31
|
-
# %% ../nbs/04_cli.ipynb
|
|
31
|
+
# %% ../nbs/04_cli.ipynb
|
|
32
32
|
@call_parse
|
|
33
33
|
def railway_deploy(
|
|
34
34
|
name:str, # The project name to deploy
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_components.ipynb.
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
|
-
__all__ = ['voids', 'named', 'html_attrs', 'hx_attrs', 'show', '
|
|
5
|
-
'find_inputs', '
|
|
4
|
+
__all__ = ['voids', 'named', 'html_attrs', 'hx_attrs', 'show', 'ft_html', 'ft_hx', 'File', 'fill_form', 'fill_dataclass',
|
|
5
|
+
'find_inputs', 'html2ft', 'A', 'Abbr', 'Address', 'Area', 'Article', 'Aside', 'Audio', 'B', 'Base', 'Bdi',
|
|
6
6
|
'Bdo', 'Blockquote', 'Body', 'Br', 'Button', 'Canvas', 'Caption', 'Cite', 'Code', 'Col', 'Colgroup', 'Data',
|
|
7
7
|
'Datalist', 'Dd', 'Del', 'Details', 'Dfn', 'Dialog', 'Div', 'Dl', 'Dt', 'Em', 'Embed', 'Fencedframe',
|
|
8
8
|
'Fieldset', 'Figcaption', 'Figure', 'Footer', 'Form', 'H1', 'Head', 'Header', 'Hgroup', 'Hr', 'Html', 'I',
|
|
@@ -13,7 +13,7 @@ __all__ = ['voids', 'named', 'html_attrs', 'hx_attrs', 'show', 'xt_html', 'xt_hx
|
|
|
13
13
|
'Td', 'Template', 'Textarea', 'Tfoot', 'Th', 'Thead', 'Time', 'Title', 'Tr', 'Track', 'U', 'Ul', 'Var',
|
|
14
14
|
'Video', 'Wbr']
|
|
15
15
|
|
|
16
|
-
# %% ../nbs/01_components.ipynb
|
|
16
|
+
# %% ../nbs/01_components.ipynb
|
|
17
17
|
from dataclasses import dataclass, asdict, is_dataclass, make_dataclass, replace, astuple, MISSING
|
|
18
18
|
from bs4 import BeautifulSoup, Comment
|
|
19
19
|
|
|
@@ -26,33 +26,33 @@ import types
|
|
|
26
26
|
try: from IPython import display
|
|
27
27
|
except ImportError: display=None
|
|
28
28
|
|
|
29
|
-
# %% ../nbs/01_components.ipynb
|
|
30
|
-
def show(
|
|
31
|
-
if rest:
|
|
32
|
-
return display.HTML(to_xml(
|
|
29
|
+
# %% ../nbs/01_components.ipynb
|
|
30
|
+
def show(ft,*rest):
|
|
31
|
+
if rest: ft = (ft,)+rest
|
|
32
|
+
return display.HTML(to_xml(ft))
|
|
33
33
|
|
|
34
|
-
# %% ../nbs/01_components.ipynb
|
|
34
|
+
# %% ../nbs/01_components.ipynb
|
|
35
35
|
voids = set('area base br col command embed hr img input keygen link meta param source track wbr !doctype'.split())
|
|
36
36
|
named = set('a button form frame iframe img input map meta object param select textarea'.split())
|
|
37
37
|
html_attrs = 'id cls title style accesskey contenteditable dir draggable enterkeyhint hidden inert inputmode lang popover spellcheck tabindex translate'.split()
|
|
38
38
|
hx_attrs = 'get post put delete patch trigger target swap include select indicator push_url confirm disable replace_url on'
|
|
39
39
|
hx_attrs = html_attrs + [f'hx_{o}' for o in hx_attrs.split()]
|
|
40
40
|
|
|
41
|
-
# %% ../nbs/01_components.ipynb
|
|
42
|
-
def
|
|
41
|
+
# %% ../nbs/01_components.ipynb
|
|
42
|
+
def ft_html(tag: str, *c, id=None, cls=None, title=None, style=None, **kwargs):
|
|
43
43
|
if len(c)==1 and isinstance(c[0], (types.GeneratorType, map, filter)): c = tuple(c[0])
|
|
44
44
|
kwargs['id'],kwargs['cls'],kwargs['title'],kwargs['style'] = id,cls,title,style
|
|
45
|
-
tag,c,kw =
|
|
45
|
+
tag,c,kw = ft(tag, *c, **kwargs)
|
|
46
46
|
if tag in named and 'id' in kw and 'name' not in kw: kw['name'] = kw['id']
|
|
47
|
-
return
|
|
47
|
+
return FT(tag,c,kw, void_=tag in voids)
|
|
48
48
|
|
|
49
|
-
# %% ../nbs/01_components.ipynb
|
|
49
|
+
# %% ../nbs/01_components.ipynb
|
|
50
50
|
@use_kwargs(hx_attrs, keep=True)
|
|
51
|
-
def
|
|
51
|
+
def ft_hx(tag: str, *c, target_id=None, **kwargs):
|
|
52
52
|
if target_id: kwargs['hx_target'] = '#'+target_id
|
|
53
|
-
return
|
|
53
|
+
return ft_html(tag, *c, **kwargs)
|
|
54
54
|
|
|
55
|
-
# %% ../nbs/01_components.ipynb
|
|
55
|
+
# %% ../nbs/01_components.ipynb
|
|
56
56
|
_g = globals()
|
|
57
57
|
_all_ = [
|
|
58
58
|
'A', 'Abbr', 'Address', 'Area', 'Article', 'Aside', 'Audio', 'B', 'Base', 'Bdi', 'Bdo', 'Blockquote', 'Body', 'Br',
|
|
@@ -63,14 +63,14 @@ _all_ = [
|
|
|
63
63
|
'P', 'Picture', 'PortalExperimental', 'Pre', 'Progress', 'Q', 'Rp', 'Rt', 'Ruby', 'S', 'Samp', 'Script', 'Search',
|
|
64
64
|
'Section', 'Select', 'Slot', 'Small', 'Source', 'Span', 'Strong', 'Style', 'Sub', 'Summary', 'Sup', 'Table', 'Tbody',
|
|
65
65
|
'Td', 'Template', 'Textarea', 'Tfoot', 'Th', 'Thead', 'Time', 'Title', 'Tr', 'Track', 'U', 'Ul', 'Var', 'Video', 'Wbr']
|
|
66
|
-
for o in _all_: _g[o] = partial(
|
|
66
|
+
for o in _all_: _g[o] = partial(ft_hx, o.lower())
|
|
67
67
|
|
|
68
|
-
# %% ../nbs/01_components.ipynb
|
|
68
|
+
# %% ../nbs/01_components.ipynb
|
|
69
69
|
def File(fname):
|
|
70
70
|
"Use the unescaped text in file `fname` directly"
|
|
71
71
|
return NotStr(Path(fname).read_text())
|
|
72
72
|
|
|
73
|
-
# %% ../nbs/01_components.ipynb
|
|
73
|
+
# %% ../nbs/01_components.ipynb
|
|
74
74
|
def _fill_item(item, obj):
|
|
75
75
|
if not isinstance(item,list): return item
|
|
76
76
|
tag,cs,attr = item
|
|
@@ -84,21 +84,21 @@ def _fill_item(item, obj):
|
|
|
84
84
|
else: attr.pop('checked', '')
|
|
85
85
|
else: attr['value'] = val
|
|
86
86
|
if tag=='textarea': cs=(val,)
|
|
87
|
-
return
|
|
87
|
+
return FT(tag,cs,attr)
|
|
88
88
|
|
|
89
|
-
# %% ../nbs/01_components.ipynb
|
|
90
|
-
def fill_form(form:
|
|
89
|
+
# %% ../nbs/01_components.ipynb
|
|
90
|
+
def fill_form(form:FT, obj)->FT:
|
|
91
91
|
"Fills named items in `form` using attributes in `obj`"
|
|
92
92
|
if not isinstance(obj,dict): obj = asdict(obj)
|
|
93
93
|
return _fill_item(form, obj)
|
|
94
94
|
|
|
95
|
-
# %% ../nbs/01_components.ipynb
|
|
95
|
+
# %% ../nbs/01_components.ipynb
|
|
96
96
|
def fill_dataclass(src, dest):
|
|
97
97
|
"Modifies dataclass in-place and returns it"
|
|
98
98
|
for nm,val in asdict(src).items(): setattr(dest, nm, val)
|
|
99
99
|
return dest
|
|
100
100
|
|
|
101
|
-
# %% ../nbs/01_components.ipynb
|
|
101
|
+
# %% ../nbs/01_components.ipynb
|
|
102
102
|
def find_inputs(e, tags='input', **kw):
|
|
103
103
|
# Recursively find all elements in `e` with `tags` and attrs matching `kw`
|
|
104
104
|
if not isinstance(e, (list,tuple)): return []
|
|
@@ -112,17 +112,17 @@ def find_inputs(e, tags='input', **kw):
|
|
|
112
112
|
for o in cs: inputs += find_inputs(o, tags, **kw)
|
|
113
113
|
return inputs
|
|
114
114
|
|
|
115
|
-
# %% ../nbs/01_components.ipynb
|
|
115
|
+
# %% ../nbs/01_components.ipynb
|
|
116
116
|
def __getattr__(tag):
|
|
117
117
|
if tag.startswith('_') or tag[0].islower(): raise AttributeError
|
|
118
118
|
tag = tag.replace("_", "-")
|
|
119
|
-
def _f(*c, target_id=None, **kwargs): return
|
|
119
|
+
def _f(*c, target_id=None, **kwargs): return ft_hx(tag, *c, target_id=target_id, **kwargs)
|
|
120
120
|
return _f
|
|
121
121
|
|
|
122
|
-
# %% ../nbs/01_components.ipynb
|
|
122
|
+
# %% ../nbs/01_components.ipynb
|
|
123
123
|
_re_h2x_attr_key = re.compile(r'^[A-Za-z_-][\w-]*$')
|
|
124
|
-
def
|
|
125
|
-
"""Convert HTML to an `
|
|
124
|
+
def html2ft(html):
|
|
125
|
+
"""Convert HTML to an `ft` expression"""
|
|
126
126
|
rev_map = {'class': 'cls', 'for': 'fr'}
|
|
127
127
|
|
|
128
128
|
def _parse(elm, lvl=0, indent=4):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
__all__ = ['voids', 'named', 'html_attrs', 'hx_attrs', 'show', 'xt_html', 'xt_hx', 'File', 'fill_form', 'fill_dataclass', 'find_inputs', '
|
|
1
|
+
__all__ = ['voids', 'named', 'html_attrs', 'hx_attrs', 'show', 'xt_html', 'xt_hx', 'File', 'fill_form', 'fill_dataclass', 'find_inputs', 'html2ft', 'A', 'Abbr', 'Address', 'Area', 'Article', 'Aside', 'Audio', 'B', 'Base', 'Bdi', 'Bdo', 'Blockquote', 'Body', 'Br', 'Button', 'Canvas', 'Caption', 'Cite', 'Code', 'Col', 'Colgroup', 'Data', 'Datalist', 'Dd', 'Del', 'Details', 'Dfn', 'Dialog', 'Div', 'Dl', 'Dt', 'Em', 'Embed', 'Fencedframe', 'Fieldset', 'Figcaption', 'Figure', 'Footer', 'Form', 'H1', 'Head', 'Header', 'Hgroup', 'Hr', 'Html', 'I', 'Iframe', 'Img', 'Input', 'Ins', 'Kbd', 'Label', 'Legend', 'Li', 'Link', 'Main', 'Map', 'Mark', 'Menu', 'Meta', 'Meter', 'Nav', 'Noscript', 'Object', 'Ol', 'Optgroup', 'Option', 'Output', 'P', 'Picture', 'PortalExperimental', 'Pre', 'Progress', 'Q', 'Rp', 'Rt', 'Ruby', 'S', 'Samp', 'Script', 'Search', 'Section', 'Select', 'Slot', 'Small', 'Source', 'Span', 'Strong', 'Style', 'Sub', 'Summary', 'Sup', 'Table', 'Tbody', 'Td', 'Template', 'Textarea', 'Tfoot', 'Th', 'Thead', 'Time', 'Title', 'Tr', 'Track', 'U', 'Ul', 'Var', 'Video', 'Wbr']
|
|
2
2
|
from dataclasses import dataclass, asdict, is_dataclass, make_dataclass, replace, astuple, MISSING
|
|
3
|
-
from bs4 import BeautifulSoup
|
|
3
|
+
from bs4 import BeautifulSoup, Comment
|
|
4
4
|
from fastcore.utils import *
|
|
5
5
|
from fastcore.xml import *
|
|
6
6
|
from fastcore.meta import use_kwargs, delegates
|
|
@@ -10,7 +10,7 @@ try:
|
|
|
10
10
|
except ImportError:
|
|
11
11
|
display = None
|
|
12
12
|
|
|
13
|
-
def show(
|
|
13
|
+
def show(ft, *rest):
|
|
14
14
|
...
|
|
15
15
|
voids = set('area base br col command embed hr img input keygen link meta param source track wbr !doctype'.split())
|
|
16
16
|
named = set('a button form frame iframe img input map meta object param select textarea'.split())
|
|
@@ -36,7 +36,7 @@ def File(fname):
|
|
|
36
36
|
def _fill_item(item, obj):
|
|
37
37
|
...
|
|
38
38
|
|
|
39
|
-
def fill_form(form:
|
|
39
|
+
def fill_form(form: FT, obj) -> FT:
|
|
40
40
|
"""Fills named items in `form` using attributes in `obj`"""
|
|
41
41
|
...
|
|
42
42
|
|
|
@@ -51,11 +51,11 @@ def __getattr__(tag):
|
|
|
51
51
|
...
|
|
52
52
|
_re_h2x_attr_key = re.compile('^[A-Za-z_-][\\w-]*$')
|
|
53
53
|
|
|
54
|
-
def
|
|
55
|
-
"""Convert HTML to an `
|
|
54
|
+
def html2ft(html):
|
|
55
|
+
"""Convert HTML to an `ft` expression"""
|
|
56
56
|
...
|
|
57
|
-
def
|
|
58
|
-
def
|
|
57
|
+
def ft_html(tag: str, *c, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, hx_get:str|None=None, hx_post:str|None=None, hx_put:str|None=None, hx_delete:str|None=None, hx_patch:str|None=None, hx_trigger:str|None=None, hx_target:str|None=None, hx_swap:str|None=None, hx_include:str|None=None, hx_select:str|None=None, hx_indicator:str|None=None, hx_push_url:str|None=None, hx_confirm:str|None=None, hx_disable:str|None=None, hx_replace_url:str|None=None, hx_on:str|None=None, **kwargs): ...
|
|
58
|
+
def ft_hx(tag: str, *c, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, hx_get:str|None=None, hx_post:str|None=None, hx_put:str|None=None, hx_delete:str|None=None, hx_patch:str|None=None, hx_trigger:str|None=None, hx_target:str|None=None, hx_swap:str|None=None, hx_include:str|None=None, hx_select:str|None=None, hx_indicator:str|None=None, hx_push_url:str|None=None, hx_confirm:str|None=None, hx_disable:str|None=None, hx_replace_url:str|None=None, hx_on:str|None=None, **kwargs): ...
|
|
59
59
|
def A(*c, name:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, hx_get:str|None=None, hx_post:str|None=None, hx_put:str|None=None, hx_delete:str|None=None, hx_patch:str|None=None, hx_trigger:str|None=None, hx_target:str|None=None, hx_swap:str|None=None, hx_include:str|None=None, hx_select:str|None=None, hx_indicator:str|None=None, hx_push_url:str|None=None, hx_confirm:str|None=None, hx_disable:str|None=None, hx_replace_url:str|None=None, hx_on:str|None=None, **kwargs): ...
|
|
60
60
|
def Abbr(*c, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, hx_get:str|None=None, hx_post:str|None=None, hx_put:str|None=None, hx_delete:str|None=None, hx_patch:str|None=None, hx_trigger:str|None=None, hx_target:str|None=None, hx_swap:str|None=None, hx_include:str|None=None, hx_select:str|None=None, hx_indicator:str|None=None, hx_push_url:str|None=None, hx_confirm:str|None=None, hx_disable:str|None=None, hx_replace_url:str|None=None, hx_on:str|None=None, **kwargs): ...
|
|
61
61
|
def Address(*c, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, id:str|None=None, cls:str|None=None, title:str|None=None, style:str|None=None, accesskey:str|None=None, contenteditable:str|None=None, dir:str|None=None, draggable:str|None=None, enterkeyhint:str|None=None, hidden:str|None=None, inert:str|None=None, inputmode:str|None=None, lang:str|None=None, popover:str|None=None, spellcheck:str|None=None, tabindex:str|None=None, translate:str|None=None, hx_get:str|None=None, hx_post:str|None=None, hx_put:str|None=None, hx_delete:str|None=None, hx_patch:str|None=None, hx_trigger:str|None=None, hx_target:str|None=None, hx_swap:str|None=None, hx_include:str|None=None, hx_select:str|None=None, hx_indicator:str|None=None, hx_push_url:str|None=None, hx_confirm:str|None=None, hx_disable:str|None=None, hx_replace_url:str|None=None, hx_on:str|None=None, **kwargs): ...
|