diff --git a/data/static/style.css b/data/static/style.css
index 39286de..5f205f6 100644
--- a/data/static/style.css
+++ b/data/static/style.css
@@ -507,7 +507,7 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus
height: 150px;
}
-ul {
+ul, ol {
margin: 10px 0 10px 30px;
padding: 0;
}
diff --git a/lib/babycode.lua b/lib/babycode.lua
index f76b84c..0a72104 100644
--- a/lib/babycode.lua
+++ b/lib/babycode.lua
@@ -1,16 +1,82 @@
local babycode = {}
+local string_trim = require("lapis.util").trim
+
+local function s_split(s, delimiter, max_matches, trim, allow_empty)
+ local result = {}
+ if s == "" then
+ return result
+ end
+ trim = trim == nil and true or trim
+ local tr = function(subj)
+ if trim then return string_trim(subj) else return subj end
+ end
+ max_matches = max_matches or -1
+ allow_empty = allow_empty == nil and true or allow_empty
+
+ if delimiter == "" then
+ for i=1, #s do
+ local c = s:sub(i, 1)
+ if allow_empty or c ~= "" then
+ table.insert(result, c)
+ if max_matches > 0 and #result == max_matches then
+ break
+ end
+ end
+ end
+ return result
+ end
+
+ local current_pos = 1
+ local delim_len = #delimiter
+
+ while true do
+ if max_matches > 0 and #result >= max_matches then
+ break
+ end
+---@diagnostic disable-next-line: param-type-mismatch
+ local start_pos, end_pos = s:find(delimiter, current_pos, true)
+ if not start_pos then
+ break
+ end
+ local substr = s:sub(current_pos, start_pos - 1)
+ if allow_empty or substr ~= "" then
+ table.insert(result, tr(substr))
+ end
+ current_pos = end_pos + 1
+ end
+
+ local substr = s:sub(current_pos)
+ if allow_empty or substr ~= "" then
+ table.insert(result, tr(substr))
+ end
+
+ return result
+end
+
+local function get_list_items(list_body, escape_html)
+ list_body = list_body:gsub(" +%s*\r?\n", "
")
+ list_body = list_body:gsub("(%S)(\r?\n\r?\n)\r?\n*", "%1\1")
+ local list_items = s_split(list_body, "\1")
+ local lis = ""
+ for _, li in ipairs(list_items) do
+ local rendered = babycode.to_html(li, escape_html)
+ lis = lis .. "
") - -- text = text:gsub("%[/quote%]", "") text = text:gsub("%[(/?)quote%]", "<%1blockquote>") -- replace loose links diff --git a/sass/style.scss b/sass/style.scss index 7a4ee19..fe3255e 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -523,7 +523,7 @@ input[type="text"], input[type="password"], textarea, select { } -ul { +ul, ol { margin: 10px 0 10px 30px; padding: 0; } diff --git a/views/common/bbcode_help.etlua b/views/common/bbcode_help.etlua index e934c67..d43a1df 100644 --- a/views/common/bbcode_help.etlua +++ b/views/common/bbcode_help.etlua @@ -6,6 +6,27 @@
[ul]
+item 1
+
+item 2
+
+item 3
+still item 3 (break line without inserting a new item by using two spaces at the end of a line)
+[/ul]
+