- <%- post.signature_rendered %> -
diff --git a/lib/babycode.lua b/lib/babycode.lua
index 301102b..f76b84c 100644
--- a/lib/babycode.lua
+++ b/lib/babycode.lua
@@ -22,25 +22,27 @@ function babycode.to_html(s, escape_html)
return "\1CODE:"..#code_blocks.."\1"
end
end)
-
+
+ text = text:gsub(" %s?\r?\n", "
")
+ -- normalize newlines
+ text = text:gsub("\r?\n\r?\n+", "
")
+
local url_tags = {}
-- replace `[url=https://example.com]Example[/url] tags
text = text:gsub("%[url=([^%]]+)%](.-)%[/url%]", function(url, label)
table.insert(url_tags, {url = url, label = label})
return "\1URL:"..#url_tags.."\1"
end)
-
- -- replace `[url]https://example.com[/url] tags
- -- text = text:gsub("%[url%]([^%]]+)%[/url%]", function(url)
- -- return ''..url..''
- -- end)
-- bold, italics, strikethrough
text = text:gsub("%[b%](.-)%[/b%]", "%1")
text = text:gsub("%[i%](.-)%[/i%]", "%1")
text = text:gsub("%[s%](.-)%[/s%]", "%1")
- text = text:gsub("%[quote%](.-)%[/quote%]", "
%1") + -- these can be nested, so replace open and closed separately + -- text = text:gsub("%[quote%]", "
") + -- text = text:gsub("%[/quote%]", "") + text = text:gsub("%[(/?)quote%]", "<%1blockquote>") -- replace loose links text = text:gsub("(https?://[%w-_%.%?%.:/%+=&~%@#%%]+[%w-/])", function(url) @@ -57,9 +59,6 @@ function babycode.to_html(s, escape_html) -- rule text = text:gsub("\n+%-%-%-", "