Fix pages.meet post html formatting

This commit is contained in:
Niko 2022-02-21 22:06:15 +01:00
parent 4bb004f675
commit b50bd5621a
3 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@ var env = {
dev: '<?php echo DEV ?>' === '<?php echo env() ?>',
};
var app = {
domain: '<?php echo getenv('DOMAIN') ?>',
strings: JSON.parse(atob('<?php echo base64_encode(json_encode(strings())) ?>')),
pages: {},
hashHandlers: [],

View File

@ -149,6 +149,7 @@ app.post = {
},
prepare4html: function(value, tags) {
tags = tags || [];
value = text2html(value);
value = value.replaceAll('</a>', '</a> ')
.replaceAll(/\s+/g, ' ');
value = value.replaceAll('</p>', '{:br:}{:br:}');
@ -166,6 +167,8 @@ app.post = {
continue;
acct = acct.trim().substr(1);
href = href.trim();
if (acct.endsWith(`@${app.domain}`))
acct = acct.replace(`@${app.domain}`, '');
const ps = acct.split('@');
const link = '<a class="mention" href="'+htmlescape(href)+'">@'+
htmlescape(acct) + '</a>';

View File

@ -105,6 +105,11 @@ function isVisible(element) {
);
}
function text2html(text) {
return text.replaceAll('&gt;','>').replaceAll('&lt;','<')
.replaceAll('&quot;', '"').replaceAll('&amp;', '&');
}
function html2text(html) {
if (html === undefined || html === null)
return undefined;