# HG changeset patch # User Matthew Wild # Date 1451680988 0 # Node ID 2b62a714b5df7d31d7f7b3a49d5bb5f4270337bd # Parent 1de0ebd8832f2c97cb7524e820bacc6c3b44e5a9 scansion.parser: Read any comments at top of the file as script title (first line) and summary (following lines) diff -r 1de0ebd8832f -r 2b62a714b5df scansion/parser.lua --- a/scansion/parser.lua Fri Jan 01 20:42:03 2016 +0000 +++ b/scansion/parser.lua Fri Jan 01 20:43:08 2016 +0000 @@ -31,16 +31,26 @@ elseif #parsed.actions > 0 and line:sub(1,1) == "\t" then table.insert(parsed.actions[#parsed.actions].extra, line:sub(2)); elseif line:match("^%s*$") or line:match("^#") or line:match("^([/-])%1") then - -- Blank line or comment, save as annotation - if #line == 0 then - if annotation then - annotation.closed = true; + -- Blank line or comment + local in_header = (next(parsed.objects) == nil) and (next(parsed.actions) == nil); + if in_header and #line > 0 then + if line_number == 1 then + parsed.title = line:gsub("^[#-]+%s*", ""); + else + parsed.summary = (parsed.summary and parsed.summary.."\n" or "")..line:gsub("^[#-]+%s*", ""); end else - if (not annotation) or annotation.closed then - annotation = { line }; - else - table.insert(annotation, line); + -- Save as annotation for the following action + if #line == 0 then + if annotation then + annotation.closed = true; + end + elseif annotation or not line:match("^%-+$") then + if (not annotation) or annotation.closed then + annotation = { line }; + else + table.insert(annotation, line); + end end end else