fix formatting

This commit is contained in:
Daniella 2022-01-20 11:38:11 +01:00
parent 84766ccfd5
commit f9fd760ccc
2 changed files with 10 additions and 11 deletions

View file

@ -1,7 +1,7 @@
[
{
"title": "Default post",
"content": "This is the first post, it was here since the beginning.\n\n\n(Remove the space after the '[' and before the ']')\n\n [ * [* text *] * ] [ ** [** text **] ** ] [ *** [*** text ***] *** ] [ _ [_ text _] _ ] [ *_ [*_ text _*] _* ] [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** ] [ \" [\" text \"] \" ]",
"content": "This is the first post, it was here since the beginning.\n\n\n(Remove the space after the '[' and before the ']')\n\n [ * [* text *] * ] [ ** [** text **] ** ] [ *** [*** text ***] *** ] [ _ [_ text _] _ ] [ *_ [*_ text _*] _* ] [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** ] [ \" [\" text \"] \" ]",
"author": "root",
"comments": [
{

View file

@ -106,17 +106,16 @@
ret +=
`<post><div class="content">${date ? (`<h6>${date.toUTCString()}</h6>`) : ''}<h3>${post.author.replaceAll('<','&lt;').replaceAll('>','&gt;')}: ${post.title.replaceAll('<','&lt;').replaceAll('>','&gt;')}</h3>` +
post.content.replaceAll('<','&lt;').replaceAll('>','&gt;')
.replaceAll('[* ', '<i>').replaceAll(' *]', '</i>')
.replaceAll(/(https?:\/\/[^ \n]+)/g, '<a href="$1" target="_blank">$1</a>')
.replaceAll('[** ', '<b>').replaceAll(' **]', '</b>')
.replaceAll('[*** ', '<b><i>').replaceAll(' ***]', '</i></b>')
.replaceAll('[_ ', '<u>').replaceAll(' _]', '</u>')
.replaceAll('[*_ ', '<i><u>').replaceAll(' _*]', '</u></i>')
.replaceAll('[**_ ', '<b><u>').replaceAll(' _**]', '</u></b>')
.replaceAll('[***_ ', '<b><i><u>').replaceAll(' _***]', '</u></i></b>')
.replaceAll('[" ', '<pre class="inline">').replaceAll(' "]', '</pre>')
.replaceAll('["\n', '<pre>').replaceAll('\n"]', '</pre>')
.replaceAll('["" \n', '<pre>').replaceAll('\n ""]', '</pre>')
.replaceAll(/\[[*] ([\w\W]*) [*]\]/g, '<i>$1</i>')
.replaceAll(/\[[*][*] ([\w\W]*) [*][*]\]/g, '<b>$1</b>')
.replaceAll(/\[[*][*][*] ([\w\W]*) [*][*][*]\]/g, '<b><i>$1</i></b>')
.replaceAll(/\[[_] ([\w\W]*) [_]\]/g, '<u>$1</u>')
.replaceAll(/\[[*][_] ([\w\W]*) [_][*]\]/g, '<i><u>$1</u></i>')
.replaceAll(/\[[*][*][_] ([\w\W]*) [_][*][*]\]/g, '<b><u>$1</u></b>')
.replaceAll(/\[[*][*][*][_] ([\w\W]*) [_][*][*][*]\]/g, '<b><i><u>$1</u></i></b>')
.replaceAll(/\[["] ([\w\W]*) ["]\]/g, '<pre class="inline">$1</pre>')
.replaceAll(/\[["]["]* \n([\w\W]*)\n ["]["]*\]/g, '<pre>$1</pre>')
.replaceAll('\n', '<br/>')
ret += '<div class="controls">'
if (postid != -1 || id == '') {