refacto and never use escape method

This commit is contained in:
Julien Calixte
2023-07-02 12:29:54 +02:00
parent 300d62db59
commit 492eb5ed3b
4 changed files with 19 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ import markdownItCheckbox from 'markdown-it-checkbox'
import markdownItSvgCodeCopy from 'markdown-it-svg-code-copy'
import markdownItFootnote from 'markdown-it-footnote'
import { html5Media } from '@/utils/markdown/markdown-html5-media'
import { decodeBase64ToUTF8 } from '@/utils/decodeBase64ToUTF8'
const md = new MarkdownIt({
typographer: true,
@@ -38,10 +39,10 @@ const md = new MarkdownIt({
export const useMarkdown = (defaultPrefix?: string) => {
return {
renderString: (content: string) => (content ? md.render(content) : ''),
toHTML: (content: string) => (content ? md.render(content) : ''),
render: (content: string, prefix?: string) =>
content
? md.render(decodeURIComponent(escape(atob(content))), {
? md.render(decodeBase64ToUTF8(content), {
docId: defaultPrefix ?? prefix ?? ''
})
: ''