UNPKG

md-curcuma

Version:

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

39 lines (38 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MD_Math_Inline_Task = void 0; const MD_Template_1 = require("./helpers/MD_Template"); const MD_Observable_Abstract_TaskBase_1 = require("./MD_Observable_Abstract_TaskBase"); class MD_Math_Inline_Task extends MD_Observable_Abstract_TaskBase_1.MD_Observable_Abstract_TaskBase { constructor(parameter) { super(); this.collection = null; this.counter = 0; this.doCollect = false; this.template_values = { content: "", }; this.parameter = parameter; } perform(dao) { dao = super.perform(dao); return dao; } transform(mdfc, index) { let paragraph = mdfc.body_array[index]; let words_array = paragraph.split(" "); for (let i = 0; i < words_array.length; i++) { let word = words_array[i].trim(); if (word.startsWith(this.parameter.tag_obsidian_prefix) && word.endsWith(this.parameter.tag_obsidian_suffix)) { this.template_values.content = word.substring(this.parameter.tag_obsidian_prefix.length, word.length - this.parameter.tag_obsidian_suffix.length); console.log("found inline formula!", this.template_values.content); const template = new MD_Template_1.MD_Template(this.parameter.replace_template); words_array[i] = template.fill(this.template_values); } } mdfc.body_array[index] = words_array.join(" "); return mdfc; } } exports.MD_Math_Inline_Task = MD_Math_Inline_Task;