1. Go to this page and download the library: Download jolicode/jolitypo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jolicode / jolitypo example snippets
use JoliTypo\Fixer;
// Create a Fixer, specify the fixes
$fixer = new Fixer(['Ellipsis', 'Dash', 'SmartQuotes', 'CurlyQuote', 'Hyphen']);
// Get HTML content with correct microtypography
$fixedContent = $fixer->fix(
'<p>"Tell me Mr. Anderson... what good is a phone call... if you\'re unable to speak?" -- Agent Smith, <em>Matrix</em>.</p>'
);
use JoliTypo\Fixer;
$fixer = new Fixer(['SmartQuotes', 'SpaceBeforePunctuation']);
$fixer->setLocale('fr_FR');
$fixedContent = $fixer->fix('<p>Je suis "très content" de t\'avoir invité sur <a href="http://jolicode.com/">Jolicode.com</a> !</p>');
$fixer = new Fixer(['SmartQuotes', 'CurlyQuote']);
$fixer->setLocale('en_GB');
echo $fixer->fix('<p>"This \'magic\' piece of code fixes quotes and apostrophes, doesn\'t it?"</p>');
// <p>“This ‘magic’ piece of code fixes quotes and apostrophes, doesn’t it?”</p>
use JoliTypo\Fixer;
$smartQuotes = new Fixer\SmartQuotes('de_DE');
$smartQuotes->setOpening('»');
$smartQuotes->setClosing('«');
$smartQuotes->setNestedOpening('›');
$smartQuotes->setNestedClosing('‹');
$fixer = new Fixer(['Ellipsis', 'Dash', $smartQuotes, 'CurlyQuote']);
echo $fixer->fix('<p>And this is an "example with another \'single quote\' inside".</p>');
// <p>And this is an »example with another ›single quote‹ inside«.</p>
use JoliTypo\Fixer;
use JoliTypo\Fixer\Hyphen;
$fixer = new Fixer(['Ellipsis', new Hyphen('fr_FR', leftMin: 3, rightMin: 3, wordMin: 8)]);
$fixer = new Fixer(['Ellipsis', 'Dimension', 'Dash', 'SmartQuotes', 'CurlyQuote', 'Hyphen']);
$fixedContent = $fixer->fix("<p>Some user contributed HTML which does not use proper glyphs.</p>");
$fixer->setRules(['CurlyQuote']);
$fixedContent = $fixer->fix("<p>I'm only replacing single quotes.</p>");
$fixer->setRules(['Hyphen']);
$fixer->setLocale('en_GB'); // I tell which locale to use for Hyphenation and SmartQuotes
$fixedContent = $fixer->fix("<p>Very long words like Antidisestablishmentarianism.</p>");
// by FQN
$fixer = new Fixer([
'Ellipsis',
'Acme\\YourOwn\\TypoFixer'
]);
$fixedContent = $fixer->fix("<p>Content fixed by the 2 fixers.</p>");
// or instances, or both
$fixer = new Fixer([
'Ellipsis',
'Acme\\YourOwn\\TypoFixer',
new Acme\\YourOwn\\PonyFixer("Some parameter")
]);
$fixedContent = $fixer->fix("<p>Content fixed by the 3 fixers.</p>");