use describe, apply alejandra
This commit is contained in:
parent
3f16ae203a
commit
819efaddf9
7 changed files with 791 additions and 759 deletions
|
@ -1,12 +1,10 @@
|
|||
let
|
||||
elems = import ./elems.nix;
|
||||
in rec {
|
||||
readMd = md:
|
||||
processMd = md:
|
||||
if builtins.isPath md
|
||||
then processMd (builtins.readFile md)
|
||||
else processMd md;
|
||||
|
||||
processMd = processStr;
|
||||
then processStr (builtins.readFile md)
|
||||
else processStr md;
|
||||
|
||||
recReadMd = root:
|
||||
assert builtins.isPath root;
|
||||
|
@ -32,11 +30,7 @@ in rec {
|
|||
readDir = root: recFixAppendix (recReadMd root);
|
||||
|
||||
mdToPage = md:
|
||||
elems.Doc {} [[(elems.title {} "markdown file")] (readMd md)];
|
||||
|
||||
list = block:
|
||||
matchThen "(- .+\n)*(- .+\n?)"
|
||||
block (m: elems.List (splitList block));
|
||||
elems.Doc {} [[(elems.title {} "markdown file")] (processMd md)];
|
||||
|
||||
splitList = block:
|
||||
map listItem (builtins.filter (s: builtins.isString s && s != "")
|
||||
|
@ -111,15 +105,7 @@ in rec {
|
|||
href = builtins.elemAt m 2;
|
||||
text = builtins.elemAt m 1;
|
||||
in (elems.a href text)))
|
||||
(rule "(.*\n)([^-][^\n]+\n)((- [^\n]+\n)+)(.*)" (
|
||||
l: (elems.ul (basicRule "(.*\n)?- ([^\n]+)\n(.*)" (m:
|
||||
elems.li (basicRule "()\\[(.)](.*)" (check:
|
||||
elems.input {
|
||||
type = "checkbox";
|
||||
checked = check != " ";
|
||||
disabled = true;
|
||||
}) [m])) [(builtins.elemAt l 2)]))
|
||||
))
|
||||
list
|
||||
(basicRule "(.*\n\n)?(.+)\n(.*)?" elems.p)
|
||||
(basicRule "(.*\n\n)?```(.*)```(.*)?" (elems.textarea {readonly = true;}))
|
||||
(basicRule (containsBreak "###### ([^\n]+)") (elems.h6))
|
||||
|
@ -131,6 +117,16 @@ in rec {
|
|||
(basicRule (containsBreak "<(${linkmatcher})>") (m: elems.a m m))
|
||||
];
|
||||
|
||||
list = rule "(.*\n)([^-][^\n]+\n)((- [^\n]+\n)+)(.*)" (
|
||||
l: (elems.ul (basicRule "(.*\n)?- ([^\n]+)\n(.*)" (m:
|
||||
elems.li (basicRule "()\\[(.)](.*)" (check:
|
||||
elems.input {
|
||||
type = "checkbox";
|
||||
checked = check != " ";
|
||||
disabled = true;
|
||||
}) [m])) [(builtins.elemAt l 2)]))
|
||||
);
|
||||
|
||||
linkmatcher = "[-[:alnum:].%?&#=:/]+";
|
||||
contains = matcher: "(.*)?${matcher}(.*)";
|
||||
wrap = matcher: contains "${matcher}([^${matcher}]+)${matcher}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue