UNPKG

gray-matter

Version:

A simple to use YAML, JSON or Coffee Front-Matter parsing and extraction library, with options to set custom delimiters.

25 lines (20 loc) 476 B
/** * Gray Matter * Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. * Licensed under the MIT license. */ 'use strict'; var _ = require('lodash'); /** * Export utils */ var utils = module.exports = {}; // Detect the language after the first delim utils.detectLang = function (delim, content) { var re = new RegExp('^(?:' + delim + ')\s*(.+)\n'); try { return content.match(re)[1].replace(/^\s+/, ''); } catch(e) { return 'yaml'; } };