mirror of
https://github.com/He4eT/oddsquat.git
synced 2026-05-04 20:37:22 +00:00
typograf: move to tools
This commit is contained in:
parent
64bbb667e4
commit
b7ceb5cfa5
1 changed files with 0 additions and 0 deletions
39
tools/typograf.js
Normal file
39
tools/typograf.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const Typograf = require('typograf')
|
||||
const fs = require('fs')
|
||||
|
||||
if (!process.argv[2]) {
|
||||
console.log('Usage:\n node typograf file [locale]')
|
||||
return
|
||||
}
|
||||
|
||||
const filePath =
|
||||
`${process.cwd()}/${process.argv[2]}`
|
||||
|
||||
const fileContent =
|
||||
fs.readFileSync(filePath).toString()
|
||||
|
||||
const locale =
|
||||
process.argv[3] || 'en-US'
|
||||
|
||||
const tp = new Typograf({
|
||||
locale: [locale, 'en-US'],
|
||||
htmlEntity: {
|
||||
type: 'name',
|
||||
onlyInvisible: true
|
||||
}
|
||||
})
|
||||
|
||||
tp.disableRule('*');[
|
||||
'common/punctuation/quote',
|
||||
'common/nbsp/*',
|
||||
'ru/nbsp/*',
|
||||
'ru/dash/main'
|
||||
].forEach(rule =>
|
||||
tp.enableRule(rule))
|
||||
|
||||
void fs.writeFile(
|
||||
filePath,
|
||||
tp.execute(fileContent),
|
||||
err => err
|
||||
? console.error(err)
|
||||
: console.log(`Typografed: ${filePath}`))
|
||||
Loading…
Add table
Add a link
Reference in a new issue