chains-markdown

0.1.6 • Public • Published

chains-markdown

This grunt task takes a set of markdown files and converts them to HTML. It supports GFM with code highlighting. The code highlighting is done using highlight.js.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with:

npm install grunt-markdown --save-dev

Then add this line to your gruntfile:

grunt.loadNpmTasks('chains-markdown');

Documentation

Creating a markdown task is simple. For the basic functionality add the following config in your gruntfile:

grunt.initConfig({
  markdown: {
    all: {
      files: [
        {
          expand: true,
          src: 'docs/src/*.md',
          dest: 'docs/html/',
          ext: '.html'
        }
      ]
    }
  }
});
 

Here is an example config using all of the options:

grunt.initConfig({
  markdown: {
    all: {
      files: [
        {
          expand: true,
          src: 'docs/src/*.md',
          dest: 'docs/html/',
          ext: '.html'
        }
      ],
      options: {
          gfm: true,
          highlight: manual,
          codeLines: {
            before: '<span>',
            after: '</span>'
          }
      }
    }
  }
});
 

These are the properties that the markdown task accepts:

Note: If you specify multiple files to one dest file, chains-markdown will concat all files and output to the dest file.

Options

Options passed directly to the markdown parser.

  • pedantic: Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
  • gfm: Enable github flavored markdown (enabled by default).
  • sanitize: Sanitize the output. Ignore any HTML that has been input.
  • highlight: A callback to highlight code blocks.
  • tables: Enable GFM tables. This is enabled by default. (Requires the gfm option in order to be enabled).
  • breaks: Enable GFM line breaks. Disabled by default.
  • smartLists: Use smarter list behavior than the original markdown. Disabled by default. May eventually be default with the old behavior moved into pedantic.
  • smartypants: Use "smart" typograhic punctuation for things like quotes and dashes.
  • langPrefix: Set the prefix for code block classes. Defaults to lang-.

Most markdown options are passed as-is to the marked markdown parser. The only option that is processed prior to compiling the markdown is the highlight option. If you specify auto or manual the task will handle highlighting code blocks for you use highlight.js. If you pass a custom function as the highlight option it will be used to highlight the code.

  • auto: Will try to detect the language
  • manual: will pass the language name from markdown to the highlight function
  • codeLines: specify text that should wrap code lines

License

Copyright (c) 2013 WangSai Licensed under the MIT license.

Dependencies (4)

Dev Dependencies (3)

Package Sidebar

Install

npm i chains-markdown

Weekly Downloads

11

Version

0.1.6

License

none

Last publish

Collaborators

  • wangsai