diff --git a/data/static/style.css b/data/static/style.css index d0e1e9f..1d830bc 100644 --- a/data/static/style.css +++ b/data/static/style.css @@ -435,6 +435,12 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus width: 50%; } +.block-img { + object-fit: contain; + max-width: 400px; + max-height: 400px; +} + .thread-info-container { grid-area: thread-info-container; background-color: #c1ceb1; diff --git a/lib/babycode.lua b/lib/babycode.lua index 0a72104..7f37ddb 100644 --- a/lib/babycode.lua +++ b/lib/babycode.lua @@ -96,6 +96,13 @@ function babycode.to_html(s, escape_html) return "
    " .. get_list_items(list_body, escape_html) .. "
" end) + -- images + local images = {} + text = text:gsub("%[img=(.-)%](.-)%[/img%]", function (img, alt) + table.insert(images, {img = img, alt = alt}) + return "\1IMG:"..#images.."\1" + end) + -- normalize newlines, attempt #4 text = text:gsub(" +%s*\r?\n", "
") text = text:gsub("(%S)(\r?\n\r?\n)\r?\n*", "%1

") @@ -131,6 +138,11 @@ function babycode.to_html(s, escape_html) -- rule text = text:gsub("\n+%-%-%-", "
") + --
%2
+ text = text:gsub("\1IMG:(%d+)\1", function (n) + local img = images[tonumber(n)] + return ("
\"%s\"
"):format(img.img, img.alt) + end) -- replace code block placeholders back with their original contents text = text:gsub("\1CODE:(%d+)\1", function(n) local code = code_blocks[tonumber(n)] diff --git a/sass/style.scss b/sass/style.scss index e6b0fde..ad7d281 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -447,6 +447,12 @@ input[type="text"], input[type="password"], textarea, select { width: 50%; } +.block-img { + object-fit: contain; + max-width: 400px; + max-height: 400px; +} + .thread-info-container { grid-area: thread-info-container; background-color: $accent_color; diff --git a/views/common/bbcode_help.etlua b/views/common/bbcode_help.etlua index d43a1df..20dce0a 100644 --- a/views/common/bbcode_help.etlua +++ b/views/common/bbcode_help.etlua @@ -5,6 +5,7 @@
  • [b]bold[/b]
  • [i]italic[/i]
  • [s]strikethrough[/s]
  • +
  • [img=https://example.com/some-image]alt text[/img] creates an image
  • [url=https://example.com]labeled URL[/url]
  • [ul] and [ol] are unordered and ordered lists: