mirror of https://github.com/lukechilds/node.git
Browse Source
This commit introduces the Documentation YAML metadata concept to the documentation. - Parses added or Added for HTML - Parses all data for JSON Ref: https://github.com/nodejs/node/pull/3867 Ref: https://github.com/nodejs/node/issues/3713 Ref: https://github.com/nodejs/node/issues/6470 PR-URL: https://github.com/nodejs/node/pull/6495 Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>v6.x
Tristian Flanagan
9 years ago
committed by
Evan Lucas
6 changed files with 95 additions and 12 deletions
@ -0,0 +1,21 @@ |
|||
'use strict'; |
|||
|
|||
const yaml = require('js-yaml'); |
|||
|
|||
function isYAMLBlock(text) { |
|||
return !!text.match(/^<!-- YAML/); |
|||
} |
|||
|
|||
exports.isYAMLBlock = isYAMLBlock; |
|||
|
|||
function extractAndParseYAML(text) { |
|||
text = text.trim(); |
|||
|
|||
text = text.replace(/^<!-- YAML/, '') |
|||
.replace(/-->$/, ''); |
|||
|
|||
// js-yaml.safeLoad() throws on error
|
|||
return yaml.safeLoad(text); |
|||
} |
|||
|
|||
exports.extractAndParseYAML = extractAndParseYAML; |
Loading…
Reference in new issue