From f125640acec272598761162fdb5ba2a73e13d5c4 Mon Sep 17 00:00:00 2001 From: murat Date: Tue, 16 Jun 2026 18:37:00 +0300 Subject: [PATCH] chore(styling): cleanup --- luago.lua | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/luago.lua b/luago.lua index be7605e..03880ad 100644 --- a/luago.lua +++ b/luago.lua @@ -124,31 +124,36 @@ for index, value in ipairs(markdownFiles) do local content = indexFile -- STYLING - -- blockquote - markdownFiles[index].content = markdownFiles[index].content:gsub(">%s*(.-)%s*\r?\n", "
%1
") - -- line breaks - markdownFiles[index].content = markdownFiles[index].content:gsub("\r?\n", "
") - -- headers - markdownFiles[index].content = markdownFiles[index].content:gsub("######%s*(.-)%s*
", "
%1
") - markdownFiles[index].content = markdownFiles[index].content:gsub("#####%s*(.-)%s*
", "
%1
") - markdownFiles[index].content = markdownFiles[index].content:gsub("####%s*(.-)%s*
", "

%1

") - markdownFiles[index].content = markdownFiles[index].content:gsub("###%s*(.-)%s*
", "

%1

") - markdownFiles[index].content = markdownFiles[index].content:gsub("##%s*(.-)%s*
", "

%1

") - markdownFiles[index].content = markdownFiles[index].content:gsub("#%s*(.-)%s*
", "

%1

") - -- TODO: h1 and h2 using == and -- - -- bold and italic text - markdownFiles[index].content = markdownFiles[index].content:gsub("%*%*(.-)%*%*", "%1") - markdownFiles[index].content = markdownFiles[index].content:gsub("%*(.-)%*", "%1") - markdownFiles[index].content = markdownFiles[index].content:gsub("%_%_(.-)%_%_", "%1") - markdownFiles[index].content = markdownFiles[index].content:gsub("%_(.-)%_", "%1") - -- images - markdownFiles[index].content = markdownFiles[index].content:gsub("!%[(.-)%]%((.-)%)", '%1') - -- links - markdownFiles[index].content = markdownFiles[index].content:gsub("%[(.-)%]%((.-)%)", '%1') - -- code - markdownFiles[index].content = markdownFiles[index].content:gsub("`(.-)`", "%1") - -- horizontal rule - markdownFiles[index].content = markdownFiles[index].content:gsub("%-%-%-", "
") + local function styling(s) + -- blockquote + s = s:gsub(">%s*(.-)%s*\r?\n", "
%1
") + -- line breaks + s = s:gsub("\r?\n", "
") + -- headers + s = s:gsub("######%s*(.-)%s*
", "
%1
") + s = s:gsub("#####%s*(.-)%s*
", "
%1
") + s = s:gsub("####%s*(.-)%s*
", "

%1

") + s = s:gsub("###%s*(.-)%s*
", "

%1

") + s = s:gsub("##%s*(.-)%s*
", "

%1

") + s = s:gsub("#%s*(.-)%s*
", "

%1

") + -- TODO: h1 and h2 using == and -- + -- bold and italic text + s = s:gsub("%*%*(.-)%*%*", "%1") + s = s:gsub("%*(.-)%*", "%1") + s = s:gsub("%_%_(.-)%_%_", "%1") + s = s:gsub("%_(.-)%_", "%1") + -- images + s = s:gsub("!%[(.-)%]%((.-)%)", '%1') + -- links + s = s:gsub("%[(.-)%]%((.-)%)", '%1') + -- code + s = s:gsub("`(.-)`", "%1") + -- horizontal rule + s = s:gsub("%-%-%-", "
") + + return s + end + markdownFiles[index].content = styling(markdownFiles[index].content) -- replace with markdown file content local start_idx, end_idx = content:find("", 1, true)