App-DocKnot

 view release on metacpan or  search on metacpan

lib/App/DocKnot/Spin/Text.pm  view on Meta::CPAN

        ([ \t]*\n)
    }{$1<a href="#S$2">$3</a>$4}xmsg;
    return $text;
}

# Turns *some text* into <strong>some text</strong>, while trying to be
# careful to avoid other uses of wildcards.
#
# $string - Text to format
#
# Returns: Text with bold replaced with HTML markup.
sub _format_bold {
    my ($text) = @_;
    $text =~ s{
        (^|\s) [*] ( \w .*? \S ) [*] ([,.!?;\s])
    }{$1<strong>$2</strong>$3}xmsg;
    return $text;
}

# Format a link.  All whitespace in the link is treated as insignficant.
#
# $link - Link to format

lib/App/DocKnot/Spin/Text.pm  view on Meta::CPAN

        # Check for paragraphs that are entirely bulletted lines, and turn
        # them into unordered lists without <p> tags.
        if (_is_allbullet $_) {
            my $last;
            my @lines = split (/\n/, $_);
            for (@lines) {
                next unless /\S/;
                if (_is_bullet $_) {
                    if (defined $last) {
                        $self->_output(start($INDENT, 'ul'));
                        $self->_output(li($INDENT, _format_bold($last)));
                    }
                    $last = _remove_bullet($_);
                    $INDENT = indent $last;
                } else {
                    $last .= "\n$_";
                }
            }
            if (defined $last) {
                $self->_output(start($INDENT, 'ul'));
                $self->_output(li($INDENT, _format_bold($last)));
            }
            next;
        }

        # Check for paragraphs that are entirely numbered lines, and turn them
        # into ordered lists without <p> tags.
        if (_is_allnumbered $_) {
            my @lines = split (/\n/, $_);
            for (@lines) {
                next unless /\S/;
                my ($number) = /^(\d+)/;
                $_ = _remove_number($_);
                $INDENT = indent $_;
                $self->_output(start($INDENT, 'ol'));
                $self->_output(li($INDENT, _format_bold($_), $number));
            }
            next;
        }

        # Check for bulletted paragraphs and turn them into lists.
        if (_is_bullet $_) {
            $_ = _remove_bullet($_);
            $INDENT = indent $_;
            $self->_output(start($INDENT, 'ul'));
            $self->_output(li($INDENT, p(_format_bold($_))));
            next;
        }

        # Check for paragraphs quoted with some character and turn them into
        # blockquotes provided they don't have inconsistent indentation.
        my $quote = _is_quoted ($_);
        if ($quote && !$broken) {
            $_ = _remove_prefix($_, $quote);
            $INDENT = indent $_;
            $self->_output(start($INDENT, 'blockquote', p(_format_bold($_))));
            next;
        }

        # Check for numbered paragraphs and turn them into lists.
        my $number = _is_numbered ($_);
        if (defined $number) {
            my $contents = _is_contents ($_);
            $_ = _remove_number($_);
            $INDENT = indent $_;
            s%(\n\s*\S)%<br />$1%g if ($broken || $contents);
            $self->_output(start($INDENT, 'ol'));
            $self->_output(li($INDENT, p(_format_bold($_)), $number));
            next;
        }

        # Check for things that look like description lists and handle them.
        # Note that we don't allow indented description lists, because they're
        # usually something we actually want to make <pre>.  This is another
        # fairly fragile heuristic.
        if (_is_description ($_) && defined $INDENT) {
            my (@title, $body);
            ($title[0], $body) = split ("\n", $_, 2);
            my ($space) = ($title[0] =~ /^(\s*)/);
            while ($body =~ /^$space\S/) {
                my $title;
                ($title, $body) = split ("\n", $body, 2);
                push (@title, $title);
            }
            if ($indent == $INDENT || indent ($body) == $INDENT) {
                @title = map { _format_bold($_) } @title;
                my $title = join ("<br />\n", @title) . "\n";
                $INDENT = indent $body;
                $body =~ s%(\n\s*\S)%<br />$1%g if _is_broken $body;
                $self->_output(start($indent, 'dl', dt($title)));
                $self->_output(start($INDENT, 'dd', p(_format_bold($body))));
                next;
            }
        }

        # If the paragraph has inconsistent indentation, we should output it
        # in <pre>.
        if (_is_offset $_) {
            $self->_output(pre(strip_indent($_, $INDENT)));
            $self->{pre} = 1;
            next;

lib/App/DocKnot/Spin/Text.pm  view on Meta::CPAN

        # A sudden indentation change also means the paragraph should be
        # blockquoted.  We render broken blockquoted text in <pre>, which may
        # not be what's wanted for things like quotes of poetry... this is
        # probably worth looking at in more detail.
        if (defined $INDENT && $indent > $INDENT) {
            if ($broken || (lines ($_) == 1 && !_is_sentence $_)) {
                $self->_output(pre(strip_indent($_, $INDENT)));
                $self->{pre} = 1;
            } else {
                $INDENT = $indent;
                my $paragraph = p(_format_bold($_));
                $self->_output(start($INDENT, 'blockquote', $paragraph));
            }
            next;
        }

        # Close multiparagraph structure if we've outdented again.
        if ($INDENT && $indent < $INDENT) { $self->_output(start($indent)) }

        # Looks like a normal paragraph.  Establish our indentation baseline
        # if we haven't already.
        if (!defined $self->{baseline} && !$INDENT) {
            $self->{baseline} = $indent;
        }
        $INDENT = $indent;
        s%(\n\s*\S)%<br />$1%g if $broken;
        $self->_output(p(_format_bold($_)));

    } continue {
        $self->{whitespace} = $space;
    }

    # All done.  Print out our closing tags.
    $self->_output(start(-1));
    if ($self->{sitemap} && defined($self->{output}) && defined($out_path)) {
        my $page = $out_path->relative($self->{output});
        my @navbar = $self->{sitemap}->navbar($page);

lib/App/DocKnot/Spin/Text.pm  view on Meta::CPAN

App::DocKnot::Spin::Text thinks it should use for the document.

App::DocKnot::Spin::Text expects your document to have an C<< <h1> >> title,
and will add one from the Subject header if it doesn't find one.  It will also
add subheaders (C<class="subheading">) giving the author (from the C<From>
header) and the last modified time and revision (from the RCS C<Id> string) if
there are no subheadings already.  If there's a subheading that contains RCS
identifiers, it will be replaced by a nicely formatted heading generated from
the RCS C<Id> information in the HTML output.

Text marked as C<*bold*> using the standard asterisk notation will be
surrounded by C<< <strong> >> tags, if the asterisks appear to be marking bold
text rather than serving as wildcards or some other function.

App::DocKnot::Spin::Text produces output (at least in the absence of any
lurking bugs) which complies with the XHTML 1.0 Transitional standard.  The
input and output character set is assumed to be UTF-8.

=head1 CLASS METHODS

=over 4

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN


# The table of available commands.  The columns are:
#
# 1. Number of arguments or -1 to consume as many arguments as it can find.
# 2. Name of the method to call with the arguments and (if wanted) format.
# 3. Whether to look for a format in parens before the arguments.
#<<<
my %COMMANDS = (
    # name       args  method             want_format
    block     => [1,  '_cmd_block',       1],
    bold      => [1,  '_cmd_bold',        1],
    break     => [0,  '_cmd_break',       0],
    bullet    => [1,  '_cmd_bullet',      1],
    class     => [1,  '_cmd_class',       1],
    cite      => [1,  '_cmd_cite',        1],
    code      => [1,  '_cmd_code',        1],
    desc      => [2,  '_cmd_desc',        1],
    div       => [1,  '_cmd_div',         1],
    emph      => [1,  '_cmd_emph',        1],
    entity    => [1,  '_cmd_entity',      0],
    h1        => [1,  '_cmd_h1',          1],

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN

# Literal backslash.  This is the command handler for \\.
sub _literal { return (0, q{\\}) }

##############################################################################
# Regular commands
##############################################################################

# Basic inline commands.
#<<<
sub _cmd_break  { return (0, '<br />') }
sub _cmd_bold   { my ($self, @a) = @_; return $self->_inline('b',      @a) }
sub _cmd_cite   { my ($self, @a) = @_; return $self->_inline('cite',   @a) }
sub _cmd_class  { my ($self, @a) = @_; return $self->_inline('span',   @a) }
sub _cmd_code   { my ($self, @a) = @_; return $self->_inline('code',   @a) }
sub _cmd_emph   { my ($self, @a) = @_; return $self->_inline('em',     @a) }
sub _cmd_italic { my ($self, @a) = @_; return $self->_inline('i',      @a) }
sub _cmd_strike { my ($self, @a) = @_; return $self->_inline('strike', @a) }
sub _cmd_strong { my ($self, @a) = @_; return $self->_inline('strong', @a) }
sub _cmd_sub    { my ($self, @a) = @_; return $self->_inline('sub',    @a) }
sub _cmd_sup    { my ($self, @a) = @_; return $self->_inline('sup',    @a) }
sub _cmd_under  { my ($self, @a) = @_; return $self->_inline('u',      @a) }

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN


=back

=head2 Inline Commands

Inline commands can be used in the middle of a paragraph intermixed with other
text.  Most of them are simple analogs to their HTML counterparts.  All of the
following take a single argument (the enclosed text), an optional formatting
instruction, and map to simple HTML tags:

    \bold       <b></b>                 (usually use \strong)
    \cite       <cite></cite>
    \code       <code></code>
    \emph       <em></em>
    \italic     <i></i>                 (usually use \emph)
    \strike     <strike></strike>       (should use styles)
    \strong     <strong></strong>
    \sub        <sub></sub>
    \sup        <sup></sup>
    \under      <u></u>                 (should use styles)

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN

underscore), NARGS is the number of arguments that it takes, and DEFINITION is
the definition of the macro.

When the macro is expanded, any occurrence of C<\1> in the definition is
replaced with the first argument, any occurrence of C<\2> with the second
argument, and so forth, and then the definition with those substitutions is
parsed as thread, as if it were written directly in the source page.

For example:

    \==[bolddesc] [2] [\desc[\bold[\1]][\2]]

defines a macro C<\bolddesc> that takes the same arguments as the regular
C<\desc> command but always wraps the first argument, the heading, in C<<
<strong> >>.

=head1 AUTHOR

Russ Allbery <rra@cpan.org>

=head1 COPYRIGHT AND LICENSE

Copyright 1999-2011, 2013, 2021-2023 Russ Allbery <rra@cpan.org>

t/data/generate/ansicolor/docknot.yaml  view on Meta::CPAN

  text attributes or to apply a set of attributes to a string and reset the
  current text attributes at the end of that string.  Eight-color,
  sixteen-color, and 256-color escape sequences are all supported.

description: |
  This Perl module is a simple and convenient interface to the ANSI terminal
  escape sequences for color (from ECMA-48, also included in ISO 6429).  The
  color sequences are provided in two forms, either as constants for each
  color or via a function that takes the names of colors and returns the
  appropriate escape codes or wraps them around the provided text.  The
  non-color text style codes from ANSI X3.64 (bold, dark, underline, and
  reverse, for example), which were also included in ECMA-48 and ISO 6429,
  are also supported.  Also supported are the extended colors used for
  sixteen-color and 256-color emulators.

  This module is very stable, and I've used it in a wide variety of
  applications.  It has been included in the core Perl distribution starting
  with version 5.6.0, so you don't need to download and install it yourself
  unless you have an old version of Perl or need a newer version of the
  module than comes with your version of Perl.  I continue to maintain it as
  a separate module, and the version included in Perl is resynced with mine

t/data/generate/ansicolor/output/readme  view on Meta::CPAN

  the current text attributes at the end of that string.  Eight-color,
  sixteen-color, and 256-color escape sequences are all supported.

DESCRIPTION

  This Perl module is a simple and convenient interface to the ANSI
  terminal escape sequences for color (from ECMA-48, also included in ISO
  6429).  The color sequences are provided in two forms, either as
  constants for each color or via a function that takes the names of
  colors and returns the appropriate escape codes or wraps them around the
  provided text.  The non-color text style codes from ANSI X3.64 (bold,
  dark, underline, and reverse, for example), which were also included in
  ECMA-48 and ISO 6429, are also supported.  Also supported are the
  extended colors used for sixteen-color and 256-color emulators.

  This module is very stable, and I've used it in a wide variety of
  applications.  It has been included in the core Perl distribution
  starting with version 5.6.0, so you don't need to download and install
  it yourself unless you have an old version of Perl or need a newer
  version of the module than comes with your version of Perl.  I continue
  to maintain it as a separate module, and the version included in Perl is

t/data/generate/ansicolor/output/readme-md  view on Meta::CPAN

current text attributes at the end of that string.  Eight-color,
sixteen-color, and 256-color escape sequences are all supported.

## Description

This Perl module is a simple and convenient interface to the ANSI terminal
escape sequences for color (from ECMA-48, also included in ISO 6429).  The
color sequences are provided in two forms, either as constants for each
color or via a function that takes the names of colors and returns the
appropriate escape codes or wraps them around the provided text.  The
non-color text style codes from ANSI X3.64 (bold, dark, underline, and
reverse, for example), which were also included in ECMA-48 and ISO 6429,
are also supported.  Also supported are the extended colors used for
sixteen-color and 256-color emulators.

This module is very stable, and I've used it in a wide variety of
applications.  It has been included in the core Perl distribution starting
with version 5.6.0, so you don't need to download and install it yourself
unless you have an old version of Perl or need a newer version of the
module than comes with your version of Perl.  I continue to maintain it as
a separate module, and the version included in Perl is resynced with mine

t/data/generate/ansicolor/output/thread  view on Meta::CPAN

current text attributes at the end of that string.  Eight-color,
sixteen-color, and 256-color escape sequences are all supported.

\h2[Description]

This Perl module is a simple and convenient interface to the ANSI terminal
escape sequences for color (from ECMA-48, also included in ISO 6429).  The
color sequences are provided in two forms, either as constants for each
color or via a function that takes the names of colors and returns the
appropriate escape codes or wraps them around the provided text.  The
non-color text style codes from ANSI X3.64 (bold, dark, underline, and
reverse, for example), which were also included in ECMA-48 and ISO 6429,
are also supported.  Also supported are the extended colors used for
sixteen-color and 256-color emulators.

This module is very stable, and I've used it in a wide variety of
applications.  It has been included in the core Perl distribution starting
with version 5.6.0, so you don't need to download and install it yourself
unless you have an old version of Perl or need a newer version of the
module than comes with your version of Perl.  I continue to maintain it as
a separate module, and the version included in Perl is resynced with mine

t/data/spin/input/journal/2011-08/006.th  view on Meta::CPAN

top 100 works of science fiction or fantasy.  Series are counted as single
works for the purposes of the list.

This list has a ton of problems, like any list of this sort will have.  It
leans rather more heavily towards white male than the actual literature,
and certainly than my reading.  The lack of non-white writers is
particularly troubling.  But it's still an interesting selection.  (For
those wondering about some obvious omissions, young adult was explicitly
excluded.)

