tokenize-markdown.js
function tokenizeMarkdownFromFiles( files, filterParams ) {
  /**
   * Read in the provided file and return its contents as markdown tokens
   *
   * @param  {String} file A file path to read in
   * @return {Array}       An array of the individual markdown tokens found
   *                       within the provided list of files
   */
  function readAndTokenize( file ) {
    // Read the file
    var fileContents = grunt.file.read( file );

    // Map file into an object defining the tokens for this file
    return {
      file: file,
      tokens: convertToTokens( fileContents, filterParams )
    };
  }

  // Expand the provided file globs into a list of files, and process each
  // one into an object containing that file's markdown tokens
  return grunt.file.expand( files ).map( readAndTokenize );
}
function tokenizeMarkdownFromFiles( files, filterParams ) {
  /**
   * Read in the provided file and return its contents as markdown tokens
   *
   * @param  {String} file A file path to read in
   * @return {Array}       An array of the individual markdown tokens found
   *                       within the provided list of files
   */
  function readAndTokenize( file ) {
    // Read the file
    var fileContents = grunt.file.read( file );

    // Map file into an object defining the tokens for this file
    return {
      file: file,
      tokens: convertToTokens( fileContents, filterParams )
    };
  }

  // Expand the provided file globs into a list of files, and process each
  // one into an object containing that file's markdown tokens
  return grunt.file.expand( files ).map( readAndTokenize );
}
function tokenizeMarkdownFromFiles ( files , filterParams ) { /**
   * Read in the provided file and return its contents as markdown tokens
   *
   * @param  {String} file A file path to read in
   * @return {Array}       An array of the individual markdown tokens found
   *                       within the provided list of files
   */ function readAndTokenize ( file ) { // Read the file var fileContents = grunt . file . read ( file ) ; // Map file into an object defining the tokens for this file return { file : file , tokens : convertToTokens ( fileContents , filterParams ) } ; } // Expand the provided file globs into a list of files, and process each // one into an object containing that file's markdown tokens return grunt . file . expand ( files ) . map ( readAndTokenize ) ; }
Get an array of markdown tokens per file from an array of files, optionally
filtered to only those tokens matching a particular set of attributes

@example

var tokenizeMarkdown = require( 'tokenize-markdown' );

// Get all tokens
var tokens = tokenizeMarkdown.fromFiles( [ 'slides/*.md' ] );

// Get only tokens of type "code" and lang "javascript"
var jsTokens = tokenizeMarkdown.fromFiles( [ 'slides/*.md' ], {
type: 'code',
lang: 'javascript'
});

// Get tokens of lang "javascript" or "html", using a regex
var jsOrHtmlTokens = tokenizeMarkdown.fromFiles( [ 'slides/*.md' ], {
lang: /(javascript|html)/
});

@method fromFiles
@param  {Array}  files          Array of file sources to expand and process
@param  {Object} [filterParams] Optional hash of properties to use to filter
the returned tokens
@return {Array}                 Array of token objects
Get an array of markdown tokens per file from an array of files optionally filtered to only those tokens matching a particular set of attributes