From c7d53a2512e7e4f44bef3aaa7fcb99063f10a133 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 8 May 2018 03:21:25 +0100 Subject: [PATCH] lib/lua/nb.lua --- lib/lua/nb.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index 9cd81375..51b604c4 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -34,9 +34,13 @@ function nb:ngx_location_md(fheader,ffooter) local content = self:readall(file) local vars = {} - -- Extract title from content or filename or dirname + -- Extract title from h1 vars.title = string.match(content,'^#[\t ]*([^\r\n]+)') + if not vars.title then + -- Extract title from h2 + vars.title = string.match(content,'##[\t ]*([^\r\n]+)') + end -- From filename -- if not vars.title then -- vars.title = string.match(file,'([^/%.]+)%.') -- basename -- 2.47.3