The rules are to bold the works one has read in their entirety and
italicize the ones you've read part of but not finished.  I'll add
underlining the works that I own, which provides some indication of the
things that I've not read but that are on my to-read list.

\==[ro] [2] [\number(packed)[\strong[\under[\1]]: \2]]
\==[r]  [2] [\number(packed)[\strong[\1]: \2]]
\==[po] [2] [\number(packed)[\emph[\under[\1]]: \2]]
\==[p]  [2] [\number(packed)[\emph[\1]: \2]]
\==[o]  [2] [\number(packed)[\under[\1]: \2]]
\==[n]  [2] [\number(packed)[\1: \2]]

t/data/spin/input/software/index.th  view on Meta::CPAN

\==[section]  [3] [\h2(#\1)[\2]\table(software)[][\3]]
\==[package]  [3] [\tablerow[\class(package)[\strong[\link[\1][\2]]]][\3]]
\==[b]        [0] [\entity[ndash]]
\==[bolddesc] [2] [\desc[\strong[\1]][\2]]
\==[desclink] [3] [\bolddesc[\link[\1][\2]][\3]]

\rss[../journal/software.rss][Releases of Russ Allbery's Software]

\heading[Russ's Software][indent]

\h1[Software]

\class(sections)[
       \link[#kerberos][Kerberos]
    \b \link[#info][Information Management]

t/data/spin/input/usefor/index.th  view on Meta::CPAN

\=[HEADER]
  [https://www.iana.org/assignments/message-headers/message-headers.xhtml]
\=[CANCEL]
  [https://www.iana.org/assignments/netnews-parameters/netnews-parameters.xhtml]
\=[USEFOR]
  [https://mailarchive.ietf.org/arch/browse/usefor/]

\==[bolddesc] [2] [\desc[\strong[\1]][\2]]
\==[desclink] [3] [\bolddesc[\link[\1][\2]][\3]]
\==[draft]    [2] [\bullet(packed)[\link[drafts/\1][\2] (\size[drafts/\1])]]

\heading[The Usenet Article Format and Protocols][indent]

\h1[The Usenet Article Format and Protocols]

\quote(short)[
    Usenet interprets management as damage and routes around it.
][Peter da Silva][]

t/data/spin/output/journal/2011-08/006.html  view on Meta::CPAN

<p>
This list has a ton of problems, like any list of this sort will have.  It
leans rather more heavily towards white male than the actual literature,
and certainly than my reading.  The lack of non-white writers is
particularly troubling.  But it's still an interesting selection.  (For
those wondering about some obvious omissions, young adult was explicitly
excluded.)
</p>

<p>
The rules are to bold the works one has read in their entirety and
italicize the ones you've read part of but not finished.  I'll add
underlining the works that I own, which provides some indication of the
things that I've not read but that are on my to-read list.
</p>

<ol>
<li class="packed"><strong><u>The Lord Of The Rings Trilogy, by J.R.R. Tolkien</u></strong>: 
    It's a boring winner because it always wins, but it's an amazing book
    and I can't argue with it.  I'll probably never review this one since
    I'm not sure I have anything original to say about it.</li>

t/data/spin/output/journal/debian.rss  view on Meta::CPAN

<p>
This list has a ton of problems, like any list of this sort will have.  It
leans rather more heavily towards white male than the actual literature,
and certainly than my reading.  The lack of non-white writers is
particularly troubling.  But it's still an interesting selection.  (For
those wondering about some obvious omissions, young adult was explicitly
excluded.)
</p>

<p>
The rules are to bold the works one has read in their entirety and
italicize the ones you've read part of but not finished.  I'll add
underlining the works that I own, which provides some indication of the
things that I've not read but that are on my to-read list.
</p>

<ol>
<li class="packed"><strong><u>The Lord Of The Rings Trilogy, by J.R.R. Tolkien</u></strong>: 
    It's a boring winner because it always wins, but it's an amazing book
    and I can't argue with it.  I'll probably never review this one since
    I'm not sure I have anything original to say about it.</li>

t/data/spin/output/journal/index.html  view on Meta::CPAN

<p>
This list has a ton of problems, like any list of this sort will have.  It
leans rather more heavily towards white male than the actual literature,
and certainly than my reading.  The lack of non-white writers is
particularly troubling.  But it's still an interesting selection.  (For
those wondering about some obvious omissions, young adult was explicitly
excluded.)
</p>

<p>
The rules are to bold the works one has read in their entirety and
italicize the ones you've read part of but not finished.  I'll add
underlining the works that I own, which provides some indication of the
things that I've not read but that are on my to-read list.
</p>






t/data/spin/output/journal/index.rss  view on Meta::CPAN

<p>
This list has a ton of problems, like any list of this sort will have.  It
leans rather more heavily towards white male than the actual literature,
and certainly than my reading.  The lack of non-white writers is
particularly troubling.  But it's still an interesting selection.  (For
those wondering about some obvious omissions, young adult was explicitly
excluded.)
</p>

<p>
The rules are to bold the works one has read in their entirety and
italicize the ones you've read part of but not finished.  I'll add
underlining the works that I own, which provides some indication of the
things that I've not read but that are on my to-read list.
</p>

<ol>
<li class="packed"><strong><u>The Lord Of The Rings Trilogy, by J.R.R. Tolkien</u></strong>: 
    It's a boring winner because it always wins, but it's an amazing book
    and I can't argue with it.  I'll probably never review this one since
    I'm not sure I have anything original to say about it.</li>

t/data/update/ansicolor/docknot.yaml  view on Meta::CPAN

- holder: Zenin
  years: '1996'
- holder: Kurt Starsinic <kstarsinic@gmail.com>
  years: '2012'
description: |
  This Perl module is a simple and convenient interface to the ANSI terminal
  escape sequences for color (from ECMA-48, also included in ISO 6429).  The
  color sequences are provided in two forms, either as constants for each
  color or via a function that takes the names of colors and returns the
  appropriate escape codes or wraps them around the provided text.  The
  non-color text style codes from ANSI X3.64 (bold, dark, underline, and
  reverse, for example), which were also included in ECMA-48 and ISO 6429,
  are also supported.  Also supported are the extended colors used for
  sixteen-color and 256-color emulators.

  This module is very stable, and I've used it in a wide variety of
  applications.  It has been included in the core Perl distribution starting
  with version 5.6.0, so you don't need to download and install it yourself
  unless you have an old version of Perl or need a newer version of the
  module than comes with your version of Perl.  I continue to maintain it as
  a separate module, and the version included in Perl is resynced with mine

t/data/update/ansicolor/old/description  view on Meta::CPAN

This Perl module is a simple and convenient interface to the ANSI terminal
escape sequences for color (from ECMA-48, also included in ISO 6429).  The
color sequences are provided in two forms, either as constants for each
color or via a function that takes the names of colors and returns the
appropriate escape codes or wraps them around the provided text.  The
non-color text style codes from ANSI X3.64 (bold, dark, underline, and
reverse, for example), which were also included in ECMA-48 and ISO 6429,
are also supported.  Also supported are the extended colors used for
sixteen-color and 256-color emulators.

This module is very stable, and I've used it in a wide variety of
applications.  It has been included in the core Perl distribution starting
with version 5.6.0, so you don't need to download and install it yourself
unless you have an old version of Perl or need a newer version of the
module than comes with your version of Perl.  I continue to maintain it as
a separate module, and the version included in Perl is resynced with mine



( run in 2.319 seconds using v1.01-cache-2.11-cpan-c333fce770f )