markdown-toc-gen
Version:
Generating and updating table of contents in Markdown files which conform with prettier.
23 lines (22 loc) • 595 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMarkdown = toMarkdown;
/**
* uses string array and create markdown conform string
*
* string.join("\n") is not possible because this method
* adds a leading linebreak to each element with index > 0
*
* @param content - string array with markdown content
* @returns markdown conform string
*/
function toMarkdown(content) {
return content
.map((val, idx) => {
if (idx < content.length - 1) {
return val + '\n';
}
return val;
})
.join('');
}