{"id":21301709,"url":"https://github.com/funbox/babel-plugin-typograf","last_synced_at":"2025-07-11T20:31:17.626Z","repository":{"id":42717536,"uuid":"277768553","full_name":"funbox/babel-plugin-typograf","owner":"funbox","description":"Babel plugin for enhancing text punctuation and readability","archived":false,"fork":false,"pushed_at":"2023-07-18T23:12:34.000Z","size":901,"stargazers_count":11,"open_issues_count":2,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-01T19:12:13.154Z","etag":null,"topics":["babel","babel-plugin","typograf","typography"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/funbox.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}},"created_at":"2020-07-07T09:04:31.000Z","updated_at":"2023-04-18T21:45:31.000Z","dependencies_parsed_at":"2023-02-08T12:15:51.607Z","dependency_job_id":null,"html_url":"https://github.com/funbox/babel-plugin-typograf","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/funbox/babel-plugin-typograf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fbabel-plugin-typograf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fbabel-plugin-typograf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fbabel-plugin-typograf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fbabel-plugin-typograf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funbox","download_url":"https://codeload.github.com/funbox/babel-plugin-typograf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fbabel-plugin-typograf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263499191,"owners_count":23476021,"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":["babel","babel-plugin","typograf","typography"],"created_at":"2024-11-21T15:50:28.480Z","updated_at":"2025-07-11T20:31:12.615Z","avatar_url":"https://github.com/funbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @funboxteam/babel-plugin-typograf\n\n[![npm](https://img.shields.io/npm/v/@funboxteam/babel-plugin-typograf.svg)](https://www.npmjs.com/package/@funboxteam/babel-plugin-typograf)\n\nBabel plugin for enhancing text punctuation and readability.\n\n[По-русски](./README.ru.md)\n\n## Rationale\n\nText is the main tool to describe an action in UI. Also there're texts on landing pages,\n“FAQs”, “About” sections and other common places on modern websites. Frontend developers should remember\nto always write those texts properly using correct quotes, dashes, spaces, symbols, etc.\n\nThis plugin makes it possible to automate enhancing text readability but replacing entities in string \nduring the build stage. \n\n## Installation\n\n```bash\nnpm install --save-dev @funboxteam/babel-plugin-typograf\n```\n\n## Configuration \n\n**Note**:\nThe plugin should be placed “above” other plugins that work with template literals (such as `plugin-transform-template-literals`) in `plugins` array, to make it possible to convert tagged templates earlier than process template literals overall.\n\nAdd plugin settings into your Babel config:\n\n```js\n{\n  plugins: [\n    ['@funboxteam/babel-plugin-typograf', {\n      // Set locales to get correct symbol replacements (such as quotes, dashes, etc.)\n      locale: ['ru', 'en-US'],\n\n      // Symbols to HTML entities convertaion (disabled by default)\n      htmlEntity: {\n        type: 'name',        // 'name' or 'digit'\n        onlyInvisible: true, // Set `true` to convert invisible symbols only\n      },\n\n      // Here you can enable additional typograf rules\n      enableRules: [\n        'common/nbsp/afterNumber',\n      ],\n\n      // Here you can disable Typograf rules that are enabled by default\n      disableRules: [\n        'common/punctuation/quote',\n      ],\n\n      // Rules settings\n      ruleSettings: [\n        ['common/nbsp/beforeShortLastWord', 'lengthLastWord', 8],\n      ],\n    }],\n  ]\n}\n```\n\n## Usage\n\nUse this template literal tag to transform strings:\n\n```js\n// Source string\nT`Formatted \"string\".  `;\n\n// Typografed string\n// Tagged template with tag `T` is converted to a regular template literal\n`Formatted “string”.`;\n```\n\n## Typograf\n\nTo process text the plugin uses [Typograf](https://github.com/typograf/typograf). \nIt looks for the templates tagged with `T`:\n\n```\nT`\"string\"`\n```\n\nThen transforms the text inside and converts the expressions into the regular template literals without the tag:\n\n```\n`“string”`\n``` \n\n### Main features of Typograf\n\n* Trailing and double spaces removing.\n* Inserting non-breaking spaces.\n* Quotes conversion.\n* HTML-entities (`\u0026nbsp;`, `\u0026laquo;`, `\u0026raquo;`, etc.) to Unicode-symbols conversion.\n\n### Typograf rules\n\n[Some rules](https://github.com/typograf/typograf/blob/dev/docs/RULES.ru.md) are enabled by default in Typograf's config. \n\n#### Not recommended to turn on\n\n* `ru/money/ruble`  \n  Transforms `руб.` to `₽`. \n  It's better to use `₽` when necessary to avoid transformation in the places where it isn't expected. \n  E.g. in the texts where it's important to use `руб.`. \n  Or in the markup where `₽` isn't displayed correctly due to fonts incompatibility.\n\n* `common/space/delBeforePunctuation`  \n  Removes spaces before the punctuation signs. \n  But there's a bug. \n  E.g. the phrase “We need a .Net developer” will be transformed into “We need a.Net developer”. \n  Right now there's no fix for this issue, \n  but [maybe](https://github.com/typograf/typograf/issues/312) later it will be possible to create a list of exceptions.\n\n* `common/space/afterPunctuation`  \n  Adds space after the punctuation signs. \n  But sometimes they are added when you don't expect them to see. \n  E.g. `comma sign “,”` will be transformed into `comma sign “, ”`, \n  which will break `common/punctuation/quote` and the result will be `comma sign “, “`.\n\n[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fbabel-plugin-typograf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunbox%2Fbabel-plugin-typograf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fbabel-plugin-typograf/lists"}