// Created by Samuel Lord (NodeMixaholic/Sparksammy) // Now Maintained by Maxwell (GOrwell1984) // Licensed under Samuel Public License with <3 // Functions for commonly used elements // get element by id function getElementById(el) { return document.getElementById(el) } //Convert markdown to HTML and back function markdownToHTML(markdown) { // Replace headers (h1, h2, h3) with corresponding HTML tags markdown = markdown.replace(/^# (.*$)/gim, '
tag
markdown = markdown.replace(/`(.*?)`/gim, '$1
');
// Replace blockquotes with HTML tag
markdown = markdown.replace(/^\s*> (.*)$/gim, '$1
');
// Replace horizontal rules with HTML
tag
markdown = markdown.replace(/^\s*[-*_]{3,}\s*$/gim, '
');
// Replace line breaks with HTML
tag
markdown = markdown.replace(/\n$/gim, '
');
// Replace images with HTML tag
markdown = markdown.replace(/!\[(.*?)\]\((.*?)\)/gim, '');
// Replace links with HTML tag
markdown = markdown.replace(/\[(.*?)\]\((.*?)\)/gim, '$1');
markdown = markdown.replaceAll("", "")
markdown = markdown.replaceAll("
", "")
return markdown;
}
function htmlToMarkdown(html) {
// Replace headers (h1, h2, h3) with corresponding Markdown tags
html = html.replace(/(.*?)<\/h1>/gim, '# $1');
html = html.replace(/(.*?)<\/h2>/gim, '## $1');
html = html.replace(/(.*?)<\/h3>/gim, '### $1');
// Replace bold and italic text with corresponding Markdown tags
html = html.replace(/(.*?)<\/b>/gim, '**$1**');
html = html.replace(/(.*?)<\/i>/gim, '*$1*');
// Replace unordered list items with Markdown list tags
html = html.replace(/