grunt-typograf

Prepare texts with Typograf using Grunt.

Usage no npm install needed!

<script type="module">
  import gruntTypograf from 'https://cdn.skypack.dev/grunt-typograf';
</script>

README

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' - &nbsp;,
            // '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']);
};

License

The MIT License.