Mercurial Hosting > chat
changeset 122:1ae3613dd090
markdown work
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Wed, 10 Dec 2025 20:30:42 -0700 |
| parents | b96d598aa7d1 |
| children | 50f611bbfa19 |
| files | src/chat.css src/chat.js |
| diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/chat.css Fri Dec 05 11:29:31 2025 -0700 +++ b/src/chat.css Wed Dec 10 20:30:42 2025 -0700 @@ -60,9 +60,11 @@ overflow-y: auto; } -div[post] { - margin-top: 16px; - margin-bottom: 16px; +div[post] p, +div[post] pre, +div[input] p, +div[input] pre { + margin: 0; } div[intro] { @@ -146,6 +148,7 @@ div[quote] { border-left: 1px solid #888888; padding-left: 8px; + margin-bottom: 8px; } div[reply] a[when], div[quote] [when], @@ -237,6 +240,15 @@ color: red; } +code { + background-color: #EEE; + padding: 2px; +} +pre > code { + display: block; + white-space: pre-wrap; +} + @media (min-width: 700px) { div[chat_content] { margin-left: calc(3% - 8px);
--- a/src/chat.js Fri Dec 05 11:29:31 2025 -0700 +++ b/src/chat.js Wed Dec 10 20:30:42 2025 -0700 @@ -92,10 +92,10 @@ whenSpan.textContent = new Date(Number(whenSpan.textContent)).toLocaleString([],{dateStyle:'short',timeStyle:'short'}); } let textDiv = div.querySelector('div[text]'); - textDiv.innerHTML = handleMarkdown(textDiv.innerHTML); + textDiv.innerHTML = handleMarkdown(textDiv.textContent); let reply = div.querySelector('blockquote'); if( reply ) - reply.innerHTML = handleMarkdown(reply.innerHTML); + reply.innerHTML = handleMarkdown(reply.textContent); let html; if( div.getAttribute('author') === userId ) { html = document.querySelector('div[hidden] span[pulldown=author]').innerHTML; @@ -256,7 +256,7 @@ let urlRegex = /(<a href="https?:\/\/[^" ]+")>/g; function handleMarkdown(text) { - text = converter.renderInline(text); + text = converter.render(text); text = text.replace( filebinUrlRegex, '>$1<' ); text = text.replace( urlRegex, '$1 target="_blank">' ); return text;
