|
79 | 79 | "outputs": [ |
80 | 80 | { |
81 | 81 | "data": { |
82 | | - "text/markdown": "```html\n<p id=\"sentence_id\">\n<strong>FastHTML is <i>Fast</i></strong></p>\n\n```", |
| 82 | + "text/markdown": [ |
| 83 | + "```html\n", |
| 84 | + "<p id=\"sentence_id\">\n", |
| 85 | + "<strong>FastHTML is <i>Fast</i></strong></p>\n", |
| 86 | + "\n", |
| 87 | + "```" |
| 88 | + ], |
83 | 89 | "text/plain": [ |
84 | 90 | "p((strong(('FastHTML is ', i(('Fast',),{})),{}),),{'id': 'sentence_id'})" |
85 | 91 | ] |
|
328 | 334 | "outputs": [ |
329 | 335 | { |
330 | 336 | "data": { |
331 | | - "text/markdown": "```html\n<a @click.away=\"1\"></a>\n```", |
| 337 | + "text/markdown": [ |
| 338 | + "```html\n", |
| 339 | + "<a @click.away=\"1\"></a>\n", |
| 340 | + "```" |
| 341 | + ], |
332 | 342 | "text/plain": [ |
333 | 343 | "a((),{'@click.away': 1})" |
334 | 344 | ] |
|
350 | 360 | "outputs": [ |
351 | 361 | { |
352 | 362 | "data": { |
353 | | - "text/markdown": "```html\n<a @click.away=\"1\"></a>\n```", |
| 363 | + "text/markdown": [ |
| 364 | + "```html\n", |
| 365 | + "<a @click.away=\"1\"></a>\n", |
| 366 | + "```" |
| 367 | + ], |
354 | 368 | "text/plain": [ |
355 | 369 | "a((),{'@click.away': 1})" |
356 | 370 | ] |
|
372 | 386 | "outputs": [ |
373 | 387 | { |
374 | 388 | "data": { |
375 | | - "text/markdown": "```html\n<a @click.away=\"1\"></a>\n```", |
| 389 | + "text/markdown": [ |
| 390 | + "```html\n", |
| 391 | + "<a @click.away=\"1\"></a>\n", |
| 392 | + "```" |
| 393 | + ], |
376 | 394 | "text/plain": [ |
377 | 395 | "a((),{'@click.away': 1})" |
378 | 396 | ] |
|
382 | 400 | "output_type": "execute_result" |
383 | 401 | } |
384 | 402 | ], |
385 | | - "source": "ft_html('a', UserDict({'@click.away':1}))" |
| 403 | + "source": [ |
| 404 | + "ft_html('a', UserDict({'@click.away':1}))" |
| 405 | + ] |
386 | 406 | }, |
387 | 407 | { |
388 | 408 | "cell_type": "code", |
|
402 | 422 | "outputs": [ |
403 | 423 | { |
404 | 424 | "data": { |
405 | | - "text/markdown": "```html\n<a id=\"someid\" name=\"someid\"></a>\n```", |
| 425 | + "text/markdown": [ |
| 426 | + "```html\n", |
| 427 | + "<a id=\"someid\" name=\"someid\"></a>\n", |
| 428 | + "```" |
| 429 | + ], |
406 | 430 | "text/plain": [ |
407 | 431 | "a((),{'id': 'someid', 'name': 'someid'})" |
408 | 432 | ] |
|
440 | 464 | "outputs": [ |
441 | 465 | { |
442 | 466 | "data": { |
443 | | - "text/markdown": "```html\n<a hx-vals='{\"a\": 1}'></a>\n```", |
| 467 | + "text/markdown": [ |
| 468 | + "```html\n", |
| 469 | + "<a hx-vals='{\"a\": 1}'></a>\n", |
| 470 | + "```" |
| 471 | + ], |
444 | 472 | "text/plain": [ |
445 | 473 | "a((),{'hx-vals': '{\"a\": 1}'})" |
446 | 474 | ] |
|
462 | 490 | "outputs": [ |
463 | 491 | { |
464 | 492 | "data": { |
465 | | - "text/markdown": "```html\n<a hx-target=\"#someid\"></a>\n```", |
| 493 | + "text/markdown": [ |
| 494 | + "```html\n", |
| 495 | + "<a hx-target=\"#someid\"></a>\n", |
| 496 | + "```" |
| 497 | + ], |
466 | 498 | "text/plain": [ |
467 | 499 | "a((),{'hx-target': '#someid'})" |
468 | 500 | ] |
|
514 | 546 | "outputs": [ |
515 | 547 | { |
516 | 548 | "data": { |
517 | | - "text/markdown": "```html\n<form hx-post=\"/\" hx-target=\"#tgt\" id=\"frm\" name=\"frm\"><button hx-target=\"#foo\" id=\"btn\" name=\"btn\"></button></form>\n```", |
| 549 | + "text/markdown": [ |
| 550 | + "```html\n", |
| 551 | + "<form hx-post=\"/\" hx-target=\"#tgt\" id=\"frm\" name=\"frm\"><button hx-target=\"#foo\" id=\"btn\" name=\"btn\"></button></form>\n", |
| 552 | + "```" |
| 553 | + ], |
518 | 554 | "text/plain": [ |
519 | 555 | "form((button((),{'hx-target': '#foo', 'id': 'btn', 'name': 'btn'}),),{'hx-post': '/', 'hx-target': '#tgt', 'id': 'frm', 'name': 'frm'})" |
520 | 556 | ] |
|
550 | 586 | "outputs": [ |
551 | 587 | { |
552 | 588 | "data": { |
553 | | - "text/markdown": "```html\n<input name=\"nm\">\n\n```", |
| 589 | + "text/markdown": [ |
| 590 | + "```html\n", |
| 591 | + "<input name=\"nm\">\n", |
| 592 | + "\n", |
| 593 | + "```" |
| 594 | + ], |
554 | 595 | "text/plain": [ |
555 | 596 | "input((),{'name': 'nm'})" |
556 | 597 | ] |
|
573 | 614 | "outputs": [ |
574 | 615 | { |
575 | 616 | "data": { |
576 | | - "text/markdown": "```html\n<input name=\"nm\" hx-swap-oob=\"true\">\n\n```", |
| 617 | + "text/markdown": [ |
| 618 | + "```html\n", |
| 619 | + "<input name=\"nm\" hx-swap-oob=\"true\">\n", |
| 620 | + "\n", |
| 621 | + "```" |
| 622 | + ], |
577 | 623 | "text/plain": [ |
578 | 624 | "input((),{'name': 'nm', 'hx-swap-oob': 'true'})" |
579 | 625 | ] |
|
595 | 641 | "outputs": [ |
596 | 642 | { |
597 | 643 | "data": { |
598 | | - "text/markdown": "```html\n<input name=\"nm\" hx-swap-oob=\"true\">\n\n```", |
| 644 | + "text/markdown": [ |
| 645 | + "```html\n", |
| 646 | + "<input name=\"nm\" hx-swap-oob=\"true\">\n", |
| 647 | + "\n", |
| 648 | + "```" |
| 649 | + ], |
599 | 650 | "text/plain": [ |
600 | 651 | "input((),{'name': 'nm', 'hx-swap-oob': 'true'})" |
601 | 652 | ] |
|
627 | 678 | "#| export\n", |
628 | 679 | "def show(ft, *rest, iframe=False, height='auto', style=None):\n", |
629 | 680 | " \"Renders FT Components into HTML within a Jupyter notebook.\"\n", |
| 681 | + " if isinstance(ft, str): ft = Safe(ft)\n", |
630 | 682 | " if rest: ft = (ft,)+rest\n", |
631 | 683 | " res = to_xml(ft)\n", |
632 | 684 | " if iframe:\n", |
|
722 | 774 | "show(fullpage, height=100, iframe=True)" |
723 | 775 | ] |
724 | 776 | }, |
| 777 | + { |
| 778 | + "cell_type": "markdown", |
| 779 | + "id": "7db522d2", |
| 780 | + "metadata": {}, |
| 781 | + "source": [ |
| 782 | + "Plain strings also work:" |
| 783 | + ] |
| 784 | + }, |
| 785 | + { |
| 786 | + "cell_type": "code", |
| 787 | + "execution_count": null, |
| 788 | + "id": "727d32b3", |
| 789 | + "metadata": {}, |
| 790 | + "outputs": [ |
| 791 | + { |
| 792 | + "data": { |
| 793 | + "text/html": [ |
| 794 | + "<p>Hi <i>everyone</i></p>" |
| 795 | + ], |
| 796 | + "text/plain": [ |
| 797 | + "<IPython.core.display.HTML object>" |
| 798 | + ] |
| 799 | + }, |
| 800 | + "metadata": {}, |
| 801 | + "output_type": "display_data" |
| 802 | + } |
| 803 | + ], |
| 804 | + "source": [ |
| 805 | + "show(\"<p>Hi <i>everyone</i></p>\")" |
| 806 | + ] |
| 807 | + }, |
725 | 808 | { |
726 | 809 | "cell_type": "markdown", |
727 | 810 | "id": "41a00fe7", |
|
791 | 874 | "outputs": [ |
792 | 875 | { |
793 | 876 | "data": { |
794 | | - "text/markdown": "```html\n<form><fieldset name=\"stuff\"> <input value=\"Profit\" id=\"title\" class=\"char\" name=\"title\">\n<label class=\"px-2\"> <input type=\"checkbox\" name=\"done\" data-foo=\"bar\" class=\"checkboxer\" checked=\"1\">\nDone</label> <input type=\"hidden\" id=\"id\" name=\"id\" value=\"2\">\n<select name=\"opt\"><option value=\"a\"></option><option value=\"b\" selected=\"1\"></option></select><textarea id=\"details\" name=\"details\">Details</textarea><button>Save</button></fieldset></form>\n```", |
| 877 | + "text/markdown": [ |
| 878 | + "```html\n", |
| 879 | + "<form><fieldset name=\"stuff\"> <input value=\"Profit\" id=\"title\" class=\"char\" name=\"title\">\n", |
| 880 | + "<label class=\"px-2\"> <input type=\"checkbox\" name=\"done\" data-foo=\"bar\" class=\"checkboxer\" checked=\"1\">\n", |
| 881 | + "Done</label> <input type=\"hidden\" id=\"id\" name=\"id\" value=\"2\">\n", |
| 882 | + "<select name=\"opt\"><option value=\"a\"></option><option value=\"b\" selected=\"1\"></option></select><textarea id=\"details\" name=\"details\">Details</textarea><button>Save</button></fieldset></form>\n", |
| 883 | + "```" |
| 884 | + ], |
795 | 885 | "text/plain": [ |
796 | 886 | "form((fieldset((input((),{'value': 'Profit', 'id': 'title', 'class': 'char', 'name': 'title'}), label((input((),{'type': 'checkbox', 'name': 'done', 'data-foo': 'bar', 'class': 'checkboxer', 'checked': '1'}), 'Done'),{'class': 'px-2'}), input((),{'type': 'hidden', 'id': 'id', 'name': 'id', 'value': 2}), select((option((),{'value': 'a'}), option((),{'value': 'b', 'selected': '1'})),{'name': 'opt'}), textarea(('Details',),{'id': 'details', 'name': 'details'}), button(('Save',),{})),{'name': 'stuff'}),),{})" |
797 | 887 | ] |
|
825 | 915 | "outputs": [ |
826 | 916 | { |
827 | 917 | "data": { |
828 | | - "text/markdown": "```html\n<form><select multiple=\"1\" name=\"items\"><option value=\"a\" selected=\"1\">a</option><option value=\"b\">b</option><option value=\"c\" selected=\"1\">c</option></select></form>\n```", |
| 918 | + "text/markdown": [ |
| 919 | + "```html\n", |
| 920 | + "<form><select multiple=\"1\" name=\"items\"><option value=\"a\" selected=\"1\">a</option><option value=\"b\">b</option><option value=\"c\" selected=\"1\">c</option></select></form>\n", |
| 921 | + "```" |
| 922 | + ], |
829 | 923 | "text/plain": [ |
830 | 924 | "form((select((option(('a',),{'value': 'a', 'selected': '1'}), option(('b',),{'value': 'b'}), option(('c',),{'value': 'c', 'selected': '1'})),{'multiple': '1', 'name': 'items'}),),{})" |
831 | 925 | ] |
|
857 | 951 | "outputs": [ |
858 | 952 | { |
859 | 953 | "data": { |
860 | | - "text/markdown": "```html\n<form><fieldset><label> <input type=\"checkbox\" name=\"items\" value=\"a\" checked=\"1\">\na</label><label> <input type=\"checkbox\" name=\"items\" value=\"b\">\nb</label><label> <input type=\"checkbox\" name=\"items\" value=\"c\" checked=\"1\">\nc</label></fieldset></form>\n```", |
| 954 | + "text/markdown": [ |
| 955 | + "```html\n", |
| 956 | + "<form><fieldset><label> <input type=\"checkbox\" name=\"items\" value=\"a\" checked=\"1\">\n", |
| 957 | + "a</label><label> <input type=\"checkbox\" name=\"items\" value=\"b\">\n", |
| 958 | + "b</label><label> <input type=\"checkbox\" name=\"items\" value=\"c\" checked=\"1\">\n", |
| 959 | + "c</label></fieldset></form>\n", |
| 960 | + "```" |
| 961 | + ], |
861 | 962 | "text/plain": [ |
862 | 963 | "form((fieldset((label((input((),{'type': 'checkbox', 'name': 'items', 'value': 'a', 'checked': '1'}), 'a'),{}), label((input((),{'type': 'checkbox', 'name': 'items', 'value': 'b'}), 'b'),{}), label((input((),{'type': 'checkbox', 'name': 'items', 'value': 'c', 'checked': '1'}), 'c'),{})),{}),),{})" |
863 | 964 | ] |
|
1064 | 1165 | "outputs": [ |
1065 | 1166 | { |
1066 | 1167 | "data": { |
1067 | | - "text/markdown": "```python\nForm(\n Fieldset(\n Input(value='Profit', id='title', name='title', cls='char'),\n Label(\n Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer'),\n 'Done',\n cls='px-2'\n ),\n Input(type='hidden', id='id', name='id', value='2'),\n Select(\n Option(value='a'),\n Option(value='b', selected='1'),\n name='opt'\n ),\n Textarea('Details', id='details', name='details'),\n Button('Save'),\n name='stuff'\n )\n)\n```", |
| 1168 | + "text/markdown": [ |
| 1169 | + "```python\n", |
| 1170 | + "Form(\n", |
| 1171 | + " Fieldset(\n", |
| 1172 | + " Input(value='Profit', id='title', name='title', cls='char'),\n", |
| 1173 | + " Label(\n", |
| 1174 | + " Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer'),\n", |
| 1175 | + " 'Done',\n", |
| 1176 | + " cls='px-2'\n", |
| 1177 | + " ),\n", |
| 1178 | + " Input(type='hidden', id='id', name='id', value='2'),\n", |
| 1179 | + " Select(\n", |
| 1180 | + " Option(value='a'),\n", |
| 1181 | + " Option(value='b', selected='1'),\n", |
| 1182 | + " name='opt'\n", |
| 1183 | + " ),\n", |
| 1184 | + " Textarea('Details', id='details', name='details'),\n", |
| 1185 | + " Button('Save'),\n", |
| 1186 | + " name='stuff'\n", |
| 1187 | + " )\n", |
| 1188 | + ")\n", |
| 1189 | + "```" |
| 1190 | + ], |
1068 | 1191 | "text/plain": [ |
1069 | 1192 | "<IPython.core.display.Markdown object>" |
1070 | 1193 | ] |
|
1087 | 1210 | "outputs": [ |
1088 | 1211 | { |
1089 | 1212 | "data": { |
1090 | | - "text/markdown": "```python\nForm(\n Fieldset(name='stuff')(\n Input(value='Profit', id='title', name='title', cls='char')(),\n Label(cls='px-2')(\n Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer')(),\n 'Done'\n ),\n Input(type='hidden', id='id', name='id', value='2')(),\n Select(name='opt')(\n Option(value='a')(),\n Option(value='b', selected='1')()\n ),\n Textarea(id='details', name='details')('Details'),\n Button()('Save')\n )\n)\n```", |
| 1213 | + "text/markdown": [ |
| 1214 | + "```python\n", |
| 1215 | + "Form(\n", |
| 1216 | + " Fieldset(name='stuff')(\n", |
| 1217 | + " Input(value='Profit', id='title', name='title', cls='char')(),\n", |
| 1218 | + " Label(cls='px-2')(\n", |
| 1219 | + " Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer')(),\n", |
| 1220 | + " 'Done'\n", |
| 1221 | + " ),\n", |
| 1222 | + " Input(type='hidden', id='id', name='id', value='2')(),\n", |
| 1223 | + " Select(name='opt')(\n", |
| 1224 | + " Option(value='a')(),\n", |
| 1225 | + " Option(value='b', selected='1')()\n", |
| 1226 | + " ),\n", |
| 1227 | + " Textarea(id='details', name='details')('Details'),\n", |
| 1228 | + " Button()('Save')\n", |
| 1229 | + " )\n", |
| 1230 | + ")\n", |
| 1231 | + "```" |
| 1232 | + ], |
1091 | 1233 | "text/plain": [ |
1092 | 1234 | "<IPython.core.display.Markdown object>" |
1093 | 1235 | ] |
|
1195 | 1337 | "cell_type": "markdown", |
1196 | 1338 | "id": "474e14b4", |
1197 | 1339 | "metadata": {}, |
1198 | | - "source": "\"## Export -" |
| 1340 | + "source": [ |
| 1341 | + "## Export -" |
| 1342 | + ] |
1199 | 1343 | }, |
1200 | 1344 | { |
1201 | 1345 | "cell_type": "code", |
|
1214 | 1358 | "id": "74aeda124534ac06", |
1215 | 1359 | "metadata": {}, |
1216 | 1360 | "outputs": [], |
1217 | | - "source": "" |
| 1361 | + "source": [] |
1218 | 1362 | } |
1219 | 1363 | ], |
1220 | 1364 | "metadata": { |
|
0 commit comments