⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subclassing.pod

📁 source of perl for linux application,
💻 POD
📖 第 1 页 / 共 2 页
字号:
    </item-bullet>  </over-bullet>=item events with an element_name of over-numberWhen an "=over ... Z<>=back" block is parsed where the items area numbered list, it will produce this event structure:  <over-number indent="4" start_line="543">    <item-number number="1" start_line="545">      ...Stuff...    </item-number>    ...more item-number...  </over-bullet>This is like the "over-bullet" event structure; but note that the contentsare "item-number" instead of "item-bullet", and note that they will havea "number" attribute, which some formatters/processors may ignore(since, for example, there's no need for it in HTML when producingan "<UL><LI>...</LI>...</UL>" structure), but which any processor may use.Note that the values for the I<number> attributes of "item-number"elements in a given "over-number" area I<will> start at 1 and go up byone each time.  If the Pod source doesn't follow that order (even thoughit really should should!), whatever numbers it has will be ignored (withthe correct values being put in the I<number> attributes), and an errormessage might be issued to the user.=item events with an element_name of over-textThese events are are somewhat unlike the other over-*structures, as far as what their contents are.  Whenan "=over ... Z<>=back" block is parsed where the items area list of text "subheadings", it will produce this event structure:  <over-text indent="4" start_line="543">    <item-text>      ...stuff...    </item-text>    ...stuff (generally Para or Verbatim elements)...    <item-text>    ...more item-text and/or stuff...  </over-text>The I<indent> attribute is as with the other over-* events.For example, this Pod source:  =over    =item Foo    Stuff    =item Bar I<baz>!    Quux    =backproduces this event structure:  <over-text indent="4" start_line="20">    <item-text start_line="22">      Foo    </item-text>    <Para start_line="24">      Stuff    </Para>    <item-text start_line="26">      Bar        <I>          baz        </I>      !    </item-text>    <Para start_line="28">      Quux    </Para>  </over-text>=item events with an element_name of over-blockThese events are are somewhat unlike the other over-*structures, as far as what their contents are.  Whenan "=over ... Z<>=back" block is parsed where there are no items,it will produce this event structure:  <over-block indent="4" start_line="543">    ...stuff (generally Para or Verbatim elements)...  </over-block>The I<indent> attribute is as with the other over-* events.For example, this Pod source:  =over    For cutting off our trade with all parts of the world    For transporting us beyond seas to be tried for pretended offenses    He is at this time transporting large armies of foreign mercenaries to  complete the works of death, desolation and tyranny, already begun with  circumstances of cruelty and perfidy scarcely paralleled in the most  barbarous ages, and totally unworthy the head of a civilized nation.    =cut  will produce this event structure:  <over-block indent="4" start_line="2">    <Para start_line="4">      For cutting off our trade with all parts of the world    </Para>    <Para start_line="6">      For transporting us beyond seas to be tried for pretended offenses    </Para>    <Para start_line="8">      He is at this time transporting large armies of [...more text...]    </Para>  </over-block>=item events with an element_name of item-bulletSee L</"events with an element_name of over-bullet">, above.=item events with an element_name of item-numberSee L</"events with an element_name of over-number">, above.=item events with an element_name of item-textSee L</"events with an element_name of over-text">, above.=item events with an element_name of forTODO...=item events with an element_name of DataTODO...=back=head1 More Pod::Simple MethodsPod::Simple provides a lot of methods that aren't generally interestingto the end user of an existing Pod formatter, but some of which youmight find useful in writing a Pod formatter. They are listed below. Thefirst several methods (the accept_* methods) are for declaring thecapabilites of your parser, notably what C<=for I<targetname>> sectionsit's interested in, what extra NE<lt>...E<gt> codes it accepts beyondthe ones described in the I<perlpod>.=over=item C<< $parser->accept_targets( I<SOMEVALUE> ) >>As the parser sees sections like:    =for html  <img src="fig1.jpg">or    =begin html      <img src="fig1.jpg">    =end html...the parser will ignore these sections unless your subclass hasspecified that it wants to see sections targetted to "html" (or whateverthe formatter name is).If you want to process all sections, even if they're not targetted for you,call this before you start parsing:  $parser->accept_targets('*');=item C<< $parser->accept_targets_as_text(  I<SOMEVALUE>  ) >>This is like accept_targets, except that it specifies also that thecontent of sections for this target should be treated as Pod text evenif the target name in "=for I<targetname>" doesn't start with a ":".At time of writing, I don't think you'll need to use this.=item C<< $parser->accept_codes( I<Codename>, I<Codename>...  ) >>This tells the parser that you accept additional formatting codes,beyond just the standard ones (I B C L F S X, plus the two weird onesyou don't actually see in the parse tree, Z and E). For example, to alsoaccept codes "N", "R", and "W":    $parser->accept_codes( qw( N R W ) );B<TODO: document how this interacts with =extend, and long element names>=item C<< $parser->accept_directive_as_data( I<directive_name> ) >>=item C<< $parser->accept_directive_as_verbatim( I<directive_name> ) >>=item C<< $parser->accept_directive_as_processed( I<directive_name> ) >>In the unlikely situation that you need to tell the parser that you willaccept additional directives ("=foo" things), you need to first set theparset to treat its content as data (i.e., not really processed atall), or as verbatim (mostly just expanding tabs), or as processed text(parsing formatting codes like BE<lt>...E<gt>).For example, to accept a new directive "=method", you'd presumablyuse:    $parser->accept_directive_as_processed("method");so that you could have Pod lines like:    =method I<$whatever> thing B<um>Making up your own directives breaks compatibility with other Podformatters, in a way that using "=for I<target> ..." lines doesn't;however, you may find this useful if you're making a Pod supersetformat where you don't need to worry about compatibility.=item C<< $parser->nbsp_for_S( I<BOOLEAN> ); >>Setting this attribute to a true value (and by default it is false) willturn "SE<lt>...E<gt>" sequences into sequences of words separated byC<\xA0> (non-breaking space) characters. For example, it will take this:    I like S<Dutch apple pie>, don't you?and treat it as if it were:    I like DutchE<nbsp>appleE<nbsp>pie, don't you?This is handy for output formats that don't have anything quite like an"SE<lt>...E<gt>" code, but which do have a code for non-breaking space.There is currently no method for going the other way; but I canprobably provide one upon request.=item C<< $parser->version_report() >>This returns a string reporting the $VERSION value from your module (andits classname) as well as the $VERSION value of Pod::Simple.  Note thatL<perlpodspec> requires output formats (wherever possible) to notethis detail in a comment in the output format.  For example, forsome kind of SGML output format:    print OUT "<!-- \n", $parser->version_report, "\n -->";=item C<< $parser->pod_para_count() >>This returns the count of Pod paragraphs seen so far.=item C<< $parser->line_count() >>This is the current line number being parsed. But you might find the"line_number" event attribute more accurate, when it is present.=item C<< $parser->nix_X_codes(  I<SOMEVALUE>  ) >>This attribute, when set to a true value (and it is false by default)ignores any "XE<lt>...E<gt>" sequences in the document being parsed.Many formats don't actually use the content of these codes, so haveno reason to process them.=item C<< $parser->merge_text(  I<SOMEVALUE>  ) >>This attribute, when set to a true value (and it is false by default)makes sure that only one event (or token, or node) will be createdfor any single contiguous sequence of text.  For example, considerthis somewhat contrived example:    I just LOVE Z<>hotE<32>apple pie!When that is parsed and events are about to be called on it, it mayactually seem to be four different text events, one right after another:one event for "I just LOVE ", one for "hot", one for " ", and one for"apple pie!". But if you have merge_text on, then you're guaranteedthat it will be fired as one text event:  "I just LOVE hot apple pie!".=item C<< $parser->code_handler(  I<CODE_REF>  ) >>This specifies code that should be called when a code line is seen(i.e., a line outside of the Pod).  Normally this is undef, meaningthat no code should be called.  If you provide a routine, it shouldstart out like this:    sub get_code_line {  # or whatever you'll call it      my($line, $line_number, $parser) = @_;      ...    }Note, however, that sometimes the Pod events aren't processed in exactlythe same order as the code lines are -- i.e., if you have a file withPod, then code, then more Pod, sometimes the code will be processed (viawhatever you have code_handler call) before the all of the preceding Podhas been processed.=item C<< $parser->cut_handler(  I<CODE_REF>  ) >>This is just like the code_handler attribute, except that it's for"=cut" lines, not code lines. The same caveats apply. "=cut" lines areunlikely to be interesting, but this is included for completeness.=item C<< $parser->whine( I<linenumber>, I<complaint string> ) >>This notes a problem in the Pod, which will be reported to in the "PodErrors" section of the document and/or send to STDERR, depending on thevalues of the attributes C<no_whining>, C<no_errata_section>, andC<complain_stderr>.=item C<< $parser->scream( I<linenumber>, I<complaint string> ) >>This notes an error like C<whine> does, except that it is notsuppressable with C<no_whining>. This should be used only for veryserious errors.=item C<< $parser->source_dead(1) >>This aborts parsing of the current document, by switching on the flagthat indicates that EOF has been seen.  In particularly drastic cases,you might want to do this.  It's rather nicer than just callingC<die>!=item C<< $parser->hide_line_numbers( I<SOMEVALUE> ) >>Some subclasses that indescriminately dump event attributes (well,except for ones beginning with "~") can use this object attribute forrefraining to dump the "start_line" attribute.=item C<< $parser->no_whining( I<SOMEVALUE> ) >>This attribute, if set to true, will suppress reports of non-fatalerror messages.  The default value is false, meaning that complaintsI<are> reported.  How they get reported depends on the values ofthe attributes C<no_errata_section> and C<complain_stderr>.=item C<< $parser->no_errata_section( I<SOMEVALUE> ) >>This attribute, if set to true, will suppress generation of an erratasection.  The default value is false -- i.e., an errata section will begenerated.=item C<< $parser->complain_stderr( I<SOMEVALUE> ) >>This attribute, if set to true will send complaints to STDERR.  Thedefault value is false -- i.e., complaints do not go to STDERR.=item C<< $parser->bare_output( I<SOMEVALUE> ) >>Some formatter subclasses use this as a flag for whether output shouldhave prologue and epilogue code omitted. For example, setting this totrue for an HTML formatter class should omit the"<html><head><title>...</title><body>..." prologue and the"</body></html>" epilogue.If you want to set this to true, you should probably also setC<no_whining> or at least C<no_errata_section> to true.=item C<< $parser->preserve_whitespace( I<SOMEVALUE> ) >>If you set this attribute to a true value, the parser will try topreserve whitespace in the output.  This means that such formattingconventions as two spaces after periods will be preserved by the parser.This is primarily useful for output formats that treat whitespace assignificant (such as text or *roff, but not HTML).=back=head1 SEE ALSOL<Pod::Simple> -- event-based Pod-parsing frameworkL<Pod::Simple::Methody> -- like Pod::Simple, but each sort of eventcalls its own method (like C<start_head3>)L<Pod::Simple::PullParser> -- a Pod-parsing framework like Pod::Simple,but with a token-stream interfaceL<Pod::Simple::SimpleTree> -- a Pod-parsing framework like Pod::Simple,but with a tree interfaceL<Pod::Simple::Checker> -- a simple Pod::Simple subclass that readsdocuments, and then makes a plaintext report of any errors found in thedocumentL<Pod::Simple::DumpAsXML> -- for dumping Pod documents as tidilyindented XML, showing each event on its own lineL<Pod::Simple::XMLOutStream> -- dumps a Pod document as XML (withoutintroducing extra whitespace as Pod::Simple::DumpAsXML does).L<Pod::Simple::DumpAsText> -- for dumping Pod documents as tidilyindented text, showing each event on its own lineL<Pod::Simple::LinkSection> -- class for objects representing the valuesof the TODO and TODO attributes of LE<lt>...E<gt> elementsL<Pod::Escapes> -- the module the Pod::Simple uses for evaluatingEE<lt>...E<gt> contentL<Pod::Simple::Text> -- a simple plaintext formatter for PodL<Pod::Simple::TextContent> -- like Pod::Simple::Text, butmakes no effort for indent or wrap the text being formattedL<perlpod|perlpod>L<perlpodspec|perlpodspec>L<perldoc>=head1 COPYRIGHT AND DISCLAIMERSCopyright (c) 2002 Sean M. Burke.  All rights reserved.This library is free software; you can redistribute it and/or modify itunder the same terms as Perl itself.This program is distributed in the hope that it will be useful, butwithout any warranty; without even the implied warranty ofmerchantability or fitness for a particular purpose.=head1 AUTHORSean M. Burke C<sburke@cpan.org>=for notesHm, my old podchecker version (1.2) says: *** WARNING: node 'http://search.cpan.org/' contains non-escaped | or / at line 38 in file Subclassing.pod *** WARNING: node 'http://lists.perl.org/showlist.cgi?name=pod-people' contains non-escaped | or / at line 41 in file Subclassing.podYes, L<...> is hard.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -