NAME
Lout.pm - Module providing txt2lout, htmlentity2lout and pod2lout functions
SYNOPSIS
use Lout ;
$lout = Lout::txt2lout( $text ) ;
$lout = Lout::pod2lout( $pod ) ;
$lout = Lout::htmlentity2lout( $html ) ;
# If doing lots of htmlentity2lout this is faster:
Lout::set_option( -html => 1 ) ;
foreach $html ( @html ) {
$lout .= Lout::txt2lout( $html ) ;
}
use Lout qw( txt2lout pod2lout htmlentity2lout set_option ) ;
# or
use Lout qw( :Func ) ;
# Import the names into your namespace
use Lout qw( %Entity2char %Char2entity ) ;
# or
use Lout qw( :Hash ) ;
# Use the predefined hashes - they are *not* inversions of each other
use Lout qw( :ALL ) ; # Import the lot.
DESCRIPTION
Lout::txt2lout
This function converts a plain text string into a string of lout. It is influenced by the following options (all of which are set by calling Lout::set_option
once for each option - defaults are shown):
Lout::set_option( -html => 0)
- Treat the input as plain text; set to 1 to treat the input as HTML. If on then -verbatim is off.
Lout::set_option( -hyphen => 0)
- Convert space delimited hyphens to lout double hyphens.
Lout::set_option( -smartquotes => 1)
- Convert single and double quotes to `smart' quotes.
Lout::set_option( -superscripts => 1)
- Convert the letters after numbers to superscripts, e.g. for 1st, 2nd, 3rd, 4th, etc.
Lout::set_option( -tex => 0)
- Convert TeX and LaTeX to @TeX and @LaTeX; this assumes that you are using a lout document type which has these macros defined.
Lout::set_option( -verbatim => 1)
- On for text and pod, off for html. Allows @Verbatim Lout in your text to go through unchanged.
Lout::htmlentity2lout
This is merely a wrapper around Lout::txt2lout
which effectively calls Lout::set_option( -html => 1)
first. For processing lots of html entity strings it is quicker to set the option once and call Lout::txt2lout
direct.
NB This is the equivalent of Gisle Aas HTML::Entities::decode except that it produces Lout instead of plain text. It does not deal with HTML tags - use my HTML::LoutParser.pm
module for that.
Lout::pod2lout
This calls Lout::txt2lout
(so all the options which are set apply), and then performs pod-specific translations.
NB This only translates pod `entities' like E>gt<, etc. For full pod translation use my pod2lout
program.
Lout::set_option
(This sets the options used by Lout::txt2lout
and Lout::htmlentity2lout
as described above.)
%Entity2char
This hash is keyed by entity name (excluding leading & and trailing ;) and provides the lout equivalent, e.g.
$Entity2char{'amp'} eq '&' ;
$Entity2char{'copy'} eq '{@CopyRight}' ;
$Entity2char{'nbsp'} eq '~' ;
$Entity2char{'ccedil'} eq '{@Char ccedilla}' ;
$Entity2char{'frac12'} eq '{@Char onehalf}' ;
%Char2entity
This has is keyed by lout name (excluding braces) and provides the HTML equivalent, e.g.
$Char2entity{'@Char fi'} eq 'fi' ;
$Char2entity{'@Bullet'} eq '·' ;
$Char2entity{'@Yen'} eq '¥' ;
EXAMPLES
(See DESCRIPTION.)
BUGS
None that I know of!
CHANGES
1999/07/18 First properly documented release.
1999/07/28 Put %Entity2char in the symbol table so that other perl programs can access it, for example lout2html.
1999/08/08 Changed licence to LGPL.
1999/08/15 Added -hyphen and -verbatim options.
1999/09/04 Tiny improvement.
2000/01/24 Now use exporter so you can import the functions in to your name space. Added %Char2entity hash.
AUTHOR
Mark Summerfield. I can be contacted as <summer@perlpress.com> - please include the word 'lout' in the subject line.
COPYRIGHT
Copyright (c) Mark Summerfield 1999-2000. All Rights Reserved.
This module may be used/distributed/modified under the LGPL.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 379:
Deleting unknown formatting code V<>