diff --git a/client/lib/render-markdown.tsx b/client/lib/render-markdown.tsx
index e3c30843..7919c5c2 100644
--- a/client/lib/render-markdown.tsx
+++ b/client/lib/render-markdown.tsx
@@ -8,21 +8,56 @@ delete defaultProps.theme
const renderer = new marked.Renderer()
-// renderer.heading = (text, level, _, slugger) => {
-// const id = slugger.slug(text)
-// const Component = `h${level}`
+const convertHtmlEntities = (str: string) => {
+ const quot = '"'
+ const apos = '''
+ const amp = '&'
+ const nbsp = ' '
+ const lt = '<'
+ const gt = '>'
+ const code = ''
+ const endCode = '
'
+ const combinedRegex = new RegExp(`${code}|${endCode}|${quot}|${apos}|${amp}|${nbsp}|${lt}|${gt}`, 'g')
-// return renderToStaticMarkup(
-// //@ts-ignore
-//
-//
-// {text}
-//
-//
-// )
-// }
+ return str.replace(combinedRegex, (match) => {
+ switch (match) {
+ case quot:
+ return '"'
+ case apos:
+ return "'"
+ case amp:
+ return '&'
+ case nbsp:
+ return ' '
+ case lt:
+ return '<'
+ case gt:
+ return '>'
+ case code:
+ case endCode:
+ return '`'
+ default:
+ return match
+ }
+ })
+}
+
+renderer.heading = (text, level, _, slugger) => {
+ const id = slugger.slug(text)
+ const Component = `h${level}`
+
+
+
+ return renderToStaticMarkup(
+ //@ts-ignore
+
+
+ {convertHtmlEntities(text)}
+
+
+ )
+}
-// TODO: support elements inside link
// renderer.link = (href, _, text) => {
// const isHrefLocal = href?.startsWith('/') || href?.startsWith('#')
// if (isHrefLocal) {
@@ -32,9 +67,13 @@ const renderer = new marked.Renderer()
//
// )
// }
-// return `${text}`
+
+// // dirty hack
+// // if text contains elements, render as html
+// return `${convertHtmlEntities(text)}`
// }
+
renderer.image = function (href, _, text) {
return ``
}
diff --git a/server/src/lib/render-markdown.tsx b/server/src/lib/render-markdown.tsx
index e3c30843..7919c5c2 100644
--- a/server/src/lib/render-markdown.tsx
+++ b/server/src/lib/render-markdown.tsx
@@ -8,21 +8,56 @@ delete defaultProps.theme
const renderer = new marked.Renderer()
-// renderer.heading = (text, level, _, slugger) => {
-// const id = slugger.slug(text)
-// const Component = `h${level}`
+const convertHtmlEntities = (str: string) => {
+ const quot = '"'
+ const apos = '''
+ const amp = '&'
+ const nbsp = ' '
+ const lt = '<'
+ const gt = '>'
+ const code = ''
+ const endCode = '
'
+ const combinedRegex = new RegExp(`${code}|${endCode}|${quot}|${apos}|${amp}|${nbsp}|${lt}|${gt}`, 'g')
-// return renderToStaticMarkup(
-// //@ts-ignore
-//
-//
-// {text}
-//
-//
-// )
-// }
+ return str.replace(combinedRegex, (match) => {
+ switch (match) {
+ case quot:
+ return '"'
+ case apos:
+ return "'"
+ case amp:
+ return '&'
+ case nbsp:
+ return ' '
+ case lt:
+ return '<'
+ case gt:
+ return '>'
+ case code:
+ case endCode:
+ return '`'
+ default:
+ return match
+ }
+ })
+}
+
+renderer.heading = (text, level, _, slugger) => {
+ const id = slugger.slug(text)
+ const Component = `h${level}`
+
+
+
+ return renderToStaticMarkup(
+ //@ts-ignore
+
+
+ {convertHtmlEntities(text)}
+
+
+ )
+}
-// TODO: support elements inside link
// renderer.link = (href, _, text) => {
// const isHrefLocal = href?.startsWith('/') || href?.startsWith('#')
// if (isHrefLocal) {
@@ -32,9 +67,13 @@ const renderer = new marked.Renderer()
//
// )
// }
-// return `${text}`
+
+// // dirty hack
+// // if text contains elements, render as html
+// return `${convertHtmlEntities(text)}`
// }
+
renderer.image = function (href, _, text) {
return ``
}