This draft of the documentation remains immature. While we have made attempt to be thorough and accurate, you may encounter errors. If you discover any deficiencies, please let us know at info@kingdesk.com
This page is a subset of the documentation of the functionality provided by the PHP Typography project.class phpTypography
Description
object new phpTypography ( [ bool $setDefaults = TRUE ] )
phpTypography is a class designed to improve the typography of xHTML documents. phpTypography has the following capabilities (with granular control as to application):
- Hyphenation
- Spacing control, including: gluing values to units, widow protection, and forced internal wrapping of long URLs & email addresses.
- Intelligent character replacement, including smart handling of: quote marks, dashes, ellipses, trademarks, multiplication symbols, fractions, and ordinal suffixes (i.e. 1st, 2nd, 3rd)
- CSS hooks for styling: ampersands (class “amp”), acronyms (class “caps”), numbers (class “numbers”), initial single quotes (class “quo”), and initial double quotes & guillemets (class “dquo”).
phpTypography has the following requirements:
- the host server must run PHP 5 or later
- text must be encoded UTF-8
- all markup must be valid xHTML, specifically:
- every element must be closed,
- every attribute must have a value enclosed in quotes, and
- tag names and attributes must be lowercase.
Parameter
- setDefaults
- OPTIONAL. A Boolean value determines whether to set default options. Set to
FALSEonly if you are going to manually set each option (this saves a few processor cycles). Defaults toTRUE
Return Values
Returns an object of class phpTypography
Examples
A basic example:
<?php
$html = "raw HTML here... ";
include('path/to/php-typography.php');
$typo = new phpTypography();
$html = $typo->process($html);
echo $html;
?>
phpTypography Methods
- set_defaults()
- set_tags_to_ignore()
- set_classes_to_ignore()
- set_ids_to_ignore()
- set_hyphenation()
- set_hyphenation_language()
- set_min_length_hyphenation()
- set_min_before_hyphenation()
- set_min_after_hyphenation()
- set_hyphenate_headings()
- set_hyphenate_title_case()
- set_hyphenate_all_caps()
- set_hyphenation_exceptions()
- set_fraction_spacing()
- set_unit_spacing()
- set_units()
- set_dash_spacing()
- set_single_character_word_spacing()
- set_space_collapse()
- set_dewidow()
- set_max_dewidow_length()
- set_max_dewidow_pull()
- set_wrap_hard_hyphens()
- set_url_wrap()
- set_email_wrap()
- set_min_after_url_wrap()
- set_smart_quotes()
- set_smart_quotes_primary()
- set_smart_quotes_secondary()
- set_smart_dashes()
- set_smart_ellipses()
- set_smart_diacritics()
- set_diacritic_language()
- set_diacritic_custom_replacements()
- set_smart_marks()
- set_smart_math()
- set_smart_exponents()
- set_smart_fractions()
- set_smart_multiplication()
- set_smart_ordinal_suffix()
- set_style_ampersands()
- set_style_caps()
- set_style_numbers()
- set_style_initial_quotes()
- set_initial_quote_tags()
- process()
- process_feed()
- get_languages()
- get_diacritic_languages()

