Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

typograf/grunt-typograf

Repository files navigation

grunt-typograf

NPM version NPM downloads Dependency Status devDependency Status Build Status

Prepare texts with Typograf for Grunt.

Install

npm install typograf grunt-typograf --save-dev

Usage

Gruntfile.js

module.exports = function (grunt) {
  grunt.initConfig({
    typograf: {
      compile: {
        options: {
          locale: ['ru', 'en-US']
        },
        files: {
          'hello.txt': ['header.txt', 'footer.txt']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-typograf');
  grunt.registerTask('default', ['typograf']);
};

With additional options

module.exports = function (grunt) {
  grunt.initConfig({
    typograf: {
      compile: {
        options: {
          locale: ['ru', 'en-US'],
          htmlEntity: {
            // Type of HTML entities:
            // 'digit' - &#160,
            // 'name' -  ,
            // 'default' - UTF-8
            type: 'digit'
          },

          disableRule: ['ru/optalign/*'],
          enableRule:  ['ru/money/ruble'],

          // Own rules
          rules: [
            {
              name: 'common/other/typographicalEmoticon',
              handler: (text, settings) => text.replace(/:-\)/, ':—)')
            },
            {
              name: 'common/other/trimLeft',
              handler: (text, settings) => text.trimLeft()
            }
          ]
        },

        files: {
          'hello.txt': ['header.txt', 'footer.txt']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-typograf');
  grunt.registerTask('default', ['typograf']);
};

The MIT License.