]> git.nbdom.net Git - nb.git/commitdiff
lib/lua/nb.lua
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 02:21:25 +0000 (03:21 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 02:21:25 +0000 (03:21 +0100)
lib/lua/nb.lua

index 9cd81375aa93b72c2d456d122c33c58e3e77477e..51b604c49ca1f455f1c460bb92b6c324818d51db 100644 (file)
@@ -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