From e0c772db925a4ac1af1ae7c5767abefe44c91a92 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Sat, 7 Mar 2026 19:21:18 +0100 Subject: [PATCH] testing stuff --- flake.lock | 71 ++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 8 ++++-- main.zig | 40 +++++++++++++++++++++++++++ run.sh | 5 +++- src/main.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++--- template.html | 7 +++++ 6 files changed, 199 insertions(+), 8 deletions(-) create mode 100644 main.zig diff --git a/flake.lock b/flake.lock index e3816b4..6f8bad3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -50,11 +66,28 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1771043024, + "narHash": "sha256-O1XDr7EWbRp+kHrNNgLWgIrB0/US5wvw9K6RERWAj6I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3aadb7ca9eac2891d52a9dec199d9580a6e2bf44", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "rust-overlay": "rust-overlay", + "zig-overlay": "zig-overlay" } }, "rust-overlay": { @@ -89,6 +122,42 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "flake": false, + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "zig-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs_3", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1772540502, + "narHash": "sha256-HXlx2i9gGH2HKfBSMihKCvU6DQMVlR4iyOulkSOe+Cg=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "03fa375def0685b8ce282f118452532845f16a20", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c6775a8..4b0b867 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,10 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # or whatever vers flake-utils.url = "github:numtide/flake-utils"; rust-overlay.url = "github:oxalica/rust-overlay"; + zig-overlay.url = "github:mitchellh/zig-overlay"; }; - outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }: + outputs = { self, nixpkgs, flake-utils, rust-overlay, zig-overlay, ... }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) ]; @@ -19,8 +20,11 @@ devShell = pkgs.mkShell rec { LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}"; packages = with pkgs; [ - (rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)) + rustc + cargo + rust-analyzer gcc + zig-overlay.packages."x86_64-linux".master ]; buildInputs = with pkgs; [ libdisplay-info diff --git a/main.zig b/main.zig new file mode 100644 index 0000000..18223c7 --- /dev/null +++ b/main.zig @@ -0,0 +1,40 @@ +const std = @import("std"); +pub fn main(init: std.process.Init) !void { + const xdxdx = try std.Io.Dir.readFileAlloc(std.Io.Dir.cwd(), init.io, "main.zig", init.gpa, .unlimited); + defer init.gpa.free(xdxdx); + std.debug.print("morbius {s} {s}\n", .{xdxdx, "morbius"}); + switch (f(.blub)) { + .hop => {}, + .jobb => {}, + } + const heee = h(); + std.debug.print("{any}\n", .{heee}); + var huhhh: std.ArrayList(u18) = .empty; + defer huhhh.deinit(init.gpa); + try huhhh.append(init.gpa, 3333); + const Vec3 = @Vector(3, u4); + const a: Vec3 = .{3, 4, 5}; + //const b: Vec3 = .{3, 4, 5}; + std.debug.print("{any}", .{@reduce(.Add, a)}); + //inline for (.{Gloob {}, Gleeeb {}}) |v| { + // v.morbiusss(); + //} +} + +//const Gloob = struct { +// fn morbiusss( self: @This ) void { +// } +//}; +const Gleeeb = struct { + fn morbiusss() void { + } +}; + +fn h() [4]u8 { + return .{3,4,2,1}; +} + +fn f(x: enum { glob, blub }) enum { hop, jobb } { + _ = x; + return .jobb; +} diff --git a/run.sh b/run.sh index 11e8a45..d8af2b6 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,6 @@ #/bin/sh cargo run "$@" > blog.html -sed template.html -e '/INSERT_HERE/r blog.html' > result.html +sed template.html -e '/INSERT_HERE/{ + r blog.html + d +}' > result.html diff --git a/src/main.rs b/src/main.rs index 25b86a8..c3eaaf3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,80 @@ -use std::fs::read; +fn header(i: &str) -> Option<(&str, String)> { + let mut itr = i.chars(); + if let Some(next) = itr.next() && next == '\n' { + if let Some(maybe_star) = itr.skip_while(|c| *c == ' ' || *c == '\t').next() && maybe_star == '*' { + + } + } + Some((i, "

".to_string())) +} fn main() { // arg 1: src, arg 2: dest let args: Vec = std::env::args().collect(); let input: String = std::fs::read_to_string(&args[1]).unwrap(); - let mut output = input; + let mut output: String = String::new(); + + let mut is_bold = false; + let mut title: Option = None; + + let mut itr = input.chars().peekable(); + while let Some(c) = itr.next() { + match c { + '*' => { + if !is_bold { + output.push_str(""); + is_bold = true; + } else { + output.push_str(""); + is_bold = false; + } + } + '\n' => { + if let Some(title_count) = title { + title = None; + output.push_str(&format!("")); + } else { + let mut title_count = 0; + while let Some(c) = itr.peek() { + if *c == '#' { + title_count += 1; + } else if *c == ' ' || *c == '\t' { + // it is title + output.push_str(&format!("")); + title = Some(title_count); + } else { + + } + } + } + output.push('\n'); + } + _ => { + output.push(c); + } + } + } + println!("{output}"); + + //let output: String = input.lines().map(|l| { + // // Titles + // let count = l.chars().take_while(|c| *c == '#').count(); + // if count > 0 { + // format!("{}", &l[count..]) + // } else { + // l.to_string() + // } + //}) + //.map(|l| { + // if l.chars().skip_while(|c| *c == ' ' || *c == '\t').next().unwrap_or('g') == '*' { + // + // } else { + // l.to_string() + // } + //}) + //.collect(); // headings: replace # - newline to

-

- - println!("{}", output); + + //println!("{}", output); } diff --git a/template.html b/template.html index db8e041..81f9dbf 100644 --- a/template.html +++ b/template.html @@ -7,6 +7,13 @@

MDF BLOG 🍼

INSERT_HERE +

Testing erm, stuff

+ bold +
    +
  • an item
  • +
+ italics + 🔈️🍰👆️