Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/css/md.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ a .markdown iconify-icon:first-child {
margin-inline-end: 0.4em;
}

iconify-icon {
display: inline-flex;
align-items: center;
}

/* align icons with buttons better */
button .markdown .paragraph {
display: inline-flex;
align-items: baseline;
gap: 0.4em;

Expand Down
27 changes: 27 additions & 0 deletions frontend/src/plugins/core/__test__/sanitize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,31 @@ describe("sanitizeHtml", () => {
`"<details><summary>Click me</summary><p>Hidden content</p></details>"`,
);
});

test("preserves iconify-icon custom element", () => {
const html = '<iconify-icon icon="lucide:leaf"></iconify-icon>';
expect(sanitizeHtml(html)).toMatchInlineSnapshot(
`"<iconify-icon icon="lucide:leaf"></iconify-icon>"`,
);
});

test("preserves iconify-icon with all attributes", () => {
const html =
'<iconify-icon icon="lucide:rocket" width="24px" height="24px" inline="" flip="horizontal" rotate="90deg" style="color: blue;"></iconify-icon>';
expect(sanitizeHtml(html)).toMatchInlineSnapshot(
`"<iconify-icon icon="lucide:rocket" width="24px" height="24px" inline="" flip="horizontal" rotate="90deg" style="color: blue;"></iconify-icon>"`,
);
});

test("preserves self-closing iconify-icon", () => {
const html = '<iconify-icon icon="lucide:star" />';
expect(sanitizeHtml(html)).toMatchInlineSnapshot(
`"<iconify-icon icon="lucide:star"></iconify-icon>"`,
);
});

test("still removes other non-marimo/non-iconify custom elements", () => {
const html = "<some-custom-element>Content</some-custom-element>";
expect(sanitizeHtml(html)).toMatchInlineSnapshot(`"Content"`);
});
});
2 changes: 1 addition & 1 deletion frontend/src/plugins/core/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function sanitizeHtml(html: string) {
// glue elements like style, script or others to document.body and prevent unintuitive browser behavior in several edge-cases
FORCE_BODY: true,
CUSTOM_ELEMENT_HANDLING: {
tagNameCheck: /^marimo-[A-Za-z][\w-]*$/,
tagNameCheck: /^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,
attributeNameCheck: /^[A-Za-z][\w-]*$/,
},
};
Expand Down
8 changes: 2 additions & 6 deletions marimo/_smoke_tests/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import marimo

__generated_with = "0.15.5"
__generated_with = "0.17.3"
app = marimo.App()


Expand Down Expand Up @@ -92,11 +92,7 @@ def _(mo):

@app.cell
def _(mo):
mo.md(
f"""
## {mo.icon('material-symbols:edit')} Icons in markdown
"""
)
mo.md(f"""## {mo.icon('material-symbols:edit')} Icons in markdown""")
return


Expand Down
Loading