パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.0

html_unescape

HTMLのエスケープを解除するための小さなライブラリです。すべての名前付き文字参照、10進数文字参照、16進数文字参照をサポートしています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
46.2万
いいね数
181
Pub ポイント
160

パッケージをインストール

flutter pub add html_unescape

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

命名、10進数、16進数の文字参照を含むHTMLエンティティをデコードする軽量なFlutter/Dartパッケージです。エスケープされたHTMLテキストを安全に元の形式に戻すため、Webソースやユーザー入力からのコンテンツレンダリングに最適です。このライブラリは効率的で最小限であり、複数のプラットフォームでのDartアプリケーション向けに特別に設計されています。

用途

  • UIでHTMLエンコードされたテキストをレンダリングする
  • ユーザー生成コンテンツの処理
  • Web APIからデータを解析する
  • CMSからフォーマットされたテキストを表示
  • 表示の前に入力をサニタイズする

主な機能

  • すべてのHTMLエンティティタイプをサポートしています
  • 軽量で高速
  • クロスプラットフォーム互換性
  • シンプルな API、明確なメソッド
  • 外部の依存関係なし

適している対象

  • 生のHTML文字列を処理するアプリ
  • コンテンツレンダリングアプリ
  • Web スクレイピングユーティリティ
  • テキスト処理ツール
  • 教育またはドキュメンテーションアプリ

注意事項

  • 完全なHTMLドキュメントをパースしない
  • XSS保護には適していません
  • エスケープされていないコンテンツの手動サニタイズが必要です
  • 文字参照のデコードに制限される
  • 複雑なHTMLの操作には向いていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

html_unescape

Build Status

A Dart library for unescaping HTML-encoded strings.

Supports:

  • Named Character References ( )
    • 2099 of them
  • Decimal Character References (á)
  • Hexadecimal Character References (ã)

The idea is that while you seldom need encoding to such a level (most of the time, all you need to escape is <, >, /, & and "), you do want to make sure that you cover the whole spectrum when decoding from HTML-escaped strings.

Inspired by Java's unbescape library.

Usage

A simple usage example:

import 'package:html_unescape/html_unescape.dart';

main() {
  var unescape = HtmlUnescape();
  var text = unescape.convert("&lt;strong&#62;This &quot;escaped&quot; string");
  print(text);
}

You can also use the converter to transform a stream. For example, the code below will transform a POSIX stdin into an HTML-unencoded stdout.

await stdin
    .transform(Utf8Decoder())
    .transform(HtmlUnescape())
    .transform(Utf8Encoder())
    .pipe(stdout);

Full versus small

If you're sure you will only encounter the most common escaped characters, you can import 'package:html_unescape/html_unescape_small.dart' instead of the full version. This will decrease code size and increase performance. The only difference is in the size of the Named Character Reference dictionary. The full set includes the likes of &DownLeftRightVector; or &UpArrowBar; while the small set only includes the first 255 charcodes.

Issues

Please use GitHub tracker. Don't hesitate to create pull requests, too.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

ランキング