Skip to the content

Taisen Brackets対戦

Knockout brackets as SVG, from a list of ties.

Taisen (対戦, たいせん) is Japanese for a matchup: two sides facing each other. About the name

Contents

Reference · Draw a bracket, a table or a road to the final

cleanSvgfunction

Takes inline SVG markup from a caller and makes it safe to put inside a drawing: the outer <svg>'s viewBox is kept, and scripts, event handlers, <style>, <foreignObject>, comments and javascript: addresses are removed. Returns the viewBox and the inner markup, or null when it is not an <svg>.

Import it

import { cleanSvg } from "@johnmorrisdotca/taisen-brackets";

Definition

function cleanSvg(markup: string): { viewBox: string; inner: string; } | null

Parameters

NameTypeDescription
markupstring

The SVG text of a team's mark.

Returns

{ viewBox: string; inner: string; } | null

The view box and the inner markup with scripts, events and external references removed; null when the text is not an <svg>.

Examples

import { cleanSvg } from "@johnmorrisdotca/taisen-brackets";

console.log(cleanSvg('<svg viewBox="0 0 10 10" onload="alert(1)"><script>alert(1)</script><circle cx="5" cy="5" r="4"/></svg>'), cleanSvg("not svg"));
{ viewBox: '0 0 10 10', inner: '<circle cx="5" cy="5" r="4"/>' } null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/taisen-brackets 0.20.0.