diff --git a/src/routes/community/create-post/+page.server.ts b/src/routes/community/create-post/+page.server.ts index c3e79238..61daf99c 100644 --- a/src/routes/community/create-post/+page.server.ts +++ b/src/routes/community/create-post/+page.server.ts @@ -21,53 +21,57 @@ export const config = { } function addClassesToHtml(htmlString) { - // Helper function to add a class to a specific tag + // Helper function to add a class to a specific tag function addClassToTag(tag, className) { - // Add class if the tag doesn't already have a class attribute - const regex = new RegExp(`<${tag}(?![^>]*\\bclass=)([^>]*)>`, 'g'); - htmlString = htmlString.replace(regex, `<${tag} class="${className}"$1>`); - - // Append the new class to tags that already have a class attribute, ensuring no duplicates - const regexWithClass = new RegExp(`(<${tag}[^>]*\\bclass=["'][^"']*)(?!.*\\b${className}\\b)([^"']*)["']`, 'g'); - htmlString = removeDuplicateClasses(htmlString.replace(regexWithClass, `$1 ${className}$2"`)); - } - // Add classes to headings - addClassToTag('h1', 'text-2xl'); - addClassToTag('h2', 'text-xl'); - addClassToTag('h3', 'text-xl'); - addClassToTag('h4', 'text-md'); - addClassToTag('h5', 'text-sm'); - addClassToTag('h6', 'text-xs'); - - // Add classes to anchor tags - addClassToTag('a', 'text-blue-400 hover:text-white underline'); - - // Add classes to ordered lists - addClassToTag('ol', 'list-decimal ml-5 text-sm'); - - // Add classes to unordered lists - addClassToTag('ul', 'list-disc ml-5 text-sm -mt-5'); - - // Add classes to blockquotes and their paragraphs - function addClassToBlockquote() { - // Add class to blockquote - htmlString = htmlString.replace( - ']*)>\s*

\n

]*\\bclass=)([^>]*)>`, 'g'); + htmlString = htmlString.replace(regex, `<${tag} class="${className}"$1>`); + + // Append the new class to tags that already have a class attribute, ensuring no duplicates + const regexWithClass = new RegExp(`(<${tag}[^>]*\\bclass=["'][^"']*)(?!.*\\b${className}\\b)([^"']*)["']`, 'g'); + htmlString = htmlString.replace(regexWithClass, `$1 ${className}$2"`); + } + + // Add classes to headings + addClassToTag('h1', 'text-lg'); + addClassToTag('h2', 'text-lg'); + addClassToTag('h3', 'text-lg'); + addClassToTag('h4', 'text-lg'); + addClassToTag('h5', 'text-lg'); + addClassToTag('h6', 'text-lg'); + + // Add classes to anchor tags + addClassToTag('a', 'text-blue-400 hover:text-white underline'); + + // Add classes to ordered lists + addClassToTag('ol', 'list-decimal ml-10 text-sm'); + + // Add classes to unordered lists + addClassToTag('ul', 'list-disc ml-10 text-sm -mt-5'); + + // Add classes to blockquotes and their paragraphs + function addClassToBlockquote() { + // Add class to blockquote + htmlString = htmlString.replace( + /

]*)>\s*

\n

{ diff --git a/src/routes/notifications/+page.svelte b/src/routes/notifications/+page.svelte index 73cd8ed1..17e1abbb 100644 --- a/src/routes/notifications/+page.svelte +++ b/src/routes/notifications/+page.svelte @@ -4,7 +4,7 @@ import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import { onMount } from 'svelte'; - import {userRegion, screenWidth, numberOfUnreadNotification, scrollToComment } from '$lib/store'; + import {userRegion, numberOfUnreadNotification, scrollToComment } from '$lib/store'; export let data; export let form; @@ -120,7 +120,7 @@ onMount(async () => { -

+

Notifications