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

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)))