From c7aa9f17c9d8c481547b306772a3395c8000b123 Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Tue, 28 May 2024 18:26:22 +0000 Subject: [PATCH] Update frontend.js --- frontend.js | 897 ++++++++++++++++++++++++++-------------------------- 1 file changed, 450 insertions(+), 447 deletions(-) diff --git a/frontend.js b/frontend.js index 30c5dc5..10f6607 100644 --- a/frontend.js +++ b/frontend.js @@ -1,450 +1,453 @@ -// 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(elementID) { - return document.getElementById(elementID) -} - -//Convert markdown to HTML and back -function markdownToHTML(markdown) { - // Replace headers (h1, h2, h3) with corresponding HTML tags - markdown = markdown.replace(/^# (.*$)/gim, '

$1

'); - markdown = markdown.replace(/^## (.*$)/gim, '

$1

'); - markdown = markdown.replace(/^### (.*$)/gim, '

$1

'); - - // Replace bold and italic text with corresponding HTML tags - markdown = markdown.replace(/\*\*(.*)\*\*/gim, '$1'); - markdown = markdown.replace(/\*(.*)\*/gim, '$1'); - - // Replace unordered list items with HTML list tags - markdown = markdown.replace(/\* (.*?)(\n|$)/gim, '
  • $1
  • '); - - // Replace inline code with HTML 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, '$1'); - - // 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(/