{"id":17893502,"url":"https://github.com/parisek/twig-typography","last_synced_at":"2026-05-30T12:01:23.900Z","repository":{"id":57035942,"uuid":"343936169","full_name":"parisek/twig-typography","owner":"parisek","description":"Uses PHP-Typography library and exposes it as Twig Extension.","archived":false,"fork":false,"pushed_at":"2026-05-25T18:02:24.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-25T20:05:10.877Z","etag":null,"topics":["php","twig","twig-extension","typography"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/parisek/twig-typography","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parisek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-03-02T22:58:03.000Z","updated_at":"2026-05-25T18:01:09.000Z","dependencies_parsed_at":"2024-10-28T15:24:16.293Z","dependency_job_id":"2169bb02-d728-4b92-93f1-5e794762ce4d","html_url":"https://github.com/parisek/twig-typography","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"df8055e34fa071b93707c990d96cd8f6367951a7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/parisek/twig-typography","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parisek%2Ftwig-typography","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parisek%2Ftwig-typography/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parisek%2Ftwig-typography/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parisek%2Ftwig-typography/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parisek","download_url":"https://codeload.github.com/parisek/twig-typography/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parisek%2Ftwig-typography/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33691312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php","twig","twig-extension","typography"],"created_at":"2024-10-28T14:52:57.078Z","updated_at":"2026-05-30T12:01:23.892Z","avatar_url":"https://github.com/parisek.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twig Typography Extension\n\nTwig adapter for [PHP-Typography](https://github.com/mundschenk-at/php-typography) —\nsmart quotes, dashes, ellipses, hyphenation, widow protection, fraction\nglyphs, ordinal suffixes, math symbols, CSS hooks for styling.\n\n## Requirements\n\n- PHP 8.3+\n- Twig 3 or 4\n- Symfony YAML 6, 7, or 8 (always installed as a hard dependency; only invoked at runtime when the constructor receives a `.yml` file path)\n\n## Installation\n\n```bash\ncomposer require parisek/twig-typography\n```\n\n## Usage\n\n### Register on a Twig environment\n\n```php\nuse Parisek\\Twig\\TypographyExtension;\nuse Twig\\Environment;\nuse Twig\\Loader\\FilesystemLoader;\n\n$twig = new Environment(new FilesystemLoader('/path/to/templates'));\n\n// Library defaults — sane English settings.\n$twig-\u003eaddExtension(new TypographyExtension());\n\n// — or — load settings from a YAML file:\n$twig-\u003eaddExtension(new TypographyExtension(__DIR__ . '/typography.yml'));\n\n// — or — pass settings as a PHP array (no filesystem):\n$twig-\u003eaddExtension(new TypographyExtension([\n    'set_smart_quotes' =\u003e true,\n    'set_smart_dashes' =\u003e true,\n]));\n```\n\n### In templates\n\n```twig\n{{ title|typography }}\n\n{{ \"Lorem ipsum\"|typography }}\n\n{# Override constructor defaults for one call: #}\n{{ title|typography({ set_smart_dashes: false }) }}\n```\n\nThe filter is `is_safe: html` — its output may contain `\u003csup\u003e`, `\u003cspan class=\"…\"\u003e`,\nand similar markup, and is emitted unescaped.\n\n## Configuration\n\nEvery key in your YAML or array becomes a method call on\n[PHP-Typography's `Settings` class](https://github.com/mundschenk-at/php-typography/blob/main/src/class-settings.php).\nThe library's full `Settings(true)` defaults are applied first; your\nvalues override them.\n\n### Example: Czech (`cs-CZ`) settings\n\n```yaml\n# typography.yml — Czech smart typography\nset_diacritic_language: \"cs\"\n\n# Smart quotes — Czech style „double\" and ‚single'\nset_smart_quotes: TRUE\nset_smart_quotes_primary: \"doubleLow9\"      # „ … \"\nset_smart_quotes_secondary: \"singleLow9\"    # ‚ … '\n\n# Smart dashes — Czech/EU: en-dash with spaces (not US em-dash)\nset_smart_dashes: TRUE\nset_smart_dashes_style: \"international\"\n\n# Smart spacing\nset_single_character_word_spacing: TRUE     # k/s/v/z/o/u/i/a + nbsp — required in CZ\nset_unit_spacing: TRUE                      # \"5 kg\" → \"5\u0026nbsp;kg\"\nset_dewidow: FALSE                          # last-line widow protection — bad for responsive layouts\n\n# Wrapping helpers\nset_hyphenation: FALSE                      # leave to CSS `hyphens: auto` + `lang=\"cs\"`\nset_url_wrap: FALSE\nset_email_wrap: FALSE\n```\n\n## What's not included\n\nThis extension exposes PHP-Typography as **one Twig filter**, `|typography`.\nThere's no `{% typography %}` block tag (despite earlier versions of this\nREADME claiming one — the tag was never implemented in code). To apply\ntypography to a block of HTML, wrap it in an element and apply the filter\nto the rendered string, or define a [Twig macro](https://twig.symfony.com/doc/3.x/tags/macro.html)\nthat encapsulates the pattern you want.\n\n## License\n\nGPL-2.0-or-later, see `LICENSE.txt`.\n\n## Inspiration\n\n- [Twig Extension Symfony Bundle](https://github.com/debach/typography-bundle)\n- [Twig Typography Drupal Module](https://www.drupal.org/project/twig_typography)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisek%2Ftwig-typography","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparisek%2Ftwig-typography","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisek%2Ftwig-typography/lists"}