let md = import ../nixite/md.nix; elems = import ../nixite/elems.nix; it = import ./it.nix; in with md; [ (it "gets md heading" { actual = mdBlock "# title of the page"; expected = elems.h1 "title of the page"; }) (it "gets md heading 2" { actual = mdBlock "## a subheading"; expected = elems.h2 "a subheading"; }) (it "limits to 6 #" { actual = mdBlock "######## super ultra tiny heading"; expected = elems.h6 "super ultra tiny heading"; }) (it "makes a code block" (let code = '' this is my code ''; in { actual = mdBlock "```${code}```"; expected = elems.code code; })) (it "matches a list of one element" ({ actual = list '' - something ''; expected = { matched = true; block = elems.List ['' something '']; }; })) (it "matches a list of many elements" ({ actual = list '' - something - something else ''; expected = { matched = true; block = elems.List [ '' something '' '' something else '' ]; }; })) (it "matches a list with no whitespace around" ({ actual = list '' - something - something else''; expected = { matched = true; block = elems.List [ '' something '' "something else" ]; }; })) (it "doesnt match not a list" (let str = "blah blah"; in { actual = list str; expected = { matched = false; block = str; }; })) (it "makes a list" ({ actual = mdBlock '' - something ''; expected = elems.List ['' something '']; })) (it "finds surrounded parts" ({ actual = replace (wrap "\\*\\*") elems.strong '' this text **may** contain **bold** words inside it. ''; expected = [ "this text" (elems.strong "may") "contain" (elems.strong "bold") '' words inside it. '' ]; asString = true; })) (it "surrounds in list of elems" ({ actual = rule (wrap "\\*") elems.em [ "this text" (elems.strong "may") "*or may not* contain" (elems.strong "bold") "words *inside* it." ]; expected = [ "this text" (elems.strong "may") (elems.em "or may not") "contain" (elems.strong "bold") "words" (elems.em "inside") "it." ]; asString = true; })) (it "processes whole string with all rules" ({ actual = processStr '' this text **may** *or may not* contain **bold** words *inside* it. ''; expected = [ "this text" (elems.strong "may") (elems.em "or may not") "contain" (elems.strong "bold") "words" (elems.em "inside") '' it. '' ]; asString = true; })) (it "processes md block" { actual = readMd '' # foo bar lorem ipsum ''; expected = [ (elems.h1 { } "foo bar") "" (elems.p { } '' lorem ipsum '') ]; asString = true; }) (it "can fix file appendixes" { actual = fixAppendix "index.md"; expected = "index.html"; }) (it "converts markdown to a page" { actual = toString (mdToPage ./blog/index.md) + "\n"; expected = builtins.readFile ./out/index.html; asString = true; }) (it "recursively reads dir" { actual = recReadMd ./blog; expected = { "index.md" = mdToPage ./blog/index.md; "dir" = { "index.md" = mdToPage ./blog/dir/index.md; }; }; asJSON = true; }) (it "recursively fixes filename" { actual = recFixAppendix { "index.md" = "something"; dir = { "index.md" = "something else"; }; }; expected = { "index.html" = "something"; dir = { "index.html" = "something else"; }; }; }) (it "recursively translates md to html" { actual = builtins.toJSON (readDir ./blog); expected = builtins.toJSON { "index.html" = mdToPage ./blog/index.md; "dir" = { "index.html" = mdToPage ./blog/dir/index.md; }; }; }) ]