Enable reader mode

Various fixes to enable reader mode on most platforms. I tested on
firefox, google chrome, and microsoft edge, I don't have an iphone, so
let me know if it's still broken.
This commit is contained in:
Robin Malley 2020-05-19 20:13:30 -04:00
parent 2e735282ec
commit 03d4779129
3 changed files with 24 additions and 22 deletions

View File

@ -70,7 +70,7 @@ local grammar = P{
marked = V"spoiler" + V"bold" + V"italic" + V"underline" + V"heading" + V"strike" + V"spoiler2" + V"code",
plainline = (V"marked" + word)^0,
line = Cs(V"greentext" + V"pinktext" + V"plainline" + P"") * P"\n" / function(a)
return string.format("%s<br/>",a)
return string.format("<p>%s",a)
end,
ending = C(P(1)^0) / sanitize,
chunk = V"line"^0 * V"plainline" * V"ending"

View File

@ -6,7 +6,7 @@ local escapes = {
['"'] = "&quot;",
["'"] = "&#39;",
--Kinda hacky
["\n"] = "<br/>",
["\n"] = "<p>",
}
local esctbl = {}
for char,_ in pairs(escapes) do
@ -18,5 +18,7 @@ local function sanitize(capture)
return escapes[capture] or capture
end
return function(text)
return string.gsub(text,escapematch,sanitize)
text = string.gsub(text,escapematch,sanitize)
--text = string.gsub(text,"\n\n","<p>")
return text
end

View File

@ -2,33 +2,33 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title><%= title %></title>
<meta name="author" content="<%= author %>">
<title><%- title %></title>
<link href="/_css/milligram.css" rel="stylesheet">
<link href="/_css/style.css" rel="stylesheet">
</head>
<body class="container">
<main class="wrapper">
<h1>
<a href="https://<%= domain %>"><%= domain %></a>/<a href="https://<%= domain %>/<%= idp %>"><%= idp %></a>
</h1>
<% if owner then %>
<form action="https://<%= domain %>/_edit" method="get"><fieldset>
<input type="hidden" name="story" value="<%= idp %>"/>
<input type="submit" value="edit" class="button"/>
</fieldset></form>
<% end %>
<h1 class="title">
<body><main class="wrapper">
<nav>
<a href="https://<%= domain %>"><%= domain %></a>/<a href="https://<%= domain %>/<%= idp %>"><%= idp %></a>
</nav>
<% if owner then %>
<form action="https://<%= domain %>/_edit" method="get"><fieldset>
<input type="hidden" name="story" value="<%= idp %>"/>
<input type="submit" value="edit" class="button"/>
</fieldset></form>
<% end %>
<h2 class="title">
<%- title %>
</h1>
</h2>
<h3>
<% if isanon then %>
By Anonymous
<% else %>
By <a href="https://<%= author %>.<%= domain %>"><%= author %></a>
<% end %>
<article class="container content">
<%- text %>
</article>
</main>
</body>
</h3>
<%- text %>
</article>
</main></body>
</html>