phpTypography Settings Methods

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.

php­Ty­pog­ra­phy Set­tings Methods

return to top

set_​defaults()

Descrip­tion

bool set_defaults ( )

A method of class php­Ty­pog­ra­phy. This method calls all other set­tings meth­ods with their default para­me­ters. This method is called auto­mat­i­cally at the cre­ation of a php­Ty­pog­ra­phy instance. It may be called to inde­pen­dently to restore default settings.

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​tags_​to_​ignore()

Descrip­tion

bool set_tags_to_ignore ( [ mixed $tagNames = array("code", "head", "kbd", "object", "option", "pre", "samp", "script", "select", "style", "textarea", "title", "var", "math") ] )

A method of class php­Ty­pog­ra­phy. This method iden­ti­fies HTML ele­ments to which typo­graphic pro­cess­ing should not be applied.

Para­me­ter

tag­Names
OPTIONAL. A string or array of HTML ele­ment names to which typo­graphic pro­cess­ing should not be applied. Defaults to array("code", "head", "kbd", "object", "option", "pre", "samp", "script", "select", "style", "textarea", "title", "var", "math")

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​classes_​to_​ignore()

Descrip­tion

bool set_classes_to_ignore ( [ mixed $classNames = array("vcard") ] )

A method of class php­Ty­pog­ra­phy. This method iden­ti­fies HTML classes to which typo­graphic pro­cess­ing should not be applied.

Para­me­ter

class­Names
OPTIONAL. A string or array of HTML class names to which typo­graphic pro­cess­ing should not be applied. Defaults to array("vcard")

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​ids_​to_​ignore()

Descrip­tion

bool set_ids_to_ignore ( [ mixed $idNames = array() ] )

A method of class php­Ty­pog­ra­phy. This method iden­ti­fies HTML IDs to which typo­graphic pro­cess­ing should not be applied.

Para­me­ter

idNames
OPTIONAL. A string or array of HTML IDs to which typo­graphic pro­cess­ing should not be applied. Defaults to array()

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenation()

Descrip­tion

bool set_hyphenation ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method turns on and off the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenation_​language()

Descrip­tion

bool set_hyphenation_language ( [ string $languageCode = "en-US" ] )

A method of class php­Ty­pog­ra­phy. This method sets the lan­guage spe­cific hyphen­ation pat­terns used in the hyphen­ation func­tion­al­ity of the process method. You may use the get_​​languages method to auto­mat­i­cally gen­er­ate a list of all installed lan­guage patterns.

Para­me­ter

lan­guage­Code
OPTIONAL. A string equal to the Lan­guage Code of a hyphen­ation pat­tern. Allowed Lan­guage Codes are those for which a dic­tio­nary has been loaded into the ‘php-​​typography/​lang’ direc­tory. Defaults to en-US

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​min_​length_​hyphenation()

Descrip­tion

bool set_min_length_hyphenation ( [ int $length = 5 ] )

A method of class php­Ty­pog­ra­phy. This method sets the min­i­mum word length for the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

length
OPTIONAL. An inte­ger equal to the min­i­mum word length for the hyphen­ation func­tion­al­ity. Defaults to 5

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​min_​before_​hyphenation()

Descrip­tion

bool set_min_before_hyphenation ( [ int $length = 3 ] )

A method of class php­Ty­pog­ra­phy. This method sets the min­i­mum num­ber of char­ac­ters between the begin­ning of a word and the first hyphen­ation point for the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

length
OPTIONAL. An inte­ger equal to the min­i­mum num­ber of char­ac­ters between the begin­ning of a word and the first hyphen­ation point for the hyphen­ation func­tion­al­ity. Defaults to 3

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​min_​after_​hyphenation()

Descrip­tion

bool set_min_after_hyphenation ( [ int $length = 2 ] )

A method of class php­Ty­pog­ra­phy. This method sets the min­i­mum num­ber of char­ac­ters between the last hyphen­ation point and the end of a word for the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

