Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Card designs

cleanMarkupfunction

SVG markup with what could run or fetch taken out: scripts, foreignObject, frames, animation elements and styles, every on… handler, and any href that is not a picture or a #fragment of the drawing itself. Anything else is kept as it was written. This is a guard for markup that came from a page's own code, not a sanitiser for strangers' files: never hand it what a visitor typed.

Import it

import { cleanMarkup } from "@johnmorrisdotca/toranpu/card-faces";

Definition

function cleanMarkup(markup: unknown): string

Parameters

NameTypeDescription
markupunknown

Untrusted drawing markup to sanitize.

Returns

string

SVG markup with what could run or fetch taken out: scripts, foreignObject, frames, animation elements and styles, every on… handler, and any href that is not a picture or a #fragment of the drawing itself. Anything else is kept as it was written. This is a guard for markup that came from a page's own code, not a sanitiser for strangers' files: never hand it what a visitor typed.

Examples

import { cleanMarkup } from "@johnmorrisdotca/toranpu/card-faces";

console.log(cleanMarkup(`<svg><script>alert(1)</script><circle cx="5" cy="5" r="2"/></svg>`));
<svg><circle cx="5" cy="5" r="2"/></svg>

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.