This commit is contained in:
tristan 2024-01-02 09:33:56 +00:00
parent 195f8a60ae
commit b1426fb1ca
7 changed files with 28 additions and 20 deletions

View file

@ -1,9 +1,7 @@
{ {
description = "A site in nix?"; description = "A site in nix?";
inputs = { inputs = { tix.url = "git+https://git.tristans.cloud/tristan/tix"; };
tix.url = "git+https://git.tristans.cloud/tristan/tix";
};
outputs = { self, nixpkgs, tix }: outputs = { self, nixpkgs, tix }:
let let

View file

@ -1,5 +1,4 @@
let let elems = import ./elems.nix;
elems = import ./elems.nix;
in rec { in rec {
readMd = md: readMd = md:
if builtins.isPath md then if builtins.isPath md then
@ -66,7 +65,7 @@ in rec {
(let (let
m = builtins.match regex block; m = builtins.match regex block;
before = let v = builtins.elemAt m 0; in if v == null then "" else v; before = let v = builtins.elemAt m 0; in if v == null then "" else v;
after = toString( builtins.elemAt m (matchCount - 1)); after = toString (builtins.elemAt m (matchCount - 1));
matchCount = builtins.length m; matchCount = builtins.length m;
in if m == null then in if m == null then
block block
@ -97,14 +96,11 @@ in rec {
(basicRule (wrap "~~") elems.del) (basicRule (wrap "~~") elems.del)
(basicRule (wrap "\\*\\*") elems.strong) (basicRule (wrap "\\*\\*") elems.strong)
(basicRule (wrapBreak "__") elems.strong) (basicRule (wrapBreak "__") elems.strong)
(rule (contains "\\[(.*)]\\((.*)\\)") ( (rule (contains "\\[(.*)]\\((.*)\\)") (m:
m:
let let
href = builtins.elemAt m 2; href = builtins.elemAt m 2;
text = builtins.elemAt m 1; text = builtins.elemAt m 1;
in in (elems.a href text)))
(elems.a href text)
))
(rule ('' (rule (''
(.* (.*
)([^-][^ )([^-][^
@ -127,8 +123,15 @@ in rec {
}) [ m ])) [ (builtins.elemAt l 2) ])) }) [ m ])) [ (builtins.elemAt l 2) ]))
)) ))
(basicRule ( "(.*\n\n)?(.+)\n(.*)?" ) elems.p) (basicRule (''
(basicRule ("(.*\n\n)?```(.*)```(.*)?") (elems.textarea { readonly = true; })) (.*
)?(.+)
(.*)?'') elems.p)
(basicRule (''
(.*
)?```(.*)```(.*)?'') (elems.textarea { readonly = true; }))
(basicRule (containsBreak '' (basicRule (containsBreak ''
###### ([^ ###### ([^
]+)'') (elems.h6)) ]+)'') (elems.h6))

View file

@ -1,4 +1,5 @@
{it,...}:let { it, ... }:
let
elems = import ../nixite/elems.nix; elems = import ../nixite/elems.nix;
style = import ../nixite/style.nix; style = import ../nixite/style.nix;
html = import ../nixite/html.nix; html = import ../nixite/html.nix;

View file

@ -1,5 +1,5 @@
{it, ...}: let { it, ... }:
html = import ../nixite/html.nix; let html = import ../nixite/html.nix;
in with html; [ in with html; [
(it "keeps info in the tag" (let p = tag "p"; (it "keeps info in the tag" (let p = tag "p";

View file

@ -1,4 +1,5 @@
{it,...}: let { it, ... }:
let
md = import ../nixite/md.nix; md = import ../nixite/md.nix;
elems = import ../nixite/elems.nix; elems = import ../nixite/elems.nix;
in with md; [ in with md; [
@ -99,7 +100,10 @@ in with md; [
foo bar foo bar
''; '';
expected = "<p >lorem ipsum\ndolor sit\n</p><p >foo bar</p>"; expected = ''
<p >lorem ipsum
dolor sit
</p><p >foo bar</p>'';
asString = true; asString = true;
}) })

View file

@ -1,4 +1,5 @@
{it,...}:let { it, ... }:
let
html = import ../nixite/html.nix; html = import ../nixite/html.nix;
elems = import ../nixite/elems.nix; elems = import ../nixite/elems.nix;
site = import ../nixite/site.nix; site = import ../nixite/site.nix;

View file

@ -1,4 +1,5 @@
{it,...}: let { it, ... }:
let
style = import ../nixite/style.nix; style = import ../nixite/style.nix;
elems = import ../nixite/elems.nix; elems = import ../nixite/elems.nix;
in [ in [