Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@funboxteam/babel-plugin-typograf
Advanced tools
Babel plugin for enhancing text punctuation and readability
Babel plugin for enhancing text punctuation and readability.
Text is the main tool to describe an action in UI. Also there're texts on landing pages, “FAQs”, “About” sections and other common places on modern websites. Frontend developers should remember to always write those texts properly using correct quotes, dashes, spaces, symbols, etc.
This plugin makes it possible to automate enhancing text readability but replacing entities in string during the build stage.
npm install --save-dev @funboxteam/babel-plugin-typograf
Note:
The 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.
Add plugin settings into your Babel config:
{
plugins: [
['@funboxteam/babel-plugin-typograf', {
// Set locales to get correct symbol replacements (such as quotes, dashes, etc.)
locale: ['ru', 'en-US'],
// Symbols to HTML entities convertaion (disabled by default)
htmlEntity: {
type: 'name', // 'name' or 'digit'
onlyInvisible: true, // Set `true` to convert invisible symbols only
},
// Here you can enable additional typograf rules
enableRules: [
'common/nbsp/afterNumber',
],
// Here you can disable Typograf rules that are enabled by default
disableRules: [
'common/punctuation/quote',
],
// Rules settings
ruleSettings: [
['common/nbsp/beforeShortLastWord', 'lengthLastWord', 8],
],
}],
]
}
Use this template literal tag to transform strings:
// Source string
T`Formatted "string". `;
// Typografed string
// Tagged template with tag `T` is converted to a regular template literal
`Formatted “string”.`;
To process text the plugin uses Typograf.
It looks for the templates tagged with T
:
T`"string"`
Then transforms the text inside and converts the expressions into the regular template literals without the tag:
`“string”`
, «
, »
, etc.) to Unicode-symbols conversion.Some rules are enabled by default in Typograf's config.
ru/money/ruble
Transforms руб.
to ₽
.
It's better to use ₽
when necessary to avoid transformation in the places where it isn't expected.
E.g. in the texts where it's important to use руб.
.
Or in the markup where ₽
isn't displayed correctly due to fonts incompatibility.
common/space/delBeforePunctuation
Removes spaces before the punctuation signs.
But there's a bug.
E.g. the phrase “We need a .Net developer” will be transformed into “We need a.Net developer”.
Right now there's no fix for this issue,
but maybe later it will be possible to create a list of exceptions.
common/space/afterPunctuation
Adds space after the punctuation signs.
But sometimes they are added when you don't expect them to see.
E.g. comma sign “,”
will be transformed into comma sign “, ”
,
which will break common/punctuation/quote
and the result will be comma sign “, “
.
2.1.1 (10.06.2021)
Fixed several security vulnerabilities:
Use of a Broken or Risky Cryptographic Algorithm in elliptic. Updated from 6.5.3 to 6.5.4.
Prototype Pollution in y18n. Updated from 3.2.1 to 3.2.2.
Remote Code Execution in handlebars. Updated from 4.7.6 to 4.7.7.
Regular Expression Denial of Service in hosted-git-info. Updated from 2.8.8 to 2.8.9.
Command Injection in lodash. Updated from 4.17.20 to 4.17.21.
Regular Expression Denial of Service in browserslist. Updated from 4.13.0 to 4.16.6.
Regular Expression Denial of Service in ws. Updated from 7.4.5 to 7.4.6.
Regular Expression Denial of Service in glob-parent. Updated from 3.1.0 to 5.1.2. Also led to @babel/cli update from 7.0.0 to 7.14.5.
and others.
FAQs
Babel plugin for enhancing text punctuation and readability
The npm package @funboxteam/babel-plugin-typograf receives a total of 355 weekly downloads. As such, @funboxteam/babel-plugin-typograf popularity was classified as not popular.
We found that @funboxteam/babel-plugin-typograf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.