public function __construct() { // get locale $this->locale = Config::get('letterpress.locale'); // defaults if (Config::get('letterpress.microtypography.useDefaults')) { $this->fixers = Config::get('jolitypo.defaults'); // locale additions $localeKey = sprintf('jolitypo.%s', $this->locale); if (Config::has($localeKey)) { $this->fixers = array_merge($this->fixers, Config::get($localeKey)); } } // hyphenation if (Config::get('letterpress.microtypography.enableHyphenation')) { $this->fixers[] = 'Hyphen'; } // user additions $this->fixers = array_merge($this->fixers, Config::get('letterpress.microtypography.additionalFixers')); if (count($this->fixers) === 0) { throw new LetterpressException('Typography fixing requires setting up fixers.'); } $this->fixer = new Fixer($this->fixers); $this->fixer->setLocale($this->locale); }
public function testHtmlHeart() { $fixed = <<<HTML <p>We <3 web.</p> HTML; $to_fix = <<<HTML <p>We <3 web.</p> HTML; $fixer = new Fixer($this->en_fixers); $fixer->setLocale('en'); $this->assertInstanceOf('JoliTypo\\Fixer', $fixer); $this->assertEquals($fixed, $fixer->fix($to_fix)); }
public function testEncodingMess() { $fixer = new Fixer($this->fr_fixers); $fixer->setLocale('fr'); $this->assertInstanceOf('JoliTypo\\Fixer', $fixer); $fixed = <<<HTML Ça s’ar­rête là ! HTML; $to_fix = <<<HTML Ça s'arrête là ! HTML; $this->assertEquals($fixed, $fixer->fix($to_fix)); }
/** * @see https://github.com/jolicode/JoliTypo/issues/16 */ public function testNoBreakingSpaceInsideGoodQuotes() { $fixer = new Fixer($this->fr_fixers); $fixer->setLocale('fr'); $this->assertInstanceOf('JoliTypo\\Fixer', $fixer); $fixed = <<<HTML « test » et « test » sont dans un bateau. HTML; $to_fix = <<<HTML « test » et «test» sont dans un bateau. HTML; $this->assertEquals($fixed, $fixer->fix($to_fix)); $to_fix = <<<HTML « test » et «test» sont dans un bateau. HTML; $this->assertEquals($fixed, $fixer->fix($to_fix)); }
/** * @see https://github.com/jolicode/JoliTypo/issues/15 */ public function testNumericDoesNotBreakOtherFixers() { $fixer = new Fixer($this->fr_fixers); $fixer->setLocale('fr'); $this->assertInstanceOf('JoliTypo\\Fixer', $fixer); $fixed = <<<HTML 2 × 5 doit être corrigé, et 2 h aussi. HTML; $to_fix = <<<HTML 2 x 5 doit être corrigé, et 2 h aussi. HTML; $this->assertEquals($fixed, $fixer->fix($to_fix)); }
/** * @expectedException \InvalidArgumentException */ public function testBadLocale() { $fixer = new Fixer(array('Ellipsis')); $fixer->setLocale(false); }