doerg-parser

This commit is contained in:
2026-01-31 04:18:24 -07:00
parent 39c13c764b
commit 262a5f680c
13 changed files with 287 additions and 24 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,5 @@
result
result-*
.nrepl-port
.cpcache/
.cache/
@@ -8,7 +9,6 @@ result
.lsp
.nrepl
.direnv/
node_modules
resources/vendor/*
node_modules
.cljs_node_repl

View File

@@ -0,0 +1,3 @@
#+title: doerg-parser
This is a tiny Node script that is used by doerg. It reads Org-mode markup on stdin, feeds it to the lovely [[https://github.com/rasendubi/uniorg][Uniorg]] library, and spits the JSON-encoded AST to stdout.

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env node
const { parse } = require ("uniorg-parse/lib/parser.js");
async function main () {
const chunks = []
for await (const chunk of process.stdin) {
chunks.push (chunk)
}
const orgText = Buffer.concat (chunks).toString ("utf8")
process.stdout.write (JSON.stringify (parse (orgText)))
}
main ()

187
doerg/doerg-parser/package-lock.json generated Normal file
View File

@@ -0,0 +1,187 @@
{
"name": "doerg-parser",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"uniorg-parse": "^3.2.0"
}
},
"node_modules/@types/unist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
"license": "MIT"
},
"node_modules/bail": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
"integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/devlop": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
"integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",
"license": "MIT",
"dependencies": {
"dequal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"license": "MIT"
},
"node_modules/is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/trough": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz",
"integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/unified": {
"version": "11.0.5",
"resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
"integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"bail": "^2.0.0",
"devlop": "^1.0.0",
"extend": "^3.0.0",
"is-plain-obj": "^4.0.0",
"trough": "^2.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/uniorg": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/uniorg/-/uniorg-1.3.0.tgz",
"integrity": "sha512-4FC5ExQJDJAb19Y+Nn7TnRo/Efsio9NwI29A6dZArSY24udp2WH2Gm4DwIi9nqlWsXE8E68i50YlZ+CkDSblTA==",
"license": "GPL-3.0-or-later",
"dependencies": {
"@types/unist": "^3.0.0"
}
},
"node_modules/uniorg-parse": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/uniorg-parse/-/uniorg-parse-3.2.0.tgz",
"integrity": "sha512-eMvDz7X3dl5+wG/UsYQ9+HxDedYobW/+ftGY9uVM+lZlqENsu8zLgveUm0gEnmAWgY5YCSOsSGwAi+d6x6KTeA==",
"license": "GPL-3.0-or-later",
"dependencies": {
"unified": "^11.0.4",
"uniorg": "^1.3.0",
"unist-builder": "^4.0.0",
"vfile": "^6.0.1",
"vfile-location": "^5.0.2"
}
},
"node_modules/unist-builder": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-4.0.0.tgz",
"integrity": "sha512-wmRFnH+BLpZnTKpc5L7O67Kac89s9HMrtELpnNaE6TAobq5DTZZs5YaTQfAZBA9bFPECx2uVAPO31c+GVug8mg==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
"integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",
"integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile-message": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-location": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz",
"integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-message": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",
"integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-stringify-position": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
}
}
}

View File

@@ -0,0 +1,4 @@
{"dependencies": {"uniorg-parse": "^3.2.0"}
,"name": "doerg-parser"
,"version": "0.1.0"
,"bin": {"doerg-parser": "index.js"}}

View File

@@ -0,0 +1,13 @@
{ buildNpmPackage
, importNpmLock
, makeWrapper
}:
buildNpmPackage {
pname = "doerg-parser";
version = "0.1.0";
src = ./.;
npmDeps = importNpmLock { npmRoot = ./.; };
npmConfigHook = importNpmLock.npmConfigHook;
dontNpmBuild = true;
}

View File

@@ -1,14 +1,15 @@
{ mkCljBin
, nodejs
, callPackage
, doerg-parser
}:
mkCljBin {
name = "net.deertopia/doerg";
version = "1.0.0";
version = "0.1.0";
projectSrc = ./.;
lockfile = ../deps-lock.json;
main-ns = "net.deertopia.doerg.main";
buildInputs = [
nodejs
doerg-parser
];
}

View File

@@ -0,0 +1,17 @@
(ns net.deertopia.doerg.parse
(:require [babashka.process :as p]
[babashka.fs :as fs]
[clojure.java.io :as io]
[cheshire.core :as json])
(:refer-clojure :exclude [read-string]))
(defonce ^:private uniorg-script-path-atom (atom nil))
(defn- uniorg []
@(p/process {:in (slurp "/home/msyds/org/20260124165717-if_so_in_korean.org")
:out :string}
"doerg-parser"))
(defn read-string [s]
#_
(p/process "node" (uniorg-script-path)))

18
flake.lock generated
View File

@@ -7,11 +7,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1738969798,
"narHash": "sha256-yHUAph4easuun343wEEJXC4qsftl9vRy+CqLkORkeKI=",
"lastModified": 1767127926,
"narHash": "sha256-x7ySkkTG3dPi6jMhkPVten3pQCIzllRzcFqJ/tRQSFY=",
"owner": "jlesquembre",
"repo": "clj-nix",
"rev": "7b314a06743ef400beb921d3559482741d19bf3f",
"rev": "86c0312e9abcc46e3b4168c1b8ac1daebad5ddb6",
"type": "github"
},
"original": {
@@ -28,11 +28,11 @@
]
},
"locked": {
"lastModified": 1728330715,
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
"lastModified": 1741473158,
"narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=",
"owner": "numtide",
"repo": "devshell",
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
"rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0",
"type": "github"
},
"original": {
@@ -101,11 +101,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1728492678,
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
"lastModified": 1749285348,
"narHash": "sha256-frdhQvPbmDYaScPFiCnfdh3B/Vh81Uuoo0w5TkWmmjU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
"rev": "3e3afe5174c561dee0df6f2c2b2236990146329f",
"type": "github"
},
"original": {

View File

@@ -26,8 +26,11 @@
inherit system;
});
in {
# Exposed as a REPL convenience.
_pkgs = each-system ({ pkgs, ... }: pkgs);
packages = each-system ({ pkgs, ... }: {
inherit (pkgs) server doerg;
inherit (pkgs) server doerg doerg-parser;
default = pkgs.server;
});
@@ -36,16 +39,14 @@
in rec {
server = final.callPackage ./server/package.nix {};
doerg = final.callPackage ./doerg/package.nix {};
doerg-parser = final.callPackage ./doerg/doerg-parser/package.nix {};
};
devShells = each-system ({ pkgs, system, ... }: {
default = pkgs.mkShell {
inputsFrom = [
self.packages.${system}.server
self.packages.${system}.doerg
];
packages = with pkgs; [
clojure-lsp
doerg-parser
zprint
clojure
babashka

View File

@@ -1,13 +1,21 @@
;; -*- mode:clojure -*-
;;; -*- mode:clojure -*-
;;;
;;; USAGE:
;;;
;;; bb -cp . -m override-deps -- [DEP-NAME INFO]…
;;;
;;; This script takes a series of deps substitutions on the command
;;; line, applies them to a deps.edn file (read on stdin), and spits
;;; the result to stdout.
;;;
;;; It is used to build the Doerg server with Nix, since Clj-nix does
;;; not resolve the local deps itself.
(ns override-deps
(:require [rewrite-clj.zip :as z]
[babashka.fs :as fs]
[clojure.edn :as edn]))
#_
(def overrides '{net.deertopia/doerg "blah!!!!"
ring/ring-defaults {:mvn/version "xxxxx"}})
(defn apply-overrides [zloc overrides]
(loop [os (seq overrides)
loc zloc]
@@ -28,3 +36,18 @@
(apply-overrides overrides)
z/root-string
print)))
(comment
"Example overrides"
(def overrides '{net.deertopia/doerg "blah!!!!"
ring/ring-defaults {:mvn/version "xxxxx"}}))
(comment
"Behaviour of `args->overrides`."
(= (args->overrides ["net.deertopia/doerg" "{:mvn/version \"abc\"}"
"ring/ring-defaults" "{:local/root \"/path/to/jar\"}"])
'{ring/ring-defaults {:local/root "/path/to/jar"}
net.deertopia/doerg {:mvn/version "abc"}}))

View File

@@ -5,7 +5,7 @@
mkCljBin {
name = "net.deertopia/server";
version = "1.0.0";
version = "0.1.0";
projectSrc = ./.;
lockfile = ../deps-lock.json;
main-ns = "net.deertopia.server.main";