The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Pod::Advent - POD Formatter for The Perl Advent Calendar

VERSION

Version 0.11

GETTING STARTED

Most likely, the included pod2advent script is all you will need:

  pod2advent entry.pod > entry.html

Where the .pod is written using the tags described below. There is also a quick start at http://search.cpan.org/dist/Pod-Advent/ex/getting_started.html.

SYNOPSIS

Using this module directly:

  use Pod::Advent;
  my $pod = shift @ARGV or die "need pod filename";
  my $advent = Pod::Advent->new;
  $advent->parse_file( \*STDIN );

Example POD:

  =for advent_year 2008

  =for advent_day 32

  =for advent_title This is a sample

  =for advent_author Your Name Here

  Today's module M<My::Example> is featured on
  the A<http://example.com|Example Place> web site
  and is I<very> B<special>.

  =sourcedcode example.pl

Getting Started: See ex/getting_started.pod and ex/getting_started.html in the distribution for an initial template.

DESCRIPTION

This module provides a POD formatter that is designed to facilitate the create of submissions for The Perl Advent Calendar (http://perladvent.pm.org) by providing authors with simple markup that will be automatically transformed to full-fill the specific formatting guidelines. This makes it easier for authors to provide calendar-ready submissions, and for the editors to save lots of time in editting submissions.

For example, 'file-, module and program names should be wrapped in <tt>,' and 'the code sample should be appended to the document from the results of a perltidy -nnn -html'. Both of these can be trivially accomplished:

  This entry is for M<Foo::Bar> and the F<script.pl> program.

  =sourcedcode mod0.pl

The meta-data of title, date (year & day), and author is now easy to specify as well, and is used to automatically generate the full HTML header (including style) that the calendar entries require before being posted.

See ex/sample.pod and ex/sample.html in the distribution for a fuller example.

SUPPORTED POD

General note: HTML code in the pod source will be left alone, so it's effectively passed through. For example, these two lines are identical:

    B<blah>
    <b>blah</b>

This being POD, the former should be used. Where the html is useful is more for things w/o POD equivalents, like HTML encoding and writing &amp;, &hellip;, &mdash;, etc or using <BR>'s, <HR>'s, etc, or including images, etc.

Custom Codes

A<>

This is because POD doesn't support the case of L<http://example.com|Example>, so we introduce this A<> code for that exact purpose -- to generate <a href="URL">TEXT</a> hyperlinks.

  A<http://perladvent.pm.org|The Perl Advent Calendar>
  A<http://perladvent.pm.org>

M<>

This is intended for module names. The first instance, it will <tt> it and hyperlink it to a http://search.cpan.org/perldoc? url. All following instances will just <tt> it. Being just for module searches, any other searches can simply use the A<> code instead.

  M<Pod::Simple>
  A<http://search.cpan.org/search?query=Pod::Simple::Subclassing|Pod::Simple::Subclassing>
  A<http://search.cpan.org/search?dist=TimeDate|TimeDate>

N<>

Insert a superscript footnote reference. See "Footnotes".

Custom Directives

sourcedcode

Include the contents of a file formatted with Perl::Tidy (including line numbers).

  =sourcedcode foo.pl

Custom Info Targets

advent_title

Specify the title of the submission.

  =for advent_title Your Entry Title

advent_author

Specify the author of the submission.

  =for advent_author Your Name Here

advent_year

Specify the year of the submission (defaults to current year).

  =for advent_year 2008

advent_day

Specify the day of the submission (if currently known).

  =for advent_day 99

Custom Block Targets

code

Display a code snippet (sends it through Perl::Tidy).

  =begin code
  my $foo = Bar->new();
  $foo->do_it;
  =end code

codeNNN

Same as code, but with line numbers.

  =begin codeNNN
  my $foo = Bar->new();
  $foo->do_it;
  =end codeNNN

pre

Display a snippet (e.g. data, output, etc) as <PRE>-formatted text (does not use Perl::Tidy).

  =begin pre
  x,y,z
  1,2,3
  2,4,9
  3,8,27
  =end pre

quote

Processes POD and wraps it in a <BLOCKQUOTE> section.

  =begin quote
  "Ho-Ho-Ho!"
    -- S.C.
  =end quote

eds

Currently behaves exactly the same as quote.

  =begin eds
  The editors requested
  this directive.
    -- the management
  =end eds

footnote

Define a footnote's content. See "Footnotes".

Footnotes

A footnote consists of a pair of elements -- one is the "N<>" code and one is the "footnote" target. They are each pass a common identifier for the footnote. This way the author doesn't have to keep track of the numbering.

  In this entry we talk about XYZ.N<foo>

  ...

  =begin footnote foo

  The interesting thing about this is B<bar>.

  =end footnote

Note that the identifier is used for an anchor name (#footnote_foo), so it must be /^\w+$/.

The reference will appear as a superscript number. The first instance of "N<>" will be 1, the next 2, and so on.

Standard Codes

L<>

Normal behavior.

F<>

Normal behavior. Uses <tt>

C<>

Uses <tt>. Sends text through Perl::Tidy.

I<>

Normal behavior: uses <I>

B<>

Normal behavior: uses <B>

Standard Directives

headN

Expected behavior (N=1..4): uses <headN>

TODO

have tests use Test::Differences for comparing output to expected .html contents. Will provide much cleaner test feedback on errors.

make Text::Aspell usage optional (in case it isn't or can't be installed); add a --spellcheck option (default on) .. and warn cleanly if trying to sepllcheck and can't load Text::Aspell

reposition the 'View Source (POD)' link?

pod2advent option to generate template (basically cat ex/getting_started.pod)

pod2advent option to generate css (basically cat style.css)

pod2advent option for 'POD' link vs rel=alternate tag

ability to force html encoding? (see 0.07 changelog entry re: you're)

more tests

create test for output_fh not being set

test w/more complicated perl samples, for differences in Perl::Tidy versions.

code refactoring (package var usage; also maybe make code/directive behavior based on a config data structure)

support for =over/=item

check html output for validity

custom podchecker (and/or subclass of Pod::Checker)

METHODS

See Pod::Simple for all of the inherited methods. Also see Pod::Simple::Subclassing for more information.

new

Constructor. See Pod::Simple.

parse_file

Overloaded from Pod::Simple -- if input is a filename, will add a link to it at the bottom of the generated HTML.

Also, if input is a filename, it will chdir to the filename's directory before parsing the file. Thus any files referenced (e.g. in a "sourcedcode" tag) are expected to be relative to the .pod file itself.

css_url

Accessor/mutator for the stylesheet to use. Defaults to ../style.css

num_spelling_errors

Returns the number of (possible) spelling errors found while parsing.

spelling_errors

Returns an array of the (possible) spelling errors found while parsing.

INTERNAL METHODS

add

Appends text to the output buffer.

nl

Appends a newline onto the output buffer.

_handle_element_start

Overload of method to process start of an element.

_handle_element_end

Overload of method to process end of an element.

_handle_text

Overload of method to process handling of text.

__reset

Resets all of the internal (package) variables.

__spellcheck

Splits a chunk of text into words and runs it through Text::Aspell.

AUTHOR

David Westbrook (CPAN: davidrw), <dwestbrook at gmail.com>

BUGS

Please report any bugs or feature requests to bug-pod-advent at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Pod-Advent. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Pod::Advent

You can also look for information at:

SEE ALSO

ACKNOWLEDGEMENTS

The maintainers of The Perl Advent Calendar at http://perladvent.pm.org.

The 2007 editors, Bill Ricker & Jerrad Pierce, for reviewing and providing feedback on this concept.

COPYRIGHT & LICENSE

Copyright 2007-2009 David Westbrook, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.