From 565d4add81c5db9a969ce82c5a65a1613abb13eb Mon Sep 17 00:00:00 2001 From: murat Date: Tue, 16 Jun 2026 19:26:14 +0300 Subject: [PATCH] feat(styling): ul and ol lists --- luago.lua | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/luago.lua b/luago.lua index 5821f44..8fb27c2 100644 --- a/luago.lua +++ b/luago.lua @@ -124,6 +124,42 @@ for index, value in ipairs(markdownFiles) do local content = indexFile -- STYLING + local function styleLists(s) + local lines = {} + for line in (s .. "\n"):gmatch("([^\n]*)\n") do + table.insert(lines, line) + end + + local result = {} + local inUl = false + local inOl = false + + for _, line in ipairs(lines) do + local ulItem = line:match("^[%-%*%+]%s+(.*)") + local olItem = line:match("^%d+%.%s+(.*)") + + if ulItem then + if inOl then table.insert(result, ""); inOl = false end + if not inUl then table.insert(result, ""); inUl = false end + if not inOl then table.insert(result, "
    "); inOl = true end + table.insert(result, "
  1. " .. olItem .. "
  2. ") + + else + if inUl then table.insert(result, ""); inUl = false end + if inOl then table.insert(result, "
"); inOl = false end + table.insert(result, line) + end + end + + if inUl then table.insert(result, "") end + if inOl then table.insert(result, "") end + + return table.concat(result, "\n") + end local function styling(s) -- blockquote local lines = {} @@ -131,7 +167,9 @@ for index, value in ipairs(markdownFiles) do local nline = line:gsub("^>%s*(.*)", "
%1
") table.insert(lines, nline) end - s = table.concat(lines) + s = table.concat(lines, "\n") + -- lists + s = styleLists(s) -- line breaks s = s:gsub("\r?\n", "
") -- headers @@ -155,7 +193,6 @@ for index, value in ipairs(markdownFiles) do s = s:gsub("`(.-)`", "%1") -- horizontal rule s = s:gsub("%-%-%-", "
") - -- TODO: ordered and unordered lists -- TODO: p for normal text return s