mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
015f4fda0e
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>
22 lines
414 B
JavaScript
22 lines
414 B
JavaScript
'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;
|