Format.pm


NAME

Communiware::Format - preprocess routines which are called on item texts before placing them into database


SYNOPSIS

 pushref
 enr_escapeHTML
 untag_html
 img_size
 valid_richtext_format
 compute_textsize
 
=head1 DESCRIPTION

This module provides preprocessing functions, used by various posing interfaces to convert data into HTML, which would be stored in the Communiware database

enr_escapeHTML

This subroutine is used for Communiware enriched text escaping. It produces standart html-escaping and creates &nbsp

untag_html

Usage: untag_html($text,$format)

This sub returns simpified (up to plain text) html code. It cuts comments, optionally paragraphs, links and all tags

It takes html text as first arg and set of allowed options as second one.

Allowed formats must return true from valid_richtext_format

p[aragraphs]
        remove paragraphs, and lists, replacing them with spaces.
l[inks]
       replace <a> tags with link texts (contents of tag)
i[mages]
       replace img tags with their alts
a[ll]
       remove all tags. Note, that images would not be replaced
       with tags unless you'll specify 'i' option along with 'a'.
t[ext]
        same as 'a', but besides it replaces HTML entities to chars of 
communiware default charset and deletes entities absent in charset

decode_entities

Syntax

    decode_entities($string);

Decodes all the HTML entities in string, which are know to Communiware::charset module.

valid_richtext_format

Checks whether format applying to richtext is valid

compute_textsize

Syntax:

compute_textsize('text with html markup')

Computes length of text munis all HTML markup, counting all whitespace sequences as one char

cut_html


syntax

cut_html('text with html markup',$length);

Returns piece of html which contains exactly $length symbols (not counting tags and counting entity as one symbol) with all tags properly closed

16 октябрь 2007 13:44