{"id":28458111,"url":"https://github.com/jolicode/jolitypo","last_synced_at":"2025-07-02T05:31:41.993Z","repository":{"id":5770604,"uuid":"6984080","full_name":"jolicode/JoliTypo","owner":"jolicode","description":":abc: Microtypography fixer for the web","archived":false,"fork":false,"pushed_at":"2025-04-25T15:05:05.000Z","size":395,"stargazers_count":333,"open_issues_count":12,"forks_count":25,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-06-07T00:09:40.271Z","etag":null,"topics":["hacktoberfest","microtypography","microtypography-fixer","php","typography"],"latest_commit_sha":null,"homepage":"https://jolitypo.jolicode.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jolicode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-12-03T15:03:58.000Z","updated_at":"2025-05-26T21:03:10.000Z","dependencies_parsed_at":"2023-12-28T11:38:12.174Z","dependency_job_id":"3122046f-e67d-4025-8c54-8997b9f67f3e","html_url":"https://github.com/jolicode/JoliTypo","commit_stats":{"total_commits":228,"total_committers":23,"mean_commits":9.91304347826087,"dds":0.3114035087719298,"last_synced_commit":"16cb8d05f947afe6852cd0209f0b475092639a3e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/jolicode/JoliTypo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolicode%2FJoliTypo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolicode%2FJoliTypo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolicode%2FJoliTypo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolicode%2FJoliTypo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jolicode","download_url":"https://codeload.github.com/jolicode/JoliTypo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolicode%2FJoliTypo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263081366,"owners_count":23410867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","microtypography","microtypography-fixer","php","typography"],"created_at":"2025-06-07T00:09:50.067Z","updated_at":"2025-07-02T05:31:41.932Z","avatar_url":"https://github.com/jolicode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"JoliTypo – Web Microtypography fixer\n====================================\n\n\u003e Finally a tool for typography nerds.\n\nJoliTypo is a tool fixing [Microtypography](https://en.wikipedia.org/wiki/Microtypography) glitches inside your HTML content.\n\n```php\nuse JoliTypo\\Fixer;\n\n$fixer = new Fixer(['Ellipsis', 'Dash', 'SmartQuotes', 'CurlyQuote', 'Hyphen']);\n$fixedContent = $fixer-\u003efix('\u003cp\u003e\"Tell me Mr. Anderson... what good is a phone call... if you\\'re unable to speak?\" -- Agent Smith, \u003cem\u003eMatrix\u003c/em\u003e.\u003c/p\u003e');\n```\n```html\n\u003cp\u003e\u0026ldquo;Tell me Mr. Ander\u0026shy;son\u0026hellip; what good is a phone call\u0026hellip; if you\u0026rsquo;re unable to speak?\u0026rdquo;\u0026mdash;Agent Smith, \u003cem\u003eMatrix\u003c/em\u003e.\u003c/p\u003e\n```\n\u003e “Tell me Mr. Anderson… what good is a phone call… if you’re unable to speak?”—Agent Smith, Matrix.\n\nIt's designed to be:\n\n- language agnostic (you can fix `fr_FR`, `fr_CA`, `en_US`... You tell JoliTypo what to fix);\n- easy to integrate into modern PHP projects (composer and autoload);\n- robust (make use of `\\DOMDocument` instead of parsing HTML with dummy regexp);\n- smart enough to avoid Javascript, Code, CSS processing... (configurable protected tags list);\n- fully tested;\n- fully open and usable in any project (MIT License).\n\nYou can try it with the [online demo](https://jolitypo.jolicode.com/)!\n\n[![Latest Stable Version](https://poser.pugx.org/jolicode/JoliTypo/version.png)](https://packagist.org/packages/jolicode/JoliTypo)\n\nQuick usage\n===========\n\nJust tell the Fixer class [which Fixer](#available-fixers) you want to run on your content and then, call `fix()`:\n\n```php\nuse JoliTypo\\Fixer;\n\n$fixer = new Fixer([\"SmartQuotes\", \"FrenchNoBreakSpace\"]);\n$fixer-\u003esetLocale('fr_FR');\n$fixedContent = $fixer-\u003efix('\u003cp\u003eJe suis \"très content\" de t\\'avoir invité sur \u003ca href=\"http://jolicode.com/\"\u003eJolicode.com\u003c/a\u003e !\u003c/p\u003e');\n```\n\nFor your ease of use, you can find [ready to use list of Fixer for your language here](#fixer-recommendations-by-locale).\nMicro-typography is nothing like a standard or a law, what really matters is consistency, so feel free to use your own lists.\n\nPlease be advised that JoliTypo works best on **HTML content**; it will also work on plain text, but will be less smart about\n smart quotes. When fixing a complete HTML document, potential `\u003chead\u003e`, `\u003chtml\u003e` and `\u003cbody\u003e` tags may be removed.\n\nTo fix non HTML content, use the `fixString()` method:\n\n```php\nuse JoliTypo\\Fixer;\n\n$fixer = new Fixer([\"Trademark\", \"SmartQuotes\"]);\n$fixedContent = $fixer-\u003efixString('Here is a \"protip(c)\"!'); // Here is a “protip©”!\n```\n\nCLI usage\n=========\n\nYou can run a standalone version of JoliTypo by downloading [the PHAR version](https://github.com/jolicode/JoliTypo/releases/latest)\n\nRun `jolitypo --help` to know how to configure the Fixer.\n\nInstallation\n============\n\nRequirements are handled by Composer (libxml and mbstring are required).\n\n```\ncomposer require jolicode/jolitypo\n```\n\n*Usage outside composer is also possible, just add the `src/` directory to any PSR-0 compatible autoloader.*\n\nIntegrations\n===========\n\n- (Built-in) [Symfony Bundle](src/JoliTypo/Bridge/Symfony)\n- (Built-in) [Twig extension](src/JoliTypo/Bridge/Twig)\n- (Built-in) [CLI](https://github.com/jolicode/JoliTypo/releases/latest)\n- [Wordpress plugin](http://wordpress.org/plugins/typofr/)\n- [Drupal module](https://github.com/Anaethelion/JoliTypo-for-Drupal)\n- [Joomla plugin](https://github.com/YGomiero/typographe)\n- [MODX Extra](https://github.com/jenswittmann/JoliTypo)\n\nAvailable Fixers\n================\n\nDash\n----\n\nReplaces the simple dash `-` by a ndash `–` between numbers (dates ranges...) and the double `--` by a mdash `—`.\n\nDimension\n---------\n\nReplaces the letter x between numbers (`12 x 123`) by a times entity (`×`, the real mathematical symbol).\n\nEllipsis\n--------\n\nReplaces the three dots `...` by an ellipsis `…`.\n\nSmartQuotes\n-----------\n\nConverts dumb quotes `\" \"` to all kinds of smart style quotation marks (`“ ”`, `« »`, `„ “`...). Handles a good variety of locales,\nlike English, Arabic, French, Italian, Spanish, Irish, German...\n\nSee [the code](https://github.com/jolicode/JoliTypo/blob/master/src/JoliTypo/Fixer/SmartQuotes.php) for more details,\nand do not forget to specify a locale on the Fixer instance.\n\nThis Fixer replaces legacy `EnglishQuotes`, `FrenchQuotes` and `GermanQuotes`.\n\nFrenchNoBreakSpace\n------------------\n\nReplaces some classic spaces by non-breaking spaces following the French typographic code.\nNo break space are placed before `:`, thin no break space before `;`, `!` and `?`.\n\nNoSpaceBeforeComma\n------------------\n\nRemoves space before `,` and makes sure there is only one space after.\n\nHyphen (automatic hyphenation)\n------------------------------\n\nMakes use of `org_heigl/hyphenator`, a tool enabling word-hyphenation in PHP.\nThis Hyphenator uses the pattern-files from OpenOffice which are based on the pattern-files created for TeX.\n\nThere are only some locales available for this fixer: af_ZA, ca, da_DK, de_AT, de_CH, de_DE, en_GB, en_UK, et_EE, fr, hr_HR, hu_HU, it_IT, lt_LT, nb_NO, nn_NO, nl_NL, pl_PL, pt_BR, ro_RO, ru_RU, sk_SK, sl_SI, sr, zu_ZA.\n\nYou can read more about this fixer on [the official github repository](https://github.com/heiglandreas/Org_Heigl_Hyphenator).\n\n**This Fixer requires a Locale to be set on the Fixer with `$fixer-\u003esetLocale('fr_FR');`. Default to `en_GB`.**\n\n**Proper hyphenation is mandatory in justified text** and you should avoid word breaking in titles with this line of CSS: `hyphens:none;`.\n\n⚠ Be aware that the current screen readers are unable to spell correctly the words containing `\u0026shy;` tags. The Hyphen filter should therefore be used with caution or you might reduce your website's accessibility.\n\nCurlyQuote (Smart Quote)\n-----------------------\n\nReplaces straight quotes `'` with curly ones `’`.\nThere is one exception to consider: foot and inch marks (minutes and second marks). Purists use prime `′`, this fixer uses straight quotes for compatibility.\n[Read more about Curly quotes](http://practicaltypography.com/straight-and-curly-quotes.html).\n\nTrademark\n---------\n\nHandles trade­mark symbol `™`, a registered trade­mark symbol `®`, and a copy­right symbol `©`. This fixer replaces\ncommonly used approximations: `(r)`, `(c)` and `(TM)`. A non-breaking space is put between numbers and copyright symbols too.\n\nUnit (formerly Numeric)\n---------\n\nAdds a non-breaking space between a numeral and its unit. Like this: `12_h`, `42_฿` or `88_%`. It was named `Numeric` before release 1.0.2, but BC is kept for now.\n\n**It is really easy to make your own Fixers, feel free to extend the provided ones if they do not fit your typographic rules.**\n\nFixer recommendations by locale\n===============================\n\nen_GB\n-----\n\n```php\n$fixer = new Fixer(['Ellipsis', 'Dimension', 'Unit', 'Dash', 'SmartQuotes', 'NoSpaceBeforeComma', 'CurlyQuote', 'Hyphen', 'Trademark']);\n$fixer-\u003esetLocale('en_GB');\n```\n\nfr_FR\n-----\n\nThose rules apply for most of the recommendations of \"Abrégé du code typographique à l'usage de la presse\", ISBN: 9782351130667.\n\n```php\n$fixer = new Fixer(['Ellipsis', 'Dimension', 'Unit', 'Dash', 'SmartQuotes', 'FrenchNoBreakSpace', 'NoSpaceBeforeComma', 'CurlyQuote', 'Hyphen', 'Trademark']);\n$fixer-\u003esetLocale('fr_FR');\n```\n\nfr_CA\n-----\n\nMostly the same as fr_FR, but the space before punctuation points is not mandatory.\n\n```php\n$fixer = new Fixer(['Ellipsis', 'Dimension', 'Unit', 'Dash', 'SmartQuotes', 'NoSpaceBeforeComma', 'CurlyQuote', 'Hyphen', 'Trademark']);\n$fixer-\u003esetLocale('fr_CA');\n```\n\nde_DE\n-----\n\nMostly the same as en_GB, according to [Typefacts](http://typefacts.com/) and [Wikipedia](http://de.wikipedia.org/wiki/Typografie_f%C3%BCr_digitale_Texte).\n\n```php\n$fixer = new Fixer(['Ellipsis', 'Dimension', 'Unit', 'Dash', 'SmartQuotes', 'NoSpaceBeforeComma', 'CurlyQuote', 'Hyphen', 'Trademark']  );\n$fixer-\u003esetLocale('de_DE');\n```\n\nMore to come (contributions welcome!).\n\nDocumentation\n=============\n\nDefault usage\n-------------\n\n```php\n$fixer        = new Fixer(['Ellipsis', 'Dimension', 'Dash', 'SmartQuotes', 'CurlyQuote', 'Hyphen']);\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eSome user contributed HTML which does not use proper glyphs.\u003c/p\u003e\");\n\n$fixer-\u003esetRules(['CurlyQuote']);\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eI'm only replacing single quotes.\u003c/p\u003e\");\n\n$fixer-\u003esetRules(['Hyphen']);\n$fixer-\u003esetLocale('en_GB'); // I tell which locale to use for Hyphenation and SmartQuotes\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eVery long words like Antidisestablishmentarianism.\u003c/p\u003e\");\n```\n\nDefine your own Fixer\n---------------------\n\nIf you want to add your own Fixer to the list, you have to implement `JoliTypo\\FixerInterface`.\nThen just give JoliTypo their fully qualified name, or even instance:\n\n```php\n// by FQN\n$fixer        = new Fixer(['Ellipsis', 'Acme\\\\YourOwn\\\\TypoFixer']);\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eContent fixed by the 2 fixers.\u003c/p\u003e\");\n\n// or instances, or both\n$fixer        = new Fixer(['Ellipsis', 'Acme\\\\YourOwn\\\\TypoFixer', new Acme\\\\YourOwn\\\\PonyFixer(\"Some parameter\")]);\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eContent fixed by the 3 fixers.\u003c/p\u003e\");\n```\n\nConfigure the protected tags\n----------------------------\n\nProtected tags is a list of HTML tag names that the DOM parser must avoid. Nothing in those tags will be fixed.\n\n```php\n$fixer        = new Fixer(['Ellipsis']);\n$fixer-\u003esetProtectedTags(['pre', 'a']);\n$fixedContent = $fixer-\u003efix(\"\u003cp\u003eFixed...\u003c/p\u003e \u003cpre\u003eNot fixed...\u003c/pre\u003e \u003cp\u003eFixed... \u003ca\u003eNot Fixed...\u003c/a\u003e.\u003c/p\u003e\");\n```\n\nAdd your own Fixer / Contribute a Fixer\n=======================================\n\n- Write tests;\n- A Fixer is run on a piece of text, no HTML to deal with;\n- Implement `JoliTypo\\FixerInterface`;\n- Send your Pull request.\n\n### Contribution guidelines\n\n- You MUST write code in english;\n- you MUST follow PSR2 and Symfony coding standard (run `composer cs` on your branch);\n- you MUST run the tests (run `composer test`);\n- you MUST comply to the MIT license;\n- you SHOULD write documentation.\n\nIf you add a new Fixer, please provide sources and references about the typographic rule you want to fix.\n\nCompatibility \u0026 OS support restrictions\n=======================================\n\n- Windows XP : Thin No-Break Space can't be used, all other spaces are ignored, but they do not look bad (normal space).\n- Mac OS Snow Leopard : no no-break space, half no-break space, ems and en-dash but doesn't look bad (normal space).\n\nBUT if you use a font (`@font-face` maybe) that contains all those glyphs, there will be no issues.\n\nThere is a known [issue](https://bugs.php.net/bug.php?id=62190) preventing JoliTypo to work correctly with APC versions older than 3.1.11.\n\nWhat can you do to help?\n========================\n\nWe need to be able to use this tool everywhere, you can help by providing:\n- Wordpress plugin (to replace or complete `wptexturize`)\n- Dotclear plugin\n...\n\nAlso, there is a [Todo list](TODO.md) :kissing_smiling_eyes:\n\nLicense\n=======\n\nThis piece of code is under MIT License. See the [LICENSE](LICENSE) file.\n\nAlternatives and other implementations\n======================================\n\nThere is already quite a bunch of tools like this one (including good ones). Sadly, some are only for one language,\nsome are running regexp on the whole HTML code ([which is bad](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)), some\nare not tested, some are bundled inside a CMS or a Library, some are not using proper auto-loading, some do not have an open bug tracker... Have a look by yourself:\n\n- http://michelf.ca/projets/php-smartypants/\n- http://michelf.ca/projets/php-smartypants/typographer/\n- http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/\n- https://github.com/Cerdic/textwheel/blob/master/typographie/fr.php\n- https://github.com/spip/SPIP/blob/master/ecrire/typographie/fr.php\n- https://github.com/dg/texy/blob/master/Texy/modules/TexyTypographyModule.php\n- https://github.com/scoates/lexentity\n- https://github.com/nofont/Typesetter.js\n- https://github.com/judbd/php-typography (fork of php-typography, you can test it here: http://www.roxane-company.com/typonerd/)\n- http://mdash.ru/\n- https://blot.im/typeset/ (Server side Javascript pre-processor)\n\nGlossary \u0026 References\n=====================\n\nThanks to theses online resources for helping a developer understand typography:\n\n- [FR] http://typographisme.net/post/Les-espaces-typographiques-et-le-web\n- http://daringfireball.net/projects/smartypants/\n- [FR] http://www.uzine.net/article1802.html\n- [FR] http://dascritch.net/post/2011/05/09/Les-espacements-unicodes\n- http://www.punctuationmatters.com/ **is a must-read**\n- http://practicaltypography.com/\n- [FR] \"Abrégé du code typographique à l'usage de la presse\", ISBN: 9782351130667\n- https://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjolicode%2Fjolitypo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjolicode%2Fjolitypo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjolicode%2Fjolitypo/lists"}