From 2adfa1bb933e7412ae500d90a735b6bd4ab307d3 Mon Sep 17 00:00:00 2001 From: namedotget Date: Thu, 9 Jan 2025 17:05:28 -0600 Subject: [PATCH] Added remove markdown formatting --- ui/lib/nance/useProposalJSON.tsx | 7 ++++--- ui/lib/utils/strings.ts | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/lib/nance/useProposalJSON.tsx b/ui/lib/nance/useProposalJSON.tsx index 1ab1a2e9..a5ff22e1 100644 --- a/ui/lib/nance/useProposalJSON.tsx +++ b/ui/lib/nance/useProposalJSON.tsx @@ -1,5 +1,6 @@ -//jSONify the proposal sections +//JSONify the proposal sections import { useEffect, useState } from 'react' +import { removeMarkdownFormatting } from '../utils/strings' export default function useProposalJSON(proposalMarkdown: string) { const [proposalJSON, setProposalJSON] = useState() @@ -14,8 +15,8 @@ export default function useProposalJSON(proposalMarkdown: string) { sections.forEach((section) => { const [title, ...content] = section.split('\n') // Clean up the title and content - const cleanTitle = title.trim() - const cleanContent = content.join('\n').trim() + const cleanTitle = removeMarkdownFormatting(title.trim()) + const cleanContent = removeMarkdownFormatting(content.join('\n').trim()) if (cleanTitle && cleanContent) { parsedSections[cleanTitle.toLowerCase()] = cleanContent diff --git a/ui/lib/utils/strings.ts b/ui/lib/utils/strings.ts index ec75367a..5234319a 100644 --- a/ui/lib/utils/strings.ts +++ b/ui/lib/utils/strings.ts @@ -1 +1,5 @@ export const bufferToHex = (x: any) => `0x${x.toString('hex')}` + +export const removeMarkdownFormatting = (text: string) => { + return text.replace(/[#_*~`]/g, '') +}