diff --git a/web/js/ui/fmt.js b/web/js/ui/fmt.js index f7ae01f..73f759e 100644 --- a/web/js/ui/fmt.js +++ b/web/js/ui/fmt.js @@ -10,14 +10,13 @@ function linkify(text="", show_media=false) { let markup; if (show_media && is_img_url(parsed.pathname)) { markup = html` - - `; + `; } else if (show_media && is_video_url(parsed.pathname)) { markup = html` - `; + `; } else { markup = html`${url}`; } @@ -32,7 +31,7 @@ function format_content(ev, show_media) { return html`${ev.content.trim()}`; } const content = ev.content.trim(); - const body = convert_quote_blocks(content, show_media) + const body = fmt_body(content, show_media); let cw = get_content_warning(ev.tags) if (cw !== null) { let cwHTML = "Content Warning" @@ -41,18 +40,18 @@ function format_content(ev, show_media) { } else { cwHTML += html`: "${cw}".` } - return html` + return `
${cwHTML} ${body} -
- ` + `; } - return body + return body; } -function convert_quote_blocks(content, show_media) -{ +/* fmt_body will parse images, blockquotes, and sanitize the content. + */ +function fmt_body(content, show_media) { const split = content.split("\n") let blockin = false return split.reduce((str, line) => { @@ -61,13 +60,13 @@ function convert_quote_blocks(content, show_media) str += "" blockin = true } - str += linkify(line.slice(1), show_media) + str += linkify(html`${line.slice(1)}`, show_media) } else { if (blockin) { blockin = false str += "" } - str += linkify(line, show_media) + str += linkify(html`${line}`, show_media) } return str + "
" }, "")