typograf: move to tools

This commit is contained in:
He4eT 2021-10-09 17:19:14 +05:00
commit b7ceb5cfa5

View file

@ -1,39 +0,0 @@
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}`))