if no preamble, print module pathname as headline

this was supposed to work already but was broken
This commit is contained in:
Daniel Barlow 2023-08-12 20:49:16 +01:00
parent f93c03c98a
commit d7785d9d75

View file

@ -3,10 +3,9 @@
(local { : view } (require :fennel))
(fn headline [name]
(let [(_ _ basename) (string.find name ".*/([^/].*)")
(let [(_ _ basename) (string.find name ".*/([^/].*).nix")
len (basename:len)]
(print basename)
(print (string.rep "=" len))))
(.. basename "\n" (string.rep "=" len))))
(fn read-preamble [pathname]
(if (= (pathname:sub 1 1) "/")
@ -14,10 +13,10 @@
pathname
(.. pathname "/default.nix"))]
(with-open [f (assert (io.open pathname :r))]
(accumulate [lines ""
(accumulate [lines nil
l (f:lines)
:until (not (= (string.sub l 1 2) "##"))]
(.. lines (string.gsub l "^## *" "") "\n"))))))
(.. (or lines "") (string.gsub l "^## *" "") "\n"))))))
(fn strip-newlines [text]
(-> text