Only parse metadata if starts on first line

Mon, 06 Jul 2020 12:19:21 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 06 Jul 2020 12:19:21 -0500
changeset 23
0ea4b0786b43
parent 22
8c8e70569d81
child 24
4013d2901832

Only parse metadata if starts on first line

handlers/render.lua file | annotate | diff | comparison | revisions
--- a/handlers/render.lua	Mon Jul 06 12:16:04 2020 -0500
+++ b/handlers/render.lua	Mon Jul 06 12:19:21 2020 -0500
@@ -26,7 +26,7 @@
     local meta = {}
     
     for l in f:lines() do
-        if string.match(l, config.meta_marker) then
+        if (linenum==1 or in_meta) and string.match(l, config.meta_marker) then
             in_meta = not in_meta
         elseif in_meta then
             local key, val = string.match(l, "%s*([^:]*)%s*:%s*(.*)%s*")
@@ -36,7 +36,7 @@
                 local val_unq=string.match(val, '^"(.*)"$')
                 meta[key] = val_unq or val
             else
-                err.file_pos(file, linenum, "meta data syntax error")
+                err.file_pos(file, linenum, "meta data syntax error: " .. l)
             end
         else
             if data then

mercurial