Compare commits
11 Commits
33540f028f
...
f125640ace
| Author | SHA1 | Date | |
|---|---|---|---|
| f125640ace | |||
| 96f1eac252 | |||
| 67824a60b4 | |||
| 2b89ff29e2 | |||
| 74fe93a0ca | |||
| 6a294583fa | |||
| 60b91d159e | |||
| dd97b16890 | |||
| b7ae3ca52a | |||
| 4ca73d02ae | |||
| dbe8bcbb44 |
@@ -122,6 +122,39 @@ for index, value in ipairs(markdownFiles) do
|
||||
local htmlFile = io.open(workDir .. "/public/" .. markdownFiles[index].fileName .. ".html", 'w')
|
||||
if htmlFile then
|
||||
local content = indexFile
|
||||
|
||||
-- STYLING
|
||||
local function styling(s)
|
||||
-- blockquote
|
||||
s = s:gsub(">%s*(.-)%s*\r?\n", "<blockquote>%1</blockquote>")
|
||||
-- line breaks
|
||||
s = s:gsub("\r?\n", "<br>")
|
||||
-- headers
|
||||
s = s:gsub("######%s*(.-)%s*<br>", "<h6>%1</h6>")
|
||||
s = s:gsub("#####%s*(.-)%s*<br>", "<h5>%1</h5>")
|
||||
s = s:gsub("####%s*(.-)%s*<br>", "<h4>%1</h4>")
|
||||
s = s:gsub("###%s*(.-)%s*<br>", "<h3>%1</h3>")
|
||||
s = s:gsub("##%s*(.-)%s*<br>", "<h2>%1</h2>")
|
||||
s = s:gsub("#%s*(.-)%s*<br>", "<h1>%1</h1>")
|
||||
-- TODO: h1 and h2 using == and --
|
||||
-- bold and italic text
|
||||
s = s:gsub("%*%*(.-)%*%*", "<b>%1</b>")
|
||||
s = s:gsub("%*(.-)%*", "<i>%1</i>")
|
||||
s = s:gsub("%_%_(.-)%_%_", "<b>%1</b>")
|
||||
s = s:gsub("%_(.-)%_", "<i>%1</i>")
|
||||
-- images
|
||||
s = s:gsub("!%[(.-)%]%((.-)%)", '<img src="%2" alt="%1"></img>')
|
||||
-- links
|
||||
s = s:gsub("%[(.-)%]%((.-)%)", '<a href="%2">%1</a>')
|
||||
-- code
|
||||
s = s:gsub("`(.-)`", "<code>%1</code>")
|
||||
-- horizontal rule
|
||||
s = s:gsub("%-%-%-", "<hr>")
|
||||
|
||||
return s
|
||||
end
|
||||
markdownFiles[index].content = styling(markdownFiles[index].content)
|
||||
|
||||
-- replace <!-- sitecontents --> with markdown file content
|
||||
local start_idx, end_idx = content:find("<!-- sitecontents -->", 1, true)
|
||||
if start_idx and end_idx then
|
||||
|
||||
Reference in New Issue
Block a user