本文へ移動

Taisen Brackets対戦

対戦の一覧から、トーナメント表をSVGで描きます。

対戦(たいせん)は、二者が向かい合って勝負することです。 名前について(英語)

目次

リファレンス · トーナメント表・表・決勝までの道を描く

cleanSvg関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { cleanSvg } from "@johnmorrisdotca/taisen-brackets";

定義

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

引数

名前型説明
markupstring

The SVG text of a team's mark.

戻り値

{ 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>.

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/taisen-brackets 0.20.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。