public function __construct($attr = SMARTYPANTS_ATTR_DEFAULT) { # # Initialize a SmartyPantsTypographer_Parser with certain attributes. # # Parser attributes: # 0 : do nothing # 1 : set all, except dash spacing # 2 : set all, except dash spacing, using old school en- and em- dash shortcuts # 3 : set all, except dash spacing, using inverted old school en and em- dash shortcuts # # Punctuation: # q -> quotes # b -> backtick quotes (``double'' only) # B -> backtick quotes (``double'' and `single') # c -> comma quotes (,,double`` only) # g -> guillemets (<<double>> only) # d -> dashes # D -> old school dashes # i -> inverted old school dashes # e -> ellipses # w -> convert " entities to " for Dreamweaver users # # Spacing: # : -> colon spacing +- # ; -> semicolon spacing +- # m -> question and exclamation marks spacing +- # h -> em-dash spacing +- # H -> en-dash spacing +- # f -> french quote spacing +- # t -> thousand separator spacing - # u -> unit spacing +- # (you can add a plus sign after some of these options denoted by + to # add the space when it is not already present, or you can add a minus # sign to completly remove any space present) # # Initialize inherited SmartyPants parser. parent::__construct($attr); if ($attr == "1" || $attr == "2" || $attr == "3") { # Do everything, turn all options on. $this->do_comma_quotes = 1; $this->do_guillemets = 1; $this->do_space_emdash = 1; $this->do_space_endash = 1; $this->do_space_colon = 1; $this->do_space_semicolon = 1; $this->do_space_marks = 1; $this->do_space_frenchquote = 1; $this->do_space_thousand = 1; $this->do_space_unit = 1; } else { if ($attr == "-1") { # Special "stupefy" mode. $this->do_stupefy = 1; } else { $chars = preg_split('//', $attr); foreach ($chars as $c) { if ($c == "c") { $current =& $this->do_comma_quotes; } else { if ($c == "g") { $current =& $this->do_guillemets; } else { if ($c == ":") { $current =& $this->do_space_colon; } else { if ($c == ";") { $current =& $this->do_space_semicolon; } else { if ($c == "m") { $current =& $this->do_space_marks; } else { if ($c == "h") { $current =& $this->do_space_emdash; } else { if ($c == "H") { $current =& $this->do_space_endash; } else { if ($c == "f") { $current =& $this->do_space_frenchquote; } else { if ($c == "t") { $current =& $this->do_space_thousand; } else { if ($c == "u") { $current =& $this->do_space_unit; } else { if ($c == "+") { $current = 2; unset($current); } else { if ($c == "-") { $current = -1; unset($current); } else { # Unknown attribute option, ignore. } } } } } } } } } } } } $current = 1; } } } }