=encoding euc-jp =head1 NAME =begin original HTML::Parser - HTML parser class =end original HTML::Parser - HTMLパーサクラス (訳注: (TBR)がついている段落は「みんなの自動翻訳@TexTra」による 機械翻訳です。) =head1 SYNOPSIS use HTML::Parser (); # Create parser object $p = HTML::Parser->new( api_version => 3, start_h => [\&start, "tagname, attr"], end_h => [\&end, "tagname"], marked_sections => 1, ); # Parse document text chunk by chunk $p->parse($chunk1); $p->parse($chunk2); #... $p->eof; # signal end of document # Parse directly from file $p->parse_file("foo.html"); # or open(my $fh, "<:utf8", "foo.html") || die; $p->parse_file($fh); =head1 DESCRIPTION =begin original Objects of the C class will recognize markup and separate it from plain text (alias data content) in HTML documents. As different kinds of markup and text are recognized, the corresponding event handlers are invoked. =end original Cクラスのオブジェクトはマークアップを認識し、HTML文書内のプレーンテキスト(別名データコンテンツ)からマークアップを分離します。 異なる種類のマークアップとテキストが認識されると、対応するイベントハンドラが起動されます。 (TBR) =begin original C is not a generic SGML parser. We have tried to make it able to deal with the HTML that is actually "out there", and it normally parses as closely as possible to the way the popular web browsers do it instead of strictly following one of the many HTML specifications from W3C. Where there is disagreement, there is often an option that you can enable to get the official behaviour. =end original Cは一般的なSGMLパーサーではありません。 私たちは、実際に「存在する」HTMLを処理できるようにしようとしました。 Cは通常、W3Cの多くのHTML仕様の1つに厳密に従うのではなく、一般的なWebブラウザの方法にできるだけ近い方法で解析します。 意見の相違がある場合は、公式の動作を取得できるオプションがあります。 (TBR) =begin original The document to be parsed may be supplied in arbitrary chunks. This makes on-the-fly parsing as documents are received from the network possible. =end original 解析される文書は、任意のチャンクで提供される場合がある。 これにより、ネットワークから文書を受信したときに、その場で解析することが可能になる。 (TBR) =begin original If event driven parsing does not feel right for your application, you might want to use C. This is an C subclass that allows a more conventional program structure. =end original イベント駆動型の解析がアプリケーションに適していない場合は、Cを使用できます。 これは、より一般的なプログラム構造を可能にするCサブクラスです。 (TBR) =head1 METHODS =begin original The following method is used to construct a new C object: =end original 新しいCオブジェクトを構築するには、次のメソッドを使用します。 (TBR) =over =item $p = HTML::Parser->new( %options_and_handlers ) =begin original This class method creates a new C object and returns it. Key/value argument pairs may be provided to assign event handlers or initialize parser options. The handlers and parser options can also be set or modified later by the method calls described below. =end original このクラスメソッドは、新しいCオブジェクトを作成し、それを返します。 イベントハンドラを割り当てたり、パーサオプションを初期化したりするために、キーと値の引数のペアを指定できます。 ハンドラとパーサオプションは、後で後述するメソッドコールによって設定または変更することもできます。 (TBR) =begin original If a top level key is in the form "_h" (e.g., "text_h") then it assigns a handler to that event, otherwise it initializes a parser option. The event handler specification value must be an array reference. Multiple handlers may also be assigned with the 'handlers => [%handlers]' option. See examples below. =end original 最上位レベルのキーが"_h"("text_h"など)の形式の場合は、そのイベントにハンドラが割り当てられます。 それ以外の場合は、パーサーオプションが初期化されます。 イベントハンドラの指定値は配列参照である必要があります。 'handlers=>[%handlers]'オプションを使用して複数のハンドラを割り当てることもできます。 次の例を参照してください。 (TBR) =begin original If new() is called without any arguments, it will create a parser that uses callback methods compatible with version 2 of C. See the section on "version 2 compatibility" below for details. =end original 引数を指定せずにnew()を呼び出すと、バージョン2のCと互換性のあるコールバックメソッドを使用するパーサが作成されます。 詳細については、後述の「バージョン2との互換性」のセクションを参照してください。 (TBR) =begin original The special constructor option 'api_version => 2' can be used to initialize version 2 callbacks while still setting other options and handlers. The 'api_version => 3' option can be used if you don't want to set any options and don't want to fall back to v2 compatible mode. =end original 特別なコンストラクタオプション'api_version=>2'は、他のオプションとハンドラを設定しながらバージョン2コールバックを初期化するために使用できます。 'api_version=>3'オプションは、オプションを設定せず、v2互換モードにフォールバックしない場合に使用できます。 (TBR) =begin original Examples: =end original 例: (TBR) $p = HTML::Parser->new(api_version => 3, text_h => [ sub {...}, "dtext" ]); =begin original This creates a new parser object with a text event handler subroutine that receives the original text with general entities decoded. =end original これにより、テキストイベントハンドラーサブルーチンを持つ新しいパーサーオブジェクトが作成されます。 このサブルーチンは、汎用エンティティーがデコードされた元のテキストを受け取ります。 (TBR) $p = HTML::Parser->new(api_version => 3, start_h => [ 'my_start', "self,tokens" ]); =begin original This creates a new parser object with a start event handler method that receives the $p and the tokens array. =end original これにより、$pとtokens配列を受け取る開始イベントハンドラーメソッドを持つ新しいパーサーオブジェクトが作成されます。 (TBR) $p = HTML::Parser->new(api_version => 3, handlers => { text => [\@array, "event,text"], comment => [\@array, "event,text"], }); =begin original This creates a new parser object that stores the event type and the original text in @array for text and comment events. =end original これにより、テキストイベントとコメントイベントのイベントタイプと元のテキストを@arrayに格納する新しいパーサーオブジェクトが作成されます。 (TBR) =back =begin original The following methods feed the HTML document to the C object: =end original 次のメソッドは、HTML文書をCオブジェクトに渡します。 (TBR) =over =item $p->parse( $string ) =begin original Parse $string as the next chunk of the HTML document. Handlers invoked should not attempt to modify the $string in-place until $p->parse returns. =end original $stringをHTML文書の次のチャンクとして解析します。 呼び出されたハンドラは、$p->parseが返されるまで、$stringをその場で変更しようとしてはなりません。 (TBR) =begin original If an invoked event handler aborts parsing by calling $p->eof, then $p->parse() will return a FALSE value. Otherwise the return value is a reference to the parser object ($p). =end original 呼び出されたイベントハンドラが$p->eofを呼び出して解析を中断した場合、$p->parse()はFALSE値を返します。 それ以外の場合、戻り値はパーサオブジェクト($p)への参照です。 (TBR) =item $p->parse( $code_ref ) =begin original If a code reference is passed as the argument to be parsed, then the chunks to be parsed are obtained by invoking this function repeatedly. Parsing continues until the function returns an empty (or undefined) result. When this happens $p->eof is automatically signaled. =end original 解析される引数としてコード参照が渡された場合、解析されるチャンクは、この関数を繰り返し呼び出すことによって取得されます。 解析は、関数が空の(または未定義の)結果を返すまで続行されます。 これが発生すると、$p->eofが自動的にシグナリングされます。 (TBR) =begin original Parsing will also abort if one of the event handlers calls $p->eof. =end original イベントハンドラーの1つが$p->eofを呼び出した場合にも、構文解析は中断されます。 (TBR) =begin original The effect of this is the same as: =end original この効果は、次と同じです。 (TBR) while (1) { my $chunk = &$code_ref(); if (!defined($chunk) || !length($chunk)) { $p->eof; return $p; } $p->parse($chunk) || return undef; } =begin original But it is more efficient as this loop runs internally in XS code. =end original しかし、このループはXSコード内で内部的に実行されるので、より効率的です。 (TBR) =item $p->parse_file( $file ) =begin original Parse text directly from a file. The $file argument can be a filename, an open file handle, or a reference to an open file handle. =end original ファイルからテキストを直接解析します。 $file引数には、ファイル名、開いているファイルハンドル、または開いているファイルハンドルへの参照を指定できます。 (TBR) =begin original If $file contains a filename and the file can't be opened, then the method returns an undefined value and $! tells why it failed. Otherwise the return value is a reference to the parser object. =end original $fileにファイル名が含まれており、そのファイルを開くことができない場合、メソッドは未定義の値を返し、$!は失敗した理由を示します。 それ以外の場合、戻り値はパーサーオブジェクトへの参照です。 (TBR) =begin original If a file handle is passed as the $file argument, then the file will normally be read until EOF, but not closed. =end original ファイルハンドルが$file引数として渡された場合、ファイルは通常EOFまで読み込まれますが、閉じられることはありません。 (TBR) =begin original If an invoked event handler aborts parsing by calling $p->eof, then $p->parse_file() may not have read the entire file. =end original 呼び出されたイベントハンドラが$p->eofを呼び出して解析を中止した場合、$p->parse_file()はファイル全体を読み込んでいない可能性があります。 (TBR) =begin original On systems with multi-byte line terminators, the values passed for the offset and length argspecs may be too low if parse_file() is called on a file handle that is not in binary mode. =end original 複数バイトの行ターミネータを持つシステムでは、バイナリモードでないファイルハンドルに対してparse_file()が呼び出された場合、offsetとlength argspecsに渡される値が小さすぎる可能性があります。 (TBR) =begin original If a filename is passed in, then parse_file() will open the file in binary mode. =end original ファイル名が渡された場合、parse_file()はそのファイルをバイナリモードで開きます。 (TBR) =item $p->eof =begin original Signals the end of the HTML document. Calling the $p->eof method outside a handler callback will flush any remaining buffered text (which triggers the C event if there is any remaining text). =end original HTML文書の終了を通知します。 ハンドラコールバックの外部で$p->eofメソッドを呼び出すと、バッファに残っているテキストがフラッシュされます(テキストが残っている場合は、Cイベントがトリガーされます)。 (TBR) =begin original Calling $p->eof inside a handler will terminate parsing at that point and cause $p->parse to return a FALSE value. This also terminates parsing by $p->parse_file(). =end original ハンドラ内で$p->eofを呼び出すと、その時点で解析が終了し、$p->parseはFALSE値を返します。 これにより、$p->parse_file()による解析も終了します。 (TBR) =begin original After $p->eof has been called, the parse() and parse_file() methods can be invoked to feed new documents with the parser object. =end original $p->eofが呼び出された後、parse()メソッドとparse_file()メソッドを呼び出して、新しい文書にパーサーオブジェクトを渡すことができます。 (TBR) =begin original The return value from eof() is a reference to the parser object. =end original eof()からの戻り値は、パーサーオブジェクトへの参照です。 (TBR) =back =begin original Most parser options are controlled by boolean attributes. Each boolean attribute is enabled by calling the corresponding method with a TRUE argument and disabled with a FALSE argument. The attribute value is left unchanged if no argument is given. The return value from each method is the old attribute value. =end original ほとんどのパーサーオプションは、ブール属性によって制御されます。 各ブール属性は、対応するメソッドをTRUE引数でコールすると使用可能になり、FALSE引数でコールすると使用不可になります。 引数を指定しない場合、属性値は変更されません。 各メソッドからの戻り値は、古い属性値です。 (TBR) =begin original Methods that can be used to get and/or set parser options are: =end original パーサーオプションの取得または設定に使用できるメソッドは次のとおりです。 (TBR) =over =item $p->attr_encoded =item $p->attr_encoded( $bool ) =begin original By default, the C and C<@attr> argspecs will have general entities for attribute values decoded. Enabling this attribute leaves entities alone. =end original デフォルトでは、CおよびC<@attr>argspecsには、デコードされたアトリビュート値の一般エンティティがあります。 このアトリビュートを有効にすると、エンティティはそのままになります。 (TBR) =item $p->backquote =item $p->backquote( $bool ) =begin original By default, only ' and " are recognized as quote characters around attribute values. MSIE also recognizes backquotes for some reason. Enabling this attribute provides compatibility with this behaviour. =end original デフォルトでは、属性値を囲む引用符として認識されるのは'と"のみです。 MSIEは、何らかの理由で逆引用符も認識します。 この属性を有効にすると、この動作との互換性が提供されます。 (TBR) =item $p->boolean_attribute_value( $val ) =begin original This method sets the value reported for boolean attributes inside HTML start tags. By default, the name of the attribute is also used as its value. This affects the values reported for C and C argspecs. =end original このメソッドは、HTML開始タグ内のブール属性に対してレポートされる値を設定します。 デフォルトでは、属性の名前も値として使用されます。 これは、CおよびCargspecsに対してレポートされる値に影響します。 (TBR) =item $p->case_sensitive =item $p->case_sensitive( $bool ) =begin original By default, tagnames and attribute names are down-cased. Enabling this attribute leaves them as found in the HTML source document. =end original デフォルトでは、タグ名と属性名は小文字に変換されます。 この属性を有効にすると、HTMLソース文書内のタグ名と属性名のままになります。 (TBR) =item $p->closing_plaintext =item $p->closing_plaintext( $bool ) =begin original By default, "plaintext" element can never be closed. Everything up to the end of the document is parsed in CDATA mode. This historical behaviour is what at least MSIE does. Enabling this attribute makes closing "" tag effective and the parsing process will resume after seeing this tag. This emulates early gecko-based browsers. =end original デフォルトでは、"plaintext"要素は決して閉じることができません。 文書の最後までのすべてがCDATAモードで解析されます。 この歴史的な動作は、少なくともMSIEが行っていることです。 この属性を有効にすると、閉じる""タグが有効になり、このタグを見た後に解析プロセスが再開されます。 これは初期のgeckoベースのブラウザをエミュレートします。 (TBR) =item $p->empty_element_tags =item $p->empty_element_tags( $bool ) =begin original By default, empty element tags are not recognized as such and the "/" before ">" is just treated like a normal name character (unless C is enabled). Enabling this attribute make C recognize these tags. =end original デフォルトでは、空の要素タグは認識されず、「>」の前の「/」は通常の名前文字と同じように扱われます(Cが有効になっていない場合)。 この属性を有効にすると、Cはこれらのタグを認識します。 (TBR) =begin original Empty element tags look like start tags, but end with the character sequence "/>" instead of ">". When recognized by C they cause an artificial end event in addition to the start event. The C for the artificial end event will be empty and the C array will be undefined even though the the token array will have one element containing the tag name. =end original 空の要素タグは開始タグのように見えますが、">"ではなく"/>"で終わります。 Cによって認識されると、開始イベントに加えて人工的な終了イベントが発生します。 トークン配列にタグ名を含む要素が1つあっても、人工的な終了イベントのCは空になり、C配列は未定義になります。 (TBR) =item $p->marked_sections =item $p->marked_sections( $bool ) =begin original By default, section markings like are treated like ordinary text. When this attribute is enabled section markings are honoured. =end original デフォルトでは、などのセクションマーキングは通常のテキストと同様に扱われます。 この属性が有効になっている場合、セクションマーキングは受け入れられます。 (TBR) =begin original There are currently no events associated with the marked section markup, but the text can be returned as C. =end original 現在、マーク区間のマークアップに関連付けられたイベントはありませんが、テキストはCとして返されます。 (TBR) =item $p->strict_comment =item $p->strict_comment( $bool ) =begin original By default, comments are terminated by the first occurrence of "-->". This is the behaviour of most popular browsers (like Mozilla, Opera and MSIE), but it is not correct according to the official HTML standard. Officially, you need an even number of "--" tokens before the closing ">" is recognized and there may not be anything but whitespace between an even and an odd "--". =end original デフォルトでは、コメントは「-->」の最初の出現で終了します。 これはほとんどの一般的なブラウザ(Mozilla、Opera、MSIEなど)の動作ですが、公式のHTML標準によれば正しくありません。 公式には、閉じる「>」が認識される前に偶数の「--」トークンが必要であり、偶数と奇数の「--」の間には空白文字しかない場合があります。 (TBR) =begin original The official behaviour is enabled by enabling this attribute. =end original 正式な動作は、この属性を有効にすることで有効になります。 (TBR) =begin original Enabling of 'strict_comment' also disables recognizing these forms as comments: =end original 'strict_comment'を有効にすると、これらのフォームがコメントとして認識されなくなります。 (TBR) =item $p->strict_end =item $p->strict_end( $bool ) =begin original By default, attributes and other junk are allowed to be present on end tags in a manner that emulates MSIE's behaviour. =end original デフォルトでは、属性やその他のジャンクは、MSIEの動作をエミュレートする方法でエンドタグに存在することが許可されている。 (TBR) =begin original The official behaviour is enabled with this attribute. If enabled, only whitespace is allowed between the tagname and the final ">". =end original この属性を使用すると、公式の動作が有効になります。 有効にすると、タグ名と最後の「>」の間に空白のみが許可されます。 (TBR) =item $p->strict_names =item $p->strict_names( $bool ) =begin original By default, almost anything is allowed in tag and attribute names. This is the behaviour of most popular browsers and allows us to parse some broken tags with invalid attribute values like: =end original デフォルトでは、タグ名と属性名にはほとんどすべてのものが許可されています。 これは最も一般的なブラウザの動作であり、次のような無効な属性値を持つ壊れたタグを解析できます。 (TBR) [PREV =begin original By default, "LIST]" is parsed as a boolean attribute, not as part of the ALT value as was clearly intended. This is also what Mozilla sees. =end original デフォルトでは、"LIST]"はブール値として解析され、意図したとおりにALT値の一部として解析されることはありません。 Mozillaも同じことを考えている。 (TBR) =begin original The official behaviour is enabled by enabling this attribute. If enabled, it will cause the tag above to be reported as text since "LIST]" is not a legal attribute name. =end original 正式な動作は、この属性を有効にすることで有効になります。 有効にすると、「LIST]」は有効な属性名ではないため、上記のタグがテキストとして報告されます。 (TBR) =item $p->unbroken_text =item $p->unbroken_text( $bool ) =begin original By default, blocks of text are given to the text handler as soon as possible (but the parser takes care always to break text at a boundary between whitespace and non-whitespace so single words and entities can always be decoded safely). This might create breaks that make it hard to do transformations on the text. When this attribute is enabled, blocks of text are always reported in one piece. This will delay the text event until the following (non-text) event has been recognized by the parser. =end original デフォルトでは、テキストのブロックはできるだけ早くテキストハンドラに渡されます(ただし、パーサーは、単一の単語やエンティティを常に安全にデコードできるように、空白と空白以外の境界でテキストを分割するように常に注意します)。 これにより、テキストの変換を困難にする分割が作成される場合があります。 この属性が有効になっている場合、テキストのブロックは常に1つに報告されます。 これにより、次の(テキスト以外の)イベントがパーサーによって認識されるまで、テキストイベントが遅延されます。 (TBR) =begin original Note that the C argspec will give you the offset of the first segment of text and C is the combined length of the segments. Since there might be ignored tags in between, these numbers can't be used to directly index in the original document file. =end original Cargspecはテキストの最初のセグメントのオフセットを与え、Cはセグメントの結合長であることに注意してください。 間に無視されるタグがある可能性があるため、これらの番号を使用して元の文書ファイル内で直接インデックスを付けることはできません。 (TBR) =item $p->utf8_mode =item $p->utf8_mode( $bool ) =begin original Enable this option when parsing raw undecoded UTF-8. This tells the parser that the entities expanded for strings reported by C, C<@attr> and C should be expanded as decoded UTF-8 so they end up compatible with the surrounding text. =end original デコードされていない未加工のUTF-8を解析する場合、このオプションを有効にします。 これにより、C、C<@attr>、およびCによって報告された文字列に対して展開されたエンティティは、デコードされたUTF-8として展開され、周囲のテキストとの互換性が保たれるようにする必要があることがパーサーに通知されます。 (TBR) =begin original If C is enabled then it is an error to pass strings containing characters with code above 255 to the parse() method, and the parse() method will croak if you try. =end original Cが有効になっている場合、255を超えるコードの文字を含む文字列をparse()メソッドに渡すとエラーとなり、parse()メソッドは試行するとクルックします。 (TBR) =begin original Example: The Unicode character "\x{2665}" is "\xE2\x99\xA5" when UTF-8 encoded. The character can also be represented by the entity "♥" or "♥". If we feed the parser: =end original 例:UTF-8でエンコードされた場合、Unicode文字「\x{2665}」は「\xE2\x 99\xA 5」です。 この文字は、エンティティ「♥」または「♥」で表すこともできます。 パーサーに次のように入力します。 (TBR) $p->parse("\xE2\x99\xA5♥"); =begin original then C will be reported as "\xE2\x99\xA5\x{2665}" without C enabled, but as "\xE2\x99\xA5\xE2\x99\xA5" when enabled. The later string is what you want. =end original Cは、Cが有効になっていない場合は"\xE2\x 99\xA 5\x{2665}"と報告されますが、Cが有効になっている場合は"\xE2\x 99\xA 5\xE 2\x 99\xA 5"と報告されます。 後の文字列が必要な文字列です。 (TBR) =begin original This option is only available with perl-5.8 or better. =end original このオプションはperl-5.8以降でのみ使用できます。 (TBR) =item $p->xml_mode =item $p->xml_mode( $bool ) =begin original Enabling this attribute changes the parser to allow some XML constructs. This enables the behaviour controlled by individually by the C, C, C and C attributes and also suppresses special treatment of elements that are parsed as CDATA for HTML. =end original この属性を有効にすると、一部のXML構造を許可するようにパーサーが変更されます。 これにより、C、C、CおよびC属性によって個別に制御される動作が有効になり、HTMLのCDATAとして解析される要素の特別な処理も抑制されます。 (TBR) =item $p->xml_pic =item $p->xml_pic( $bool ) =begin original By default, I are terminated by ">". When this attribute is enabled, processing instructions are terminated by "?>" instead. =end original デフォルトでは、Iは">"で終了します。 この属性を有効にすると、処理命令は代わりに"?>"で終了します。 (TBR) =back =begin original As markup and text is recognized, handlers are invoked. The following method is used to set up handlers for different events: =end original マークアップとテキストが認識されると、ハンドラが呼び出されます。 さまざまなイベントのハンドラを設定するには、次のメソッドを使用します。 (TBR) =over =item $p->handler( event => \&subroutine, $argspec ) =item $p->handler( event => $method_name, $argspec ) =item $p->handler( event => \@accum, $argspec ) =item $p->handler( event => "" ); =item $p->handler( event => undef ); =item $p->handler( event ); =begin original This method assigns a subroutine, method, or array to handle an event. =end original このメソッドは、イベントを処理するサブルーチン、メソッド、または配列を割り当てます。 (TBR) =begin original Event is one of C, C, C, C, C, C, C, C or C. =end original イベントは、C、C、C、C、C、C、C、C、またはCのいずれかです。 (TBR) =begin original The C<\&subroutine> is a reference to a subroutine which is called to handle the event. =end original C<\&subroutine>は、イベントを処理するために呼び出されるサブルーチンへの参照である。 (TBR) =begin original The C<$method_name> is the name of a method of $p which is called to handle the event. =end original C<$method_name>は、イベントを処理するために呼び出される$pのメソッドの名前です。 (TBR) =begin original The C<@accum> is an array that will hold the event information as sub-arrays. =end original C<@accum>は、イベント情報をサブ配列として保持する配列です。 (TBR) =begin original If the second argument is "", the event is ignored. If it is undef, the default handler is invoked for the event. =end original 2番目の引数が""の場合、イベントは無視されます。 undefの場合、イベントに対してデフォルトのハンドラが呼び出されます。 (TBR) =begin original The C<$argspec> is a string that describes the information to be reported for the event. Any requested information that does not apply to a specific event is passed as C. If argspec is omitted, then it is left unchanged. =end original C<$argspec>は、イベントについて報告される情報を記述する文字列です。 特定のイベントに適用されない要求された情報は、Cとして渡されます。 argspecが省略された場合、変更されないままになります。 (TBR) =begin original The return value from $p->handler is the old callback routine or a reference to the accumulator array. =end original $p->ハンドラからの戻り値は、古いコールバックルーチンまたはアキュムレータ配列への参照です。 (TBR) =begin original Any return values from handler callback routines/methods are always ignored. A handler callback can request parsing to be aborted by invoking the $p->eof method. A handler callback is not allowed to invoke the $p->parse() or $p->parse_file() method. An exception will be raised if it tries. =end original ハンドラコールバックルーチン/メソッドからの戻り値は、常に無視されます。 ハンドラコールバックは、$p->eofメソッドを呼び出すことによって、解析の中止を要求できます。 ハンドラコールバックは、$p->parse()または$p->parse_file()メソッドを呼び出すことはできません。 試行すると、例外が発生します。 (TBR) =begin original Examples: =end original 例: (TBR) $p->handler(start => "start", 'self, attr, attrseq, text' ); =begin original This causes the "start" method of object $p to be called for 'start' events. The callback signature is $p->start(\%attr, \@attr_seq, $text). =end original これにより、オブジェクト$pの"start"メソッドが'start'イベントに対して呼び出されます。 コールバックシグネチャは$p->start(\%attr, \@attr_seq, $text)です。 (TBR) $p->handler(start => \&start, 'attr, attrseq, text' ); =begin original This causes subroutine start() to be called for 'start' events. The callback signature is start(\%attr, \@attr_seq, $text). =end original これにより、'start'イベントに対してサブルーチンstart()が呼び出されます。 コールバックシグネチャはstart(\%attr, \@attr_seq, $text)です。 (TBR) $p->handler(start => \@accum, '"S", attr, attrseq, text' ); =begin original This causes 'start' event information to be saved in @accum. The array elements will be ['S', \%attr, \@attr_seq, $text]. =end original これにより、'start'イベント情報が@accumに保存されます。 配列要素は['S',\%attr, \@attr_seq, $text]となります。 (TBR) $p->handler(start => ""); =begin original This causes 'start' events to be ignored. It also suppresses invocations of any default handler for start events. It is in most cases equivalent to $p->handler(start => sub {}), but is more efficient. It is different from the empty-sub-handler in that C is not reset by it. =end original これにより、「開始」イベントが無視されます。 また、開始イベントのデフォルトハンドラの呼び出しも抑制されます。 ほとんどの場合、$p->handler(start=>sub{})と同等ですが、より効率的です。 空のサブハンドラとは異なり、Cはリセットされません。 (TBR) $p->handler(start => undef); =begin original This causes no handler to be associated with start events. If there is a default handler it will be invoked. =end original これにより、開始イベントにハンドラが関連付けられなくなります。 デフォルトのハンドラがある場合は、それが呼び出されます。 (TBR) =back =begin original Filters based on tags can be set up to limit the number of events reported. The main bottleneck during parsing is often the huge number of callbacks made from the parser. Applying filters can improve performance significantly. =end original タグに基づくフィルタを設定して、報告されるイベントの数を制限できます。 解析中の主なボトルネックは、多くの場合、パーサーから行われる膨大な数のコールバックです。 フィルタを適用すると、パフォーマンスを大幅に向上させることができます。 (TBR) =begin original The following methods control filters: =end original 次のメソッドは、フィルタを制御します。 (TBR) =over =item $p->ignore_elements( @tags ) =begin original Both the C event and the C event as well as any events that would be reported in between are suppressed. The ignored elements can contain nested occurrences of itself. Example: =end original CイベントとCイベントの両方、およびその間に報告されるイベントは抑制されます。 無視された要素には、それ自体のネストされたオカレンスを含めることができます。 例: (TBR) $p->ignore_elements(qw(script style)); =begin original The C