length
OPTIONAL. An inte­ger equal to the min­i­mum num­ber of char­ac­ters between the last hyphen­ation point and the end of a word for the hyphen­ation func­tion­al­ity. Defaults to 2

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenate_​headings()

Descrip­tion

bool set_hyphenate_headings ( [ int $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method turns on and off the hyphen­ation func­tion­al­ity for head­ings of the process method.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenate_​title_​case()

Descrip­tion

bool set_hyphenate_title_case ( [ int $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method turns on and off hyphen­ation of cap­i­tal­ized (title case) words for the hyphen­ation func­tion­al­ity of the process method. Set this method to FALSE to pro­tect proper nouns from hyphenation.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenate_​all_​caps()

Descrip­tion

bool set_hyphenate_all_caps ( [ int $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method turns on and off hyphen­ation of words con­sist­ing of all cap­i­tal let­ters for the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​hyphenation_​exceptions()

Descrip­tion

bool set_hyphenation_exceptions ( [ mixed $exceptions = array() ] )

A method of class php­Ty­pog­ra­phy. This method sets cus­tom hyphen­ation points for spec­i­fied words for the hyphen­ation func­tion­al­ity of the process method.

Para­me­ter

excep­tions
OPTIONAL. Either a string of a sin­gle hyphen­ation excep­tion or an array of mul­ti­ple hyphen­ation excep­tions. Each excep­tion should be the cor­rect spelling of the tar­geted word with a hard-​​hyphen (minus sign) inserted at each allow­able hyphen­ation point. Defaults to array()

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​fraction_​spacing()

Descrip­tion

bool set_fraction_spacing ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will keep inte­gers and trail­ing frac­tions together on the same line by insert­ing a non-​​breaking space between them.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​unit_​spacing()

Descrip­tion

bool set_unit_spacing ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will keep numeric val­ues and trail­ing units on the same line by insert­ing a non-​​breaking space between them.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​units()

Descrip­tion

bool set_units ( [ mixed $units = array() ] )

A method of class php­Ty­pog­ra­phy. This method works in con­junc­tion with the set_​unit_​spacing method. set_​unit_​spacing already looks for a vast set of units. This method can be used to fill in any holes.

Para­me­ter

units
OPTIONAL. Either a string of a sin­gle unit name or an array of mul­ti­ple unit names. Defaults to array()

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​dash_​spacing()

Descrip­tion

bool set_dash_spacing ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will force thin-​​spaces between em or en dashes and adjoin­ing letters.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​single_​character_​word_​spacing()

Descrip­tion

bool set_single_character_word_spacing ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will force force sin­gle char­ac­ter words to wrap to new line (unless they are wid­ows). Added in ver­sion 1.9

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​​space_​​collapse()

Descrip­tion

bool set_​space_​collapse ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will col­lapse adja­cent spac­ing to a sin­gle char­ac­ter. Nor­mal HTML pro­cess­ing col­lapses basic spaces. This option will addi­tion­ally col­lapse no-​​break spaces, zero-​​width spaces, fig­ure spaces, etc. Added in ver­sion 1.13

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​dewidow()

Descrip­tion

bool set_dewidow ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will attempt to pro­tect wid­ows. Wid­ows are the last word in a block level text that falls to it’s own line. Wid­ows get lonely when they are all alone. Wid­ows are kept com­pany by the injec­tion of a non-​​breaking space between them and the pre­vi­ous word (caus­ing both words to drop to the next line together).

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​max_​dewidow_​length()

Descrip­tion

bool set_max_dewidow_length ( [ int $length = 5 ] )

A method of class php­Ty­pog­ra­phy. This method sets the max­i­mum word length of wid­ows who will be pro­tected. Some wid­ows are long enough, they can keep them­selves company.

Para­me­ter

length
OPTIONAL. An inte­ger equal to the max­i­mum word length of wid­ows who will be pro­tected. Defaults to 5

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​max_​dewidow_​pull()

Descrip­tion

bool set_max_dewidow_pull ( [ int $length = 5 ] )

A method of class php­Ty­pog­ra­phy. This method sets the max­i­mum word length that can be pulled from the pre­vi­ous line to keep wid­ows com­pany. Some words are too heavy to move (espe­cially with jus­ti­fied text).

Para­me­ter

length
OPTIONAL. An inte­ger equal to the max­i­mum word length of wid­ows who will be pro­tected. Defaults to 5

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​wrap_​hard_​hyphens()

Descrip­tion

bool set_wrap_hard_hyphens ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. Some browsers will not allow words such as “mother-​​in-​​law” to wrap after a hard hyphen at line’s end. This method will enable wrap­ping after hard hyphens by the inser­tion of a zero-​​width-​​space.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​email_​wrap()

Descrip­tion

bool set_email_wrap ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. Email addresses can get fairly lengthy, and not all browsers will not allow them to break-​​apart at line’s end for effi­cient line-​​wrapping. This method will enable wrap­ping of email addresses by the strate­gic inser­tion of zero-​​width-​​spaces after all non-​​alphanumeric characters.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​url_​wrap()

Descrip­tion

bool set_url_wrap ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. URLs can get very lengthy, and not all browsers will not allow them to break-​​apart at line’s end for effi­cient line-​​wrapping. This method will enable wrap­ping of URLs by the strate­gic inser­tion of zero-​​width-​​spaces. Wrap­ping points are con­ser­v­a­tively inserted into the domain por­tion of the URL and aggres­sively added to the sub­se­quent path.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​min_​after_​url_​wrap()

Descrip­tion

bool set_min_after_url_wrap ( [ int $length = 5 ] )

A method of class php­Ty­pog­ra­phy. This method sets the min­i­mum num­ber of char­ac­ters that must remain together at the end of a URL when URL wrap­ping is enabled.

Para­me­ter

length
OPTIONAL. An inte­ger equal to the min­i­mum num­ber of char­ac­ters that must remain together at the end of a URL. Defaults to 5

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​quotes()

Descrip­tion

bool set_smart_quotes ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will trans­form straight quotes and back­ticks into con­tex­tu­ally aware curly quotes, primes, apos­tro­phes, and even double-​​low-​​9-​​quotemarks.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​​smart_​​quotes_​​primary()

Descrip­tion

bool set_​smart_​quotes_​primary ( [ string $style = "doubleCurled"] )

A method of class php­Ty­pog­ra­phy. This method sets the replace­ment char­ac­ters for the dou­ble straight-​​quote char­ac­ter. Dif­fer­ent lan­guages have dif­fer­ent quo­ta­tion styles… this method accom­mo­dates these dif­fer­ences. Added in ver­sion 1.15.

Para­me­ter

style
OPTIONAL. Allowed val­ues are:
  • “dou­ble­Curled” [DEFAULT] – “foo”
  • “dou­ble­CurledRe­versed” – ”foo”
  • “doubleLow9″ – „foo”
  • “doubleLow9Reversed” – „foo“
  • “sin­gle­Curled” – ‘foo’
  • “sin­gle­CurledRe­versed” – ’foo’
  • “singleLow9″ – ‚foo’
  • “singleLow9Reversed” – ‚foo‘
  • “dou­bleGuillemets­French” – « foo »
  • “dou­bleGuillemets” – «foo»
  • “dou­bleGuillemet­sRe­versed” – »foo«
  • “sin­gleGuillemets” – ‹foo›
  • “sin­gleGuillemet­sRe­versed” – ›foo‹
  • “cor­ner­Brack­ets” – 「foo」
  • “whiteCorner­Bracket” – 『foo』

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

include('path/to/php-typography.php');
$typo = new phpTypography();
$typo->set_​smart_​quotes_​primary("doubleLow9");
$html = $typo->process($html);

echo $html;
?>

return to top

set_​​smart_​​quotes_​​secondary()

Descrip­tion

bool set_​smart_​quotes_​secondary ( [ string $style = "singleCurled"] )

A method of class php­Ty­pog­ra­phy. This method sets the replace­ment char­ac­ters for the sin­gle straight-​​quote char­ac­ter. Dif­fer­ent lan­guages have dif­fer­ent quo­ta­tion styles… this method accom­mo­dates these dif­fer­ences. Added in ver­sion 1.15.

Para­me­ter

style
OPTIONAL. Allowed val­ues are:
  • “dou­ble­Curled” – “foo”
  • “dou­ble­CurledRe­versed” – ”foo”
  • “doubleLow9″ – „foo”
  • “doubleLow9Reversed” – „foo“
  • “sin­gle­Curled” [DEFAULT] – ‘foo’
  • “sin­gle­CurledRe­versed” – ’foo’
  • “singleLow9″ – ‚foo’
  • “singleLow9Reversed” – ‚foo‘
  • “dou­bleGuillemets­French” – « foo »
  • “dou­bleGuillemets” – «foo»
  • “dou­bleGuillemet­sRe­versed” – »foo«
  • “sin­gleGuillemets” – ‹foo›
  • “sin­gleGuillemet­sRe­versed” – ›foo‹
  • “cor­ner­Brack­ets” – 「foo」
  • “whiteCorner­Bracket” – 『foo』

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

include('path/to/php-typography.php');
$typo = new phpTypography();
$typo->set_​smart_​quotes_​secondary("doubleLow9");
$html = $typo->process($html);

echo $html;
?>

return to top

set_​smart_​quotes_​language()

This method has been DEPRECIATED in favor of the set_​​smart_​​quotes_​​primary() and set_​​smart_​​quotes_​​secondary() methods.

return to top

set_​smart_​dashes()

Descrip­tion

bool set_smart_dashes ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will minus-​​hyphens (or mul­ti­ple minus-​​hyphens) into con­tex­tu­ally aware en and em dashes (and even no-​​break-​​hyphens for phone numbers).

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​ellipses()

Descrip­tion

bool set_smart_ellipses ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will replace three con­sec­u­tive peri­ods with an ellipses character.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​diacritics()

Descrip­tion

bool set_smart_diacritics ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will auto­mat­i­cally look for words that should uti­lize dia­crit­ics, and ensure they do. When enabled, “creme brulee” becomes “crème brûlée”. Note that this method will not process words that have alter­nate mean­ing with­out dia­crit­ics like resume & résumé, divorce & divorcé, and expose & exposé.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​diacritic_​language()

Descrip­tion

bool set_diacritic_language ( [ string $languageCode = "en-US" ] )

A method of class php­Ty­pog­ra­phy. This method sets the lan­guage spe­cific dia­critic replace­ment pat­terns used in the dia­critic func­tion­al­ity of the process method. You may use the get_​​diacritic_​​languages method to auto­mat­i­cally gen­er­ate a list of all installed lan­guage patterns.

Para­me­ter

lan­guage­Code
OPTIONAL. A string equal to the Lan­guage Code of a hyphen­ation pat­tern. Allowed Lan­guage Codes are those for which a dic­tio­nary has been loaded into the ‘php-​​typography/​diacritics’ direc­tory. Defaults to en-US

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​diacritic_​custom_​replacements()

Descrip­tion

bool set_diacritic_custom_replacements ( [ mixed $replacements = array() ] )

A method of class php­Ty­pog­ra­phy. This method sets cus­tom dia­critic replace­ment pat­terns for the dia­critic func­tion­al­ity of the process method. This method is case-​​sensitive.

Para­me­ter

replace­ments

OPTIONAL. Must be in one of two formats:

  • A string in the for­mat of "needle 1"=>"replacement 1", "needle 2"=>"replacement 2". Note: double-​​quotes are required.
  • An array in the for­mat of array( needle_1 => replacement_1, needle_2 => replacement_2 )

TIP: you may want to set this para­me­ter to
array (
"cooperate" => "coöperate",
"Cooperate" => "Coöperate",
"cooperation" => "coöperation",
"Cooperation" => "Coöperation",
"cooperative" => "coöperative",
"Cooperative" => "Coöperative",
"coordinate" => "coördinate",
"Coordinate" => "Coördinate",
"coordinated" => "coördinated",
"Coordinated" => "Coördinated",
"coordinating" => "coördinating",
"Coordinating" => "Coördinating",
"coordination" => "coördination",
"Coordination" => "Coördination",
"coordinator" => "coördinator",
"Coordinator" => "Coördinator",
"coordinators" => "coördinators",
"Coordinators" => "Coördinators",
"continuum" => "continuüm",
"Continuum" => "Continuüm",
"debacle" => "débâcle",
"Debacle" => "Débâcle",
"elite" => "élite",
"Elite" => "Élite"
)

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

include('path/to/php-typography.php');
$typo = new phpTypography();
$typo->set_diacritic_custom_replacements( array("cooperate"=>"coöperate", "Cooperate"=>"Coöperate") );
$html = $typo->process($html);

echo $html;
?>

return to top

set_​smart_​marks()

Descrip­tion

bool set_smart_marks ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will intel­li­gently use proper mark sym­bols. (r), (c), (tm), (sm), and (p) become ®, ©, , , and .

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​math()

Descrip­tion

bool set_smart_math ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will intel­li­gently inject proper minus, divi­sion and mul­ti­pli­ca­tion char­ac­ters into math equations.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​exponents()

Descrip­tion

bool set_smart_exponents ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will iden­tify expo­nents, super­script them. This makes for pretty exponents.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​fractions()

Descrip­tion

bool set_smart_fractions ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will iden­tify frac­tions, raise the numer­a­tor, lower the denom­i­na­tor and replace the slash with a fraction-​​slash. This makes for pretty fractions.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​smart_​multiplication()

Descrip­tion

This method has been DEPRECIATED in favor of the set_​smart_​math() method.

set_​smart_​ordinal_​suffix()

Descrip­tion

bool set_smart_ordinal_suffix ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will iden­tify num­bers fol­lowed by an ordi­nal suf­fix, and super­script the ordi­nal (i.e. 1st, 2nd and 3rd).

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​style_​ampersands()

Descrip­tion

bool set_style_ampersands ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will allow the wrap­ping of amper­sands with <span class="amp">. This pro­vides a hook for spe­cial CSS styling. For instance, the font may be changed to use a highly dec­o­ra­tive ampersand.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​style_​caps()

Descrip­tion

bool set_style_caps ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will allow the wrap­ping of acronyms with <span class="caps">. This pro­vides a hook for spe­cial CSS styling. For instance, you can use small-​​caps for your acronyms.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​style_​numbers()

Descrip­tion

bool set_style_numbers ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will allow the wrap­ping of num­bers with <span class="numbers">. This pro­vides a hook for spe­cial CSS styling. For instance, you can change a font from low­er­case or upper­case digits.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​style_​initial_​quotes()

Descrip­tion

bool set_style_initial_quotes ( [ bool $on = TRUE ] )

A method of class php­Ty­pog­ra­phy. This method will allow the wrap­ping of ini­tial sin­gle quotes with <span class="quo"> and ini­tial dou­ble quotes or guillemet with <span class="dquo">. This pro­vides a hook for spe­cial CSS styling. For instance, you can apply a neg­a­tive indent for hang­ing punctuation.

Para­me­ter

on
OPTIONAL. Allowed val­ues are TRUE and FALSE. Defaults to TRUE

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top

set_​initial_​quote_​tags()

Descrip­tion

bool set_initial_quote_tags ( [ mixed $tagNames = array("p", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "li", "dd", "dt") ] )

A method of class php­Ty­pog­ra­phy. This method works in con­junc­tion with the set_​style_​initial_​quotes method. This method allows you to spec­ify which block-​​level HTML ele­ments will allow ini­tial quotes to be styled.

Para­me­ter

tag­Names
OPTIONAL. Either a string of a sin­gle HTML ele­ment name or an array of mul­ti­ple HTML ele­ment names. Defaults to array("p", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "li", "dd", "dt")

Return Val­ues

Returns TRUE upon success;

Exam­ples


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

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

echo $html;
?>

return to top