Loading...
 

Typography


Tiki17 includes a typographic prettifier that translates plain punctuation into smart typographic punctuation characters. The typographic prettifier will also automatically change normal spaces for no-break spaces in some instances to avoid awkward line breaks. This feature is provided by including PHP SmartyPants.

These features are enabled by default but can be toggled on or off from the General Settings tab of the Editing and Plugins control panel if for some reason they aren't appropriate for your site. Typical example: when you use wiki pages as Smarty template resources for PluginTrackerlist and it contains double or single quotes it can break parsing the TPL with a parse error.

Transforms

Smart quotes

Straight quotes ( " and ' ) are converted into “curly” quotes.

Also, inside words written using the Hebrew alphabet, a straight apostrophe or double quote character will become a proper Geresh or Gershayim character.

Approximative ASCII quotes

Note: this option is not enabled by default.

Backtick-style quotes ( ``like this'' ) become “curly” quotes. This also enables approximative guillemets ( <<like this>> ) and low double quotes using a double comma ( ,,like this`` ).


This option is not enabled by default. Also, in some instances were a double apostrophe is used, it can be ambiguous with the wiki syntax. In case of ambiguity, the wiki syntax takes precedence and you might lose your quotes.

Dashes

Double hyphen ( -- ) becomes an em-dash: —

Note that to avoid ambiguity with the strikethrough wiki syntax, double hyphens should have a space on both side.

Ellipsis

Three consecutive dots ( ... ) become an ellipsis character…

Smart spacing

You probably won't notice that something is happening with the spaces, but you might notice fewer line breaks happening in awkward places. That is because the typographic prettifier replaces spaces with no-break spaces in some places. A no-break space is visually identical to a regular space, but prevents line breaks from occuring there.

The default configuration will never insert or remove a space. It will only replace existing spaces with no-break spaces in the following instances:

  • before a colon_:
  • before a semi-colon_;
  • before an exclamation mark_! or a question mark_? (also work for ¡_inverted_! marks)
  • inside «_french guillemets_» (but will no-break spaces for »german« or »finish» quotes)
  • as a thousand separator: 100_000
  • between a recognized unit symbol and its numeric value 12_kg 10_$


The no-break space is represented with _ to make it visible in the examples above. In reality you will see a normal space.

Avoiding the typographic prettifier

Monospace & preformated text

Most of the time monospace text and preformatted sections are used for code sample. Altering the quotes or the punctuation there would make the code invalid. So monospace text and preformatted sections are left untouched by the typographic prettifier.

Escapes

If you find yourself in a situation where curled quotes or other smart punctuation is not desirable in regular text, you can prefix the punctuation with a backslash character (-+\+-) which will make the typographic prettifier to ignore this character. For instance, when writing about feets and inches you normally should not use curly quotes:

He is 5\' 8\" tall.

Algorithmic shortcomings

The typographic prettifier uses a heuristic that works almost all the time, but there will be some rare cases where it won't curl the quotes the right way. For instance:

'Twas the night before Christmas.

Here the typographic prettifier will curl the quote the wrong way — as an opening single quote while in reality it should be an apostrophe indicating the contraction. In cases like this, you will need to insert the correct curly quote manually.

Configuration

You can toggle on or off globally various parts of the typographic prettifier from the Editing and Plugins control panel.

Advanced per-language configuration

You can add a typography.php file in the directory that contains the translation for a particular language. Just rename the typography.php_example file by removing the _example suffix, uncomment the lines where you want to change the defaults and set the appropriate values.

In that file, you can specify which smart quote characters to use for this particular language.

You can also refine more precisely the spacing rules for each of the cases above: use 2 to force a space to be inserted if not present (won't work for the thousand separator though), or use -1 to force-remove the space if one is present.

It is also possible to change the smart space character to use for each punctuation mark independently. So if you want to use a half-space before the colon, you can. Although beware of font and browser support if you use non-mainstream space characters.

List Slides