=encoding euc-jp =head1 NAME =begin original HTML::Filter - Filter HTML text through the parser =end original HTML::Filter - HTML テキストをパーサでフィルタリングする (訳注: (TBR)がついている段落は「みんなの自動翻訳@TexTra」による 機械翻訳です。) =head1 NOTE =begin original B The C now provides the functionally of C much more efficiently with the the C handler. =end original B<このモジュールは廃止されます。 >Cは、Cハンドラを使用して、Cの機能をより効率的に提供するようになりました。 (TBR) =head1 SYNOPSIS require HTML::Filter; $p = HTML::Filter->new->parse_file("index.html"); =head1 DESCRIPTION =begin original C is an HTML parser that by default prints the original text of each HTML element (a slow version of cat(1) basically). The callback methods may be overridden to modify the filtering for some HTML elements and you can override output() method which is called to print the HTML text. =end original Cは、デフォルトで各HTML要素の元のテキストを出力するHTMLパーサーです(基本的にはcat(1)の遅いバージョンです)。 一部のHTML要素のフィルタリングを変更するためにコールバックメソッドをオーバーライドすることができ、HTMLテキストを出力するために呼び出されるoutput()メソッドをオーバーライドすることができます。 (TBR) =begin original C is a subclass of C. This means that the document should be given to the parser by calling the $p->parse() or $p->parse_file() methods. =end original Cは、Cのサブクラスです。 つまり、$p->parse()または$p->parse_file()メソッドを呼び出して、文書をパーサーに渡す必要があります。 (TBR) =head1 EXAMPLES =begin original The first example is a filter that will remove all comments from an HTML file. This is achieved by simply overriding the comment method to do nothing. =end original 最初の例は、HTMLファイルからすべてのコメントを削除するフィルタです。 これは、commentメソッドを上書きして何もしないようにするだけで実現されます。 (TBR) package CommentStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub comment { } # ignore comments =begin original The second example shows a filter that will remove any ETABLE>s found in the HTML file. We specialize the start() and end() methods to count table tags and then make output not happen when inside a table. =end original 2番目の例は、HTMLファイル内で見つかったETABLE>を削除するフィルタを示しています。 start()メソッドとend()メソッドを特殊化してテーブルタグをカウントし、テーブル内で出力が行われないようにしています。 (TBR) package TableStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub start { my $self = shift; $self->{table_seen}++ if $_[0] eq "table"; $self->SUPER::start(@_); } sub end { my $self = shift; $self->SUPER::end(@_); $self->{table_seen}-- if $_[0] eq "table"; } sub output { my $self = shift; unless ($self->{table_seen}) { $self->SUPER::output(@_); } } =begin original If you want to collect the parsed text internally you might want to do something like this: =end original 解析されたテキストを内部で収集したい場合は、次のようにします。 (TBR) package FilterIntoString; require HTML::Filter; @ISA=qw(HTML::Filter); sub output { push(@{$_[0]->{fhtml}}, $_[1]) } sub filtered_html { join("", @{$_[0]->{fhtml}}) } =head1 SEE ALSO L =head1 COPYRIGHT Copyright 1997-1999 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =begin meta Translate: SHIRAKATA Kentaro Status: in progress =end meta =cut