yarle-evernote-to-md
Version:
Yet Another Rope Ladder from Evernote
42 lines • 1.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StandardMD = void 0;
const lodash_1 = require("lodash");
const utils_1 = require("./../utils");
class StandardMD {
constructor() {
this.languageItems = {
bold: '**',
italic: '_',
highlight: '`',
strikethrough: '~~',
listItem: '* '
};
this.codeBlock = '\n```\n';
this.postProcess = async (options, outputNotebookFolders) => { };
this.noteExtension = '.md';
this.noteProcess = (options, noteData, note) => {
(0, utils_1.saveMdFile)(fixImagesInLink(noteData.appliedMarkdownContent), noteData, note);
};
this.tagProcess = (content, tasks, currentTaskPlaceholder, updatedContent) => {
return updatedContent;
};
}
}
exports.StandardMD = StandardMD;
const fixImagesInLink = (content) => {
let updatedContent = (0, lodash_1.cloneDeep)(content);
// Regular expression for the whole string with two groups
const patternWholeString = /\[!\[\[(.*?)(?:\|(.*?))?\]\]\]\((.*?)\)/g;
let match;
while ((match = patternWholeString.exec(content)) !== null) {
const bracketContent = match[1];
const dimensions = match[2] || ''; // Use empty string if dimensions are not present
const parenthesesContent = match[3];
updatedContent = (dimensions === "")
? updatedContent.replace(`[![[${bracketContent}]]](${parenthesesContent})`, ``)
: updatedContent.replace(`[![[${bracketContent}|${dimensions}]]](${parenthesesContent})`, ``);
}
return updatedContent;
};
//# sourceMappingURL=StandardMD.js.map