Prepare texts with Typograf using Gulp.
npm install gulp-typograf --save-dev
const typograf = require('gulp-typograf');
gulp.task('typograf', function() {
gulp.src('./src/*.html')
.pipe(typograf({ locale: ['ru', 'en-US'] }))
.pipe(gulp.dest('./public/'));
});
.pipe(typograf({
locale: ['ru', 'en-US'],
// Type of HTML entities: 'digit' -  , 'name' - , 'default' - UTF-8
htmlEntity: { type: 'digit' },
disableRule: ['ru/optalign/*'],
enableRule: ['ru/money/ruble'],
safeTags: [
['<\\?php', '\\?>'],
['<no-typography>', '</no-typography>']
],
// Own rules
rules: [
{
name: 'common/other/typographicalEmoticon',
handler: function(text, settings) {
return text.replace(/:-\)/, ':—)');
},
{
name: 'common/other/trimLeft'
handler: function(text, settings) {
return text.trimLeft();
}
}
]
}))