Skip to content

Commit

Permalink
Added remove markdown formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
namedotget committed Jan 9, 2025
1 parent 54176a8 commit 2adfa1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ui/lib/nance/useProposalJSON.tsx
Original file line number Diff line number Diff line change
@@ -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<any>()
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions ui/lib/utils/strings.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export const bufferToHex = (x: any) => `0x${x.toString('hex')}`

export const removeMarkdownFormatting = (text: string) => {
return text.replace(/[#_*~`]/g, '')
}

0 comments on commit 2adfa1b

Please sign in to comment.