md-curcuma
Version:
A Typescript library for transporting and converting markdown and other data.
50 lines (49 loc) • 1.88 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MD_Math_Paragraph_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_Paragraph_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 item = mdfc.body_array[index];
if (!this.doCollect &&
item.indexOf(this.parameter.tag_obsidian_prefix) >= 0) {
this.doCollect = true;
console.log("#### math: found!");
this.collection = [];
mdfc.body_array.splice(index, 1);
mdfc.index = mdfc.index - 1;
}
else if (this.doCollect) {
if (item.indexOf(this.parameter.tag_obsidian_suffix) >= 0) {
this.doCollect = false;
console.log("#### math: process!");
this.template_values.content = this.collection.join("\n");
const template = new MD_Template_1.MD_Template(this.parameter.replace_template);
mdfc.body_array[index] = template.fill(this.template_values);
}
else {
this.collection.push(item);
mdfc.body_array.splice(index, 1);
mdfc.index = mdfc.index - 1;
console.log("#### math: collect...", this.collection);
}
}
return mdfc;
}
}
exports.MD_Math_Paragraph_Task = MD_Math_Paragraph_Task;