if no preamble, print module pathname as headline
this was supposed to work already but was broken
This commit is contained in:
parent
f93c03c98a
commit
d7785d9d75
1 changed files with 4 additions and 5 deletions
|
@ -3,10 +3,9 @@
|
||||||
(local { : view } (require :fennel))
|
(local { : view } (require :fennel))
|
||||||
|
|
||||||
(fn headline [name]
|
(fn headline [name]
|
||||||
(let [(_ _ basename) (string.find name ".*/([^/].*)")
|
(let [(_ _ basename) (string.find name ".*/([^/].*).nix")
|
||||||
len (basename:len)]
|
len (basename:len)]
|
||||||
(print basename)
|
(.. basename "\n" (string.rep "=" len))))
|
||||||
(print (string.rep "=" len))))
|
|
||||||
|
|
||||||
(fn read-preamble [pathname]
|
(fn read-preamble [pathname]
|
||||||
(if (= (pathname:sub 1 1) "/")
|
(if (= (pathname:sub 1 1) "/")
|
||||||
|
@ -14,10 +13,10 @@
|
||||||
pathname
|
pathname
|
||||||
(.. pathname "/default.nix"))]
|
(.. pathname "/default.nix"))]
|
||||||
(with-open [f (assert (io.open pathname :r))]
|
(with-open [f (assert (io.open pathname :r))]
|
||||||
(accumulate [lines ""
|
(accumulate [lines nil
|
||||||
l (f:lines)
|
l (f:lines)
|
||||||
:until (not (= (string.sub l 1 2) "##"))]
|
:until (not (= (string.sub l 1 2) "##"))]
|
||||||
(.. lines (string.gsub l "^## *" "") "\n"))))))
|
(.. (or lines "") (string.gsub l "^## *" "") "\n"))))))
|
||||||
|
|
||||||
(fn strip-newlines [text]
|
(fn strip-newlines [text]
|
||||||
(-> text
|
(-> text
|
||||||
|
|
Loading…
Reference in a new issue