class phpTypography Documentation

This draft of the doc­u­men­ta­tion remains imma­ture. While we have made attempt to be thor­ough and accu­rate, you may encounter errors. If you dis­cover any defi­cien­cies, please let us know at info@​kingdesk.​com

This page is a sub­set of the doc­u­men­ta­tion of the func­tion­al­ity pro­vided by the PHP Typog­ra­phy project.

class php­Ty­pog­ra­phy

Descrip­tion

object new phpTypography ( [ bool $setDefaults = TRUE ] )

php­Ty­pog­ra­phy is a class designed to improve the typog­ra­phy of xHTML doc­u­ments. php­Ty­pog­ra­phy has the fol­low­ing capa­bil­i­ties (with gran­u­lar con­trol as to application):

  • Hyphen­ation
  • Spac­ing con­trol, includ­ing: glu­ing val­ues to units, widow pro­tec­tion, and forced inter­nal wrap­ping of long URLs & email addresses.
  • Intel­li­gent char­ac­ter replace­ment, includ­ing smart han­dling of: quote marks, dashes, ellipses, trade­marks, mul­ti­pli­ca­tion sym­bols, frac­tions, and ordi­nal suf­fixes (i.e. 1st, 2nd, 3rd)
  • CSS hooks for styling: amper­sands (class “amp”), acronyms (class “caps”), num­bers (class “num­bers”), ini­tial sin­gle quotes (class “quo”), and ini­tial dou­ble quotes & guillemets (class “dquo”).

php­Ty­pog­ra­phy has the fol­low­ing requirements:

  • the host server must run PHP 5 or later
  • text must be encoded UTF-​​8
  • all markup must be valid xHTML, specifically:
    • every ele­ment must be closed,
    • every attribute must have a value enclosed in quotes, and
    • tag names and attrib­utes must be lowercase.

Para­me­ter

set­De­faults
OPTIONAL. A Boolean value deter­mines whether to set default options. Set to FALSE only if you are going to man­u­ally set each option (this saves a few proces­sor cycles). Defaults to TRUE

Return Val­ues

Returns an object of class php­Ty­pog­ra­phy

Exam­ples

A basic example:


<?php
$html = "raw HTML here... ";

include('path/to/php-typography.php');
$typo = new phpTypography();
$html = $typo->process($html);

echo $html;
?>

php­Ty­pog­ra­phy Methods