File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,14 @@ a .markdown iconify-icon:first-child {
7878 margin-inline-end : 0.4em ;
7979}
8080
81+ iconify-icon {
82+ display : inline-flex;
83+ align-items : center;
84+ }
85+
8186/* align icons with buttons better */
8287button .markdown .paragraph {
88+ display : inline-flex;
8389 align-items : baseline;
8490 gap : 0.4em ;
8591
Original file line number Diff line number Diff line change @@ -462,4 +462,31 @@ describe("sanitizeHtml", () => {
462462 `"<details><summary>Click me</summary><p>Hidden content</p></details>"` ,
463463 ) ;
464464 } ) ;
465+
466+ test ( "preserves iconify-icon custom element" , ( ) => {
467+ const html = '<iconify-icon icon="lucide:leaf"></iconify-icon>' ;
468+ expect ( sanitizeHtml ( html ) ) . toMatchInlineSnapshot (
469+ `"<iconify-icon icon="lucide:leaf"></iconify-icon>"` ,
470+ ) ;
471+ } ) ;
472+
473+ test ( "preserves iconify-icon with all attributes" , ( ) => {
474+ const html =
475+ '<iconify-icon icon="lucide:rocket" width="24px" height="24px" inline="" flip="horizontal" rotate="90deg" style="color: blue;"></iconify-icon>' ;
476+ expect ( sanitizeHtml ( html ) ) . toMatchInlineSnapshot (
477+ `"<iconify-icon icon="lucide:rocket" width="24px" height="24px" inline="" flip="horizontal" rotate="90deg" style="color: blue;"></iconify-icon>"` ,
478+ ) ;
479+ } ) ;
480+
481+ test ( "preserves self-closing iconify-icon" , ( ) => {
482+ const html = '<iconify-icon icon="lucide:star" />' ;
483+ expect ( sanitizeHtml ( html ) ) . toMatchInlineSnapshot (
484+ `"<iconify-icon icon="lucide:star"></iconify-icon>"` ,
485+ ) ;
486+ } ) ;
487+
488+ test ( "still removes other non-marimo/non-iconify custom elements" , ( ) => {
489+ const html = "<some-custom-element>Content</some-custom-element>" ;
490+ expect ( sanitizeHtml ( html ) ) . toMatchInlineSnapshot ( `"Content"` ) ;
491+ } ) ;
465492} ) ;
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export function sanitizeHtml(html: string) {
7575 // glue elements like style, script or others to document.body and prevent unintuitive browser behavior in several edge-cases
7676 FORCE_BODY : true ,
7777 CUSTOM_ELEMENT_HANDLING : {
78- tagNameCheck : / ^ m a r i m o - [ A - Z a - z ] [ \w - ] * $ / ,
78+ tagNameCheck : / ^ ( m a r i m o - [ A - Z a - z ] [ \w - ] * | i c o n i f y - i c o n ) $ / ,
7979 attributeNameCheck : / ^ [ A - Z a - z ] [ \w - ] * $ / ,
8080 } ,
8181 } ;
Original file line number Diff line number Diff line change 88
99import marimo
1010
11- __generated_with = "0.15.5 "
11+ __generated_with = "0.17.3 "
1212app = marimo .App ()
1313
1414
@@ -92,11 +92,7 @@ def _(mo):
9292
9393@app .cell
9494def _ (mo ):
95- mo .md (
96- f"""
97- ## { mo .icon ('material-symbols:edit' )} Icons in markdown
98- """
99- )
95+ mo .md (f"""## { mo .icon ('material-symbols:edit' )} Icons in markdown""" )
10096 return
10197
10298
You can’t perform that action at this time.
0 commit comments