make it all work
This commit is contained in:
parent
74670edee1
commit
c10587f0c5
16 changed files with 335 additions and 66 deletions
|
@ -1,26 +1,25 @@
|
|||
rec {
|
||||
readMd = path: processMd (builtins.readFile path);
|
||||
processMd = md: {
|
||||
title = "idk";
|
||||
content = toString (map (c:
|
||||
if builtins.typeOf c == "string"
|
||||
then processMdBlock c
|
||||
else null) (builtins.split "\n\n" md));
|
||||
};
|
||||
let
|
||||
elems = import ./elems.nix;
|
||||
in rec {
|
||||
readMd = md:
|
||||
if builtins.isPath md
|
||||
then processMd (builtins.readFile md)
|
||||
else processMd md;
|
||||
processMd = md: (map (c:
|
||||
if builtins.isString c
|
||||
then mdBlock c
|
||||
else "") (builtins.split "\n\n" md));
|
||||
|
||||
processMdBlock = block: p block;
|
||||
mdBlock = block: let
|
||||
m = heading block;
|
||||
h =
|
||||
if m == null
|
||||
then 0
|
||||
else builtins.stringLength (builtins.elemAt m 0);
|
||||
in
|
||||
if m == null
|
||||
then elems.p block
|
||||
else elems.h h (builtins.elemAt m 1);
|
||||
|
||||
isHeading = block: builtins.match "#+ .*" block;
|
||||
|
||||
h = content: ''
|
||||
<h1>
|
||||
${toString content}
|
||||
</h1>
|
||||
'';
|
||||
|
||||
p = content: ''
|
||||
<p>
|
||||
${toString content}
|
||||
</p>
|
||||
'';
|
||||
heading = block: builtins.match "(#+) (.*)" block;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue