Data-ShowTable

 view release on metacpan or  search on metacpan

ShowTable.pm  view on Meta::CPAN

%Type2Format = (
  'char'	=> '%%-%ds',
  'varchar'	=> '%%-%ds',
  'symbol'	=> '%%-%ds',
  'tinyint'	=> '%%%dd',
  'shortint'	=> '%%%dd',
  'int'		=> '%%%dd',
  'pct'	        => '%%%d.%df%%%%',
  'real'	=> '%%%d.%df',
  'float'	=> '%%%d.%df',
  'numeric'	=> '%%%d.%df',
  'text'	=> '%%-%ds',

  # The money types do not actually need to be in this table, since 
  # ShowTableValue handle money formatting explicitly.  However, some
  # one else might use this table, so we treat them like right-aligned
  # strings.
  'money'	=> '%%%d.%df',
  'smallmoney'	=> '%%%d.%df',

  );

=head1 PlainText

S<  >I<$plaintext> = B<&PlainText>(I<$htmltext>);

S<  >B<&PlainText>

This function removes any HTML formatting sequences from the input argument,
or from C<$_> if no argument is given.  The resulting plain text is returned
as the result.

=cut

#   $plaintext = &PlainText($htmltext);
# or:
#   &PlainText;
#
# Convert the argument and return as a string, or convert $_.

sub PlainText {
    local($_) = shift if $#_ >= 0;	# set local $_ if there's an argument
					# skip unless there's a sequence
    return $_ unless m=</?($HTML_Elements)=i;	# HTML text?
    s{</?(?:$HTML_Elements)#		# match and remove any HTML token..
	 (?:\ \w+#			# ..then PARAM or PARAM=VALUE
	     (?:\=(?:"(?:[^"]|\\")*"|#	# ...."STRING" or..
		    [^"> ]+#		# ....VALUE
		 )#
	     )?#			# ..=VALUE is optional
	 )*#				# zero or more PARAM or PARAM=VALUE
      >}{}igx;				# up to the closing '>'
    $_;					# return the result
}

BEGIN {

@HTML_Elements = qw(
    A ABBREV ACRONYM ADDRESS APP APPLET AREA AU B BANNER BASE BASEFONT BDO
    BGSOUND BIG BLINK BLOCKQUOTE BODY BQ BR CAPTION CENTER CITE CODE COL
    COLGROUP CREDIT DD DEL DFN DIR DIV DL DT EM EMBED FN FIG FONT FORM FRAME
    FRAMESET H1 H2 H3 H4 H5 H6 HEAD HP HR HTML I IMG INPUT INS ISINDEX KBD
    LANG LH LI LINK LISTING MAP MARQUEE MENU META NEXTID NOBR NOEMBED
    NOFRAMES NOTE OL OPTION OVERLAY P PARAM PERSON PLAINTEXT PRE Q S SAMP
    SELECT SMALL SPAN STRIKE STRONG SUB SUP TAB TABLE TBODY TD TEXTAREA
    TFOOT TH THEAD TITLE TR TT U UL VAR WBR XMP 
);

$HTML_Elements = join("|",@HTML_Elements);

}

=head1 VARIABLES

The following variables may be set by the user to affect the display (with
the defaults enclosed in square brackets [..]):

=over 10

=item B<$Show_Mode> [Box]

This is the default display mode when using B<ShowTable>.  The
environment variable, C<$ENV{'SHOW_MODE'}>, is used when this variable is
null or the empty string.  The possible values for this variable are:
C<"Box">, C<"List">, C<"Table">, and C<"HTML">.  Case is insignificant.

=item B<$List_Wrap_Margin> [2]

This variable's value determines how large a margin to keep before wrarpping a
long value's display in a column.  This value is only used in "List" mode.

=item B<$Max_List_Width> [80]

This variable, used in "List" mode, is used to determine how long an output line
may be before wrapping it.  The environment variable, C<$ENV{'COLUMNS'}>, is
used to define this value when it is null.

=item B<$Max_Table_Width> ['']

This variable, when set, causes all tables to have their columns scaled
such that their total combined width does not exceed this value.  When
this variable is not set, which is the default case, there is no maximum
table width, and no scaling will be done.

=item B<$No_Escape> ['']

If set, allows embedded HTML text to be included in the data displayed
in an HTML-formatted table.  By default, the HTML formatting characters
("<", ">", and "&") occuring in values are escaped.

=item B<%URL_Keys>

In HTML mode, this variable is used to recognize which columns are to be 
displayed with a corresponding hypertext anchor.  See L<"ShowHTMLTable"> 
for more details.

=item B<@HTML_Elements>

An array of HTML elements (as of HTML 3.0) used to recognize and strip for 
width calculations.

=item B<$HTML_Elements>



( run in 4.168 seconds using v1.01-cache-2.11-cpan-71847e10f99 )