UNPKG

md-curcuma

Version:

A Typescript library for transporting and converting markdown and other data.

29 lines (28 loc) 955 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MD_FileContent = void 0; var fm = require("front-matter"); const yaml_1 = require("yaml"); class MD_FileContent { constructor() { this.frontmatter = ""; this.frontmatter_attributes = ""; this.body_array = []; this.index = 0; } static split_frontmatter_body(content) { const fm_content = fm(content); const file_content = { frontmatter: fm_content.frontmatter, frontmatter_attributes: fm_content.attributes, body_array: fm_content.body.split("\n"), index: 0, }; return file_content; } static merge_frontmatter_body(mdfc) { mdfc.frontmatter = (0, yaml_1.stringify)(mdfc.frontmatter_attributes); return ("---\n" + mdfc.frontmatter + "\n---\n\n" + mdfc.body_array.join("\n")); } } exports.MD_FileContent = MD_FileContent;