mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-28 16:26:27 +00:00
Initial import of LogDarioSeq baseline
Establishes version control for the personal Logseq DB fork before starting the server-client architecture migration and domain features described in docs/agent-guide and the approved implementation plan. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
40631362b3
2016 files changed
+543898
No files matched your search
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{:paths ["src"]
|
||||
:api-namespaces [logseq.graph-parser.exporter
|
||||
logseq.graph-parser.schema.mldoc]
|
||||
:report {:format :ignore}}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
;; For CLI
|
||||
logseq.graph-parser.mldoc/ast-export-markdown
|
||||
;; API
|
||||
logseq.graph-parser.mldoc/block-with-title?
|
||||
;; API
|
||||
logseq.graph-parser.mldoc/->db-edn
|
||||
;; API
|
||||
logseq.graph-parser.text/get-file-basename
|
||||
;; API
|
||||
logseq.graph-parser.mldoc/mldoc-link?
|
||||
;; API
|
||||
logseq.graph-parser.text/get-page-name
|
||||
logseq.graph-parser.text/get-namespace-last-part
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{:linters
|
||||
{:aliased-namespace-symbol {:level :warning}
|
||||
:namespace-name-mismatch {:level :warning}
|
||||
:used-underscored-binding {:level :warning}
|
||||
:shadowed-var {:level :warning
|
||||
;; FIXME: Remove these as shadowing core fns isn't a good practice
|
||||
:exclude [val format key name alias type parents exists?]}
|
||||
|
||||
:consistent-alias
|
||||
{:aliases {clojure.string string
|
||||
datascript.core d
|
||||
logseq.graph-parser.text text
|
||||
logseq.graph-parser.block gp-block
|
||||
logseq.graph-parser.mldoc gp-mldoc
|
||||
logseq.common.util common-util
|
||||
logseq.graph-parser.property gp-property
|
||||
logseq.common.config common-config
|
||||
logseq.graph-parser.date-time-util date-time-util
|
||||
logseq.common.util.page-ref page-ref
|
||||
logseq.common.util.block-ref block-ref}}}
|
||||
|
||||
:lint-as {promesa.core/let clojure.core/let
|
||||
promesa.core/loop clojure.core/loop
|
||||
promesa.core/recur clojure.core/recur
|
||||
logseq.graph-parser.test.helper/deftest-async clojure.test/deftest}
|
||||
:skip-comments true
|
||||
:output {:progress true}}
|
||||
@@ -0,0 +1,3 @@
|
||||
/.clj-kondo/.cache
|
||||
cljs-test-runner-out
|
||||
/test/resources/docs*
|
||||
Vendored
+59
@@ -0,0 +1,59 @@
|
||||
## Description
|
||||
|
||||
This library parses a file graph directory and returns it as a datascript
|
||||
database connection. This library mainly exists to convert file graphs to DB graphs.
|
||||
This library is compatible with ClojureScript and with
|
||||
[nbb-logseq](https://github.com/logseq/nbb-logseq) to respectively provide
|
||||
frontend and commandline functionality.
|
||||
|
||||
## API
|
||||
|
||||
This library is under the parent namespace `logseq.graph-parser`. This library
|
||||
provides two main namespaces, `logseq.graph-parser.exporter` and
|
||||
`logseq.graph-parser.extract`.
|
||||
|
||||
## Usage
|
||||
|
||||
See [nbb-logseq example
|
||||
scripts](https://github.com/logseq/nbb-logseq/tree/main/examples) for example
|
||||
usage.
|
||||
|
||||
## Dev
|
||||
|
||||
This follows the practices that [the Logseq frontend
|
||||
follows](/docs/dev-practices.md). Most of the same linters are used, with
|
||||
configurations that are specific to this library. See [this library's CI
|
||||
file](/.github/workflows/deps-graph-parser.yml) for linting examples.
|
||||
|
||||
### Setup
|
||||
|
||||
To run linters and tests, you'll want to install pnpm dependencies once:
|
||||
```
|
||||
pnpm install
|
||||
```
|
||||
|
||||
This step is not needed if you're just running the frontend application.
|
||||
|
||||
### Testing
|
||||
|
||||
Testing is done with nbb-logseq and
|
||||
[nbb-test-runner](https://github.com/nextjournal/nbb-test-runner). Some basic usage:
|
||||
|
||||
```
|
||||
# Run all tests
|
||||
$ pnpm test
|
||||
# List available options
|
||||
$ pnpm test -H
|
||||
# Run tests with :focus metadata flag
|
||||
$ pnpm test -i focus
|
||||
```
|
||||
|
||||
### Managing dependencies
|
||||
|
||||
The package.json dependencies are just for testing and should be updated if there is
|
||||
new behavior to test.
|
||||
|
||||
The deps.edn dependencies are used by both ClojureScript and nbb-logseq. Their
|
||||
versions should be backwards compatible with each other with priority given to
|
||||
the frontend. _No new dependency_ should be introduced to this library without
|
||||
an understanding of the tradeoffs of adding this to nbb-logseq.
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
{:min-bb-version "0.8.156"
|
||||
:deps
|
||||
{logseq/bb-tasks
|
||||
#_{:local/root "../../../bb-tasks"}
|
||||
{:git/url "https://github.com/logseq/bb-tasks"
|
||||
:git/sha "7cc218286c03f093996539b8195de56a0ec5df6a"}}
|
||||
|
||||
:pods
|
||||
{clj-kondo/clj-kondo {:version "2026.04.15"}}
|
||||
|
||||
:tasks
|
||||
{test:load-all-namespaces-with-nbb
|
||||
logseq.bb-tasks.nbb.test/load-all-namespaces
|
||||
|
||||
lint:large-vars
|
||||
logseq.bb-tasks.lint.large-vars/-main
|
||||
|
||||
lint:carve
|
||||
logseq.bb-tasks.lint.carve/-main
|
||||
|
||||
lint:ns-docstrings
|
||||
logseq.bb-tasks.lint.ns-docstrings/-main
|
||||
|
||||
lint:minimize-public-vars
|
||||
logseq.bb-tasks.lint.minimize-public-vars/-main}
|
||||
|
||||
:tasks/config
|
||||
{:large-vars
|
||||
{:max-lines-count 75}}}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
{:paths ["src"]
|
||||
:deps
|
||||
;; These nbb-logseq deps are kept in sync with https://github.com/logseq/nbb-logseq/blob/main/bb.edn
|
||||
{com.andrewmcveigh/cljs-time {:git/url "https://github.com/logseq/cljs-time" ;; fork
|
||||
:sha "5704fbf48d3478eedcf24d458c8964b3c2fd59a9"}
|
||||
funcool/promesa {:mvn/version "11.0.678"}
|
||||
cljs-bean/cljs-bean {:mvn/version "1.9.0"}
|
||||
|
||||
;; Any other deps should be added here and to nbb.edn
|
||||
borkdude/rewrite-edn {:mvn/version "0.5.9"}
|
||||
logseq/db {:local/root "../db"}
|
||||
logseq/common {:local/root "../common"}
|
||||
;; stubbed via logseq.common.log
|
||||
com.lambdaisland/glogi {:git/url "https://github.com/lambdaisland/glogi"
|
||||
:git/sha "30328a045141717aadbbb693465aed55f0904976"}}
|
||||
|
||||
:aliases
|
||||
;; This runs tests with nodejs. Would be nice to run this with in a browser env
|
||||
;; since this is how its normally run in the app but this requires more setup
|
||||
;; with karma, shadow-cljs.edn and headless mode on CI
|
||||
{:test {:extra-paths ["test"]
|
||||
:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.1"}
|
||||
org.clojure/clojurescript {:mvn/version "1.12.134"}
|
||||
logseq/outliner {:local/root "../outliner"}}
|
||||
:main-opts ["-m" "cljs-test-runner.main"]}
|
||||
|
||||
:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2026.04.15"}}
|
||||
:main-opts ["-m" "clj-kondo.main"]}}}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
{:paths ["src"]
|
||||
:deps
|
||||
{logseq/common
|
||||
{:local/root "../common"}
|
||||
logseq/db
|
||||
{:local/root "../db"}
|
||||
logseq/outliner
|
||||
{:local/root "../outliner"}
|
||||
io.github.nextjournal/nbb-test-runner
|
||||
{:git/sha "b379325cfa5a3306180649da5de3bf5166414e71"}
|
||||
borkdude/rewrite-edn {:mvn/version "0.5.9"}
|
||||
io.github.pez/baldr {:mvn/version "1.0.9"}}}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@logseq/graph-parser",
|
||||
"version": "1.0.0",
|
||||
"packageManager": "pnpm@10.33.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@logseq/nbb-logseq": "git+https://github.com/logseq/nbb-logseq.git#feat-db-v34",
|
||||
"better-sqlite3": "^12.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"mldoc": "^1.5.9",
|
||||
"sanitize-filename": "1.6.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "pnpm exec nbb-logseq -cp test -m nextjournal.test-runner",
|
||||
"test-v": "pnpm exec nbb-logseq -cp test -m logseq.graph-parser.test-runner"
|
||||
}
|
||||
}
|
||||
+713
@@ -0,0 +1,713 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
mldoc:
|
||||
specifier: ^1.5.9
|
||||
version: 1.5.9
|
||||
sanitize-filename:
|
||||
specifier: 1.6.4
|
||||
version: 1.6.4
|
||||
devDependencies:
|
||||
'@logseq/nbb-logseq':
|
||||
specifier: git+https://github.com/logseq/nbb-logseq.git#feat-db-v34
|
||||
version: https://codeload.github.com/logseq/nbb-logseq/tar.gz/4d9f1382ce2cec6f39bf12df49ba425f1bd5f3fb
|
||||
better-sqlite3:
|
||||
specifier: ^12.8.0
|
||||
version: 12.8.0
|
||||
|
||||
packages:
|
||||
|
||||
'@logseq/nbb-logseq@https://codeload.github.com/logseq/nbb-logseq/tar.gz/4d9f1382ce2cec6f39bf12df49ba425f1bd5f3fb':
|
||||
resolution: {tarball: https://codeload.github.com/logseq/nbb-logseq/tar.gz/4d9f1382ce2cec6f39bf12df49ba425f1bd5f3fb}
|
||||
version: 1.2.173-feat-db-v34
|
||||
engines: {node: '>=20.10.0'}
|
||||
hasBin: true
|
||||
|
||||
ansi-regex@2.1.1:
|
||||
resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
ansi-regex@3.0.1:
|
||||
resolution: {integrity: sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
|
||||
better-sqlite3@12.8.0:
|
||||
resolution: {integrity: sha512-RxD2Vd96sQDjQr20kdP+F+dK/1OUNiVOl200vKBZY8u0vTwysfolF6Hq+3ZK2+h8My9YvZhHsF+RSGZW2VYrPQ==}
|
||||
engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x}
|
||||
|
||||
bindings@1.5.0:
|
||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
||||
|
||||
bl@4.1.0:
|
||||
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
|
||||
|
||||
buffer@5.7.1:
|
||||
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
||||
|
||||
camelcase@5.3.1:
|
||||
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
chownr@1.1.4:
|
||||
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
||||
|
||||
cliui@4.1.0:
|
||||
resolution: {integrity: sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==}
|
||||
|
||||
code-point-at@1.1.0:
|
||||
resolution: {integrity: sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
cross-spawn@6.0.6:
|
||||
resolution: {integrity: sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==}
|
||||
engines: {node: '>=4.8'}
|
||||
|
||||
decamelize@1.2.0:
|
||||
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
decompress-response@6.0.0:
|
||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
deep-extend@0.6.0:
|
||||
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
detect-libc@2.0.3:
|
||||
resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
end-of-stream@1.4.4:
|
||||
resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}
|
||||
|
||||
execa@1.0.0:
|
||||
resolution: {integrity: sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
expand-template@2.0.3:
|
||||
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
file-uri-to-path@1.0.0:
|
||||
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
|
||||
|
||||
find-up@3.0.0:
|
||||
resolution: {integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
fs-constants@1.0.0:
|
||||
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
||||
|
||||
get-caller-file@1.0.3:
|
||||
resolution: {integrity: sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==}
|
||||
|
||||
get-stream@4.1.0:
|
||||
resolution: {integrity: sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
github-from-package@0.0.0:
|
||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||
|
||||
ieee754@1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
|
||||
import-meta-resolve@4.1.0:
|
||||
resolution: {integrity: sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==}
|
||||
|
||||
inherits@2.0.4:
|
||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
|
||||
ini@1.3.8:
|
||||
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
|
||||
|
||||
invert-kv@2.0.0:
|
||||
resolution: {integrity: sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
is-fullwidth-code-point@1.0.0:
|
||||
resolution: {integrity: sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
is-fullwidth-code-point@2.0.0:
|
||||
resolution: {integrity: sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
is-stream@1.1.0:
|
||||
resolution: {integrity: sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
isexe@2.0.0:
|
||||
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
|
||||
|
||||
lcid@2.0.0:
|
||||
resolution: {integrity: sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
locate-path@3.0.0:
|
||||
resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
map-age-cleaner@0.1.3:
|
||||
resolution: {integrity: sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
mem@4.3.0:
|
||||
resolution: {integrity: sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
mimic-fn@2.1.0:
|
||||
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
mimic-response@3.1.0:
|
||||
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
minimist@1.2.8:
|
||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||
|
||||
mkdirp-classic@0.5.3:
|
||||
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
||||
|
||||
mldoc@1.5.9:
|
||||
resolution: {integrity: sha512-87FQ7hseS87tsk+VdpIigpu8LH+GwmbbFgpxgFwvnbH5oOjmIrc47laH4Dyggzqiy8/vMjDHkl7vsId0eXhCDQ==}
|
||||
hasBin: true
|
||||
|
||||
napi-build-utils@1.0.2:
|
||||
resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==}
|
||||
|
||||
nice-try@1.0.5:
|
||||
resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==}
|
||||
|
||||
node-abi@3.71.0:
|
||||
resolution: {integrity: sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
npm-run-path@2.0.2:
|
||||
resolution: {integrity: sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
number-is-nan@1.0.1:
|
||||
resolution: {integrity: sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
once@1.4.0:
|
||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
||||
|
||||
os-locale@3.1.0:
|
||||
resolution: {integrity: sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
p-defer@1.0.0:
|
||||
resolution: {integrity: sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
p-finally@1.0.0:
|
||||
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
p-is-promise@2.1.0:
|
||||
resolution: {integrity: sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
p-limit@2.3.0:
|
||||
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
p-locate@3.0.0:
|
||||
resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
p-try@2.2.0:
|
||||
resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
path-exists@3.0.0:
|
||||
resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
path-key@2.0.1:
|
||||
resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
prebuild-install@7.1.2:
|
||||
resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
|
||||
hasBin: true
|
||||
|
||||
pump@3.0.2:
|
||||
resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==}
|
||||
|
||||
rc@1.2.8:
|
||||
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
|
||||
hasBin: true
|
||||
|
||||
readable-stream@3.6.2:
|
||||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
require-directory@2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
require-main-filename@1.0.1:
|
||||
resolution: {integrity: sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==}
|
||||
|
||||
safe-buffer@5.2.1:
|
||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||
|
||||
sanitize-filename@1.6.4:
|
||||
resolution: {integrity: sha512-9ZyI08PsvdQl2r/bBIGubpVdR3RR9sY6RDiWFPreA21C/EFlQhmgo20UZlNjZMMZNubusLhAQozkA0Od5J21Eg==}
|
||||
|
||||
semver@5.7.2:
|
||||
resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==}
|
||||
hasBin: true
|
||||
|
||||
semver@7.6.3:
|
||||
resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
set-blocking@2.0.0:
|
||||
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
||||
|
||||
shebang-command@1.2.0:
|
||||
resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
shebang-regex@1.0.0:
|
||||
resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
signal-exit@3.0.7:
|
||||
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
|
||||
|
||||
simple-concat@1.0.1:
|
||||
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
|
||||
|
||||
simple-get@4.0.1:
|
||||
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
|
||||
|
||||
string-width@1.0.2:
|
||||
resolution: {integrity: sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
string-width@2.1.1:
|
||||
resolution: {integrity: sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
string_decoder@1.3.0:
|
||||
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
||||
|
||||
strip-ansi@3.0.1:
|
||||
resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
strip-ansi@4.0.0:
|
||||
resolution: {integrity: sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
strip-eof@1.0.0:
|
||||
resolution: {integrity: sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
strip-json-comments@2.0.1:
|
||||
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
tar-fs@2.1.1:
|
||||
resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==}
|
||||
|
||||
tar-stream@2.2.0:
|
||||
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
truncate-utf8-bytes@1.0.2:
|
||||
resolution: {integrity: sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==}
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
utf8-byte-length@1.0.5:
|
||||
resolution: {integrity: sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==}
|
||||
|
||||
util-deprecate@1.0.2:
|
||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
|
||||
which-module@2.0.1:
|
||||
resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==}
|
||||
|
||||
which@1.3.1:
|
||||
resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==}
|
||||
hasBin: true
|
||||
|
||||
wrap-ansi@2.1.0:
|
||||
resolution: {integrity: sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
y18n@4.0.3:
|
||||
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
|
||||
|
||||
yargs-parser@11.1.1:
|
||||
resolution: {integrity: sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==}
|
||||
|
||||
yargs@12.0.5:
|
||||
resolution: {integrity: sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==}
|
||||
|
||||
snapshots:
|
||||
|
||||
'@logseq/nbb-logseq@https://codeload.github.com/logseq/nbb-logseq/tar.gz/4d9f1382ce2cec6f39bf12df49ba425f1bd5f3fb':
|
||||
dependencies:
|
||||
import-meta-resolve: 4.1.0
|
||||
|
||||
ansi-regex@2.1.1: {}
|
||||
|
||||
ansi-regex@3.0.1: {}
|
||||
|
||||
base64-js@1.5.1: {}
|
||||
|
||||
better-sqlite3@12.8.0:
|
||||
dependencies:
|
||||
bindings: 1.5.0
|
||||
prebuild-install: 7.1.2
|
||||
|
||||
bindings@1.5.0:
|
||||
dependencies:
|
||||
file-uri-to-path: 1.0.0
|
||||
|
||||
bl@4.1.0:
|
||||
dependencies:
|
||||
buffer: 5.7.1
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
|
||||
buffer@5.7.1:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
camelcase@5.3.1: {}
|
||||
|
||||
chownr@1.1.4: {}
|
||||
|
||||
cliui@4.1.0:
|
||||
dependencies:
|
||||
string-width: 2.1.1
|
||||
strip-ansi: 4.0.0
|
||||
wrap-ansi: 2.1.0
|
||||
|
||||
code-point-at@1.1.0: {}
|
||||
|
||||
cross-spawn@6.0.6:
|
||||
dependencies:
|
||||
nice-try: 1.0.5
|
||||
path-key: 2.0.1
|
||||
semver: 5.7.2
|
||||
shebang-command: 1.2.0
|
||||
which: 1.3.1
|
||||
|
||||
decamelize@1.2.0: {}
|
||||
|
||||
decompress-response@6.0.0:
|
||||
dependencies:
|
||||
mimic-response: 3.1.0
|
||||
|
||||
deep-extend@0.6.0: {}
|
||||
|
||||
detect-libc@2.0.3: {}
|
||||
|
||||
end-of-stream@1.4.4:
|
||||
dependencies:
|
||||
once: 1.4.0
|
||||
|
||||
execa@1.0.0:
|
||||
dependencies:
|
||||
cross-spawn: 6.0.6
|
||||
get-stream: 4.1.0
|
||||
is-stream: 1.1.0
|
||||
npm-run-path: 2.0.2
|
||||
p-finally: 1.0.0
|
||||
signal-exit: 3.0.7
|
||||
strip-eof: 1.0.0
|
||||
|
||||
expand-template@2.0.3: {}
|
||||
|
||||
file-uri-to-path@1.0.0: {}
|
||||
|
||||
find-up@3.0.0:
|
||||
dependencies:
|
||||
locate-path: 3.0.0
|
||||
|
||||
fs-constants@1.0.0: {}
|
||||
|
||||
get-caller-file@1.0.3: {}
|
||||
|
||||
get-stream@4.1.0:
|
||||
dependencies:
|
||||
pump: 3.0.2
|
||||
|
||||
github-from-package@0.0.0: {}
|
||||
|
||||
ieee754@1.2.1: {}
|
||||
|
||||
import-meta-resolve@4.1.0: {}
|
||||
|
||||
inherits@2.0.4: {}
|
||||
|
||||
ini@1.3.8: {}
|
||||
|
||||
invert-kv@2.0.0: {}
|
||||
|
||||
is-fullwidth-code-point@1.0.0:
|
||||
dependencies:
|
||||
number-is-nan: 1.0.1
|
||||
|
||||
is-fullwidth-code-point@2.0.0: {}
|
||||
|
||||
is-stream@1.1.0: {}
|
||||
|
||||
isexe@2.0.0: {}
|
||||
|
||||
lcid@2.0.0:
|
||||
dependencies:
|
||||
invert-kv: 2.0.0
|
||||
|
||||
locate-path@3.0.0:
|
||||
dependencies:
|
||||
p-locate: 3.0.0
|
||||
path-exists: 3.0.0
|
||||
|
||||
map-age-cleaner@0.1.3:
|
||||
dependencies:
|
||||
p-defer: 1.0.0
|
||||
|
||||
mem@4.3.0:
|
||||
dependencies:
|
||||
map-age-cleaner: 0.1.3
|
||||
mimic-fn: 2.1.0
|
||||
p-is-promise: 2.1.0
|
||||
|
||||
mimic-fn@2.1.0: {}
|
||||
|
||||
mimic-response@3.1.0: {}
|
||||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
mkdirp-classic@0.5.3: {}
|
||||
|
||||
mldoc@1.5.9:
|
||||
dependencies:
|
||||
yargs: 12.0.5
|
||||
|
||||
napi-build-utils@1.0.2: {}
|
||||
|
||||
nice-try@1.0.5: {}
|
||||
|
||||
node-abi@3.71.0:
|
||||
dependencies:
|
||||
semver: 7.6.3
|
||||
|
||||
npm-run-path@2.0.2:
|
||||
dependencies:
|
||||
path-key: 2.0.1
|
||||
|
||||
number-is-nan@1.0.1: {}
|
||||
|
||||
once@1.4.0:
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
|
||||
os-locale@3.1.0:
|
||||
dependencies:
|
||||
execa: 1.0.0
|
||||
lcid: 2.0.0
|
||||
mem: 4.3.0
|
||||
|
||||
p-defer@1.0.0: {}
|
||||
|
||||
p-finally@1.0.0: {}
|
||||
|
||||
p-is-promise@2.1.0: {}
|
||||
|
||||
p-limit@2.3.0:
|
||||
dependencies:
|
||||
p-try: 2.2.0
|
||||
|
||||
p-locate@3.0.0:
|
||||
dependencies:
|
||||
p-limit: 2.3.0
|
||||
|
||||
p-try@2.2.0: {}
|
||||
|
||||
path-exists@3.0.0: {}
|
||||
|
||||
path-key@2.0.1: {}
|
||||
|
||||
prebuild-install@7.1.2:
|
||||
dependencies:
|
||||
detect-libc: 2.0.3
|
||||
expand-template: 2.0.3
|
||||
github-from-package: 0.0.0
|
||||
minimist: 1.2.8
|
||||
mkdirp-classic: 0.5.3
|
||||
napi-build-utils: 1.0.2
|
||||
node-abi: 3.71.0
|
||||
pump: 3.0.2
|
||||
rc: 1.2.8
|
||||
simple-get: 4.0.1
|
||||
tar-fs: 2.1.1
|
||||
tunnel-agent: 0.6.0
|
||||
|
||||
pump@3.0.2:
|
||||
dependencies:
|
||||
end-of-stream: 1.4.4
|
||||
once: 1.4.0
|
||||
|
||||
rc@1.2.8:
|
||||
dependencies:
|
||||
deep-extend: 0.6.0
|
||||
ini: 1.3.8
|
||||
minimist: 1.2.8
|
||||
strip-json-comments: 2.0.1
|
||||
|
||||
readable-stream@3.6.2:
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
string_decoder: 1.3.0
|
||||
util-deprecate: 1.0.2
|
||||
|
||||
require-directory@2.1.1: {}
|
||||
|
||||
require-main-filename@1.0.1: {}
|
||||
|
||||
safe-buffer@5.2.1: {}
|
||||
|
||||
sanitize-filename@1.6.4:
|
||||
dependencies:
|
||||
truncate-utf8-bytes: 1.0.2
|
||||
|
||||
semver@5.7.2: {}
|
||||
|
||||
semver@7.6.3: {}
|
||||
|
||||
set-blocking@2.0.0: {}
|
||||
|
||||
shebang-command@1.2.0:
|
||||
dependencies:
|
||||
shebang-regex: 1.0.0
|
||||
|
||||
shebang-regex@1.0.0: {}
|
||||
|
||||
signal-exit@3.0.7: {}
|
||||
|
||||
simple-concat@1.0.1: {}
|
||||
|
||||
simple-get@4.0.1:
|
||||
dependencies:
|
||||
decompress-response: 6.0.0
|
||||
once: 1.4.0
|
||||
simple-concat: 1.0.1
|
||||
|
||||
string-width@1.0.2:
|
||||
dependencies:
|
||||
code-point-at: 1.1.0
|
||||
is-fullwidth-code-point: 1.0.0
|
||||
strip-ansi: 3.0.1
|
||||
|
||||
string-width@2.1.1:
|
||||
dependencies:
|
||||
is-fullwidth-code-point: 2.0.0
|
||||
strip-ansi: 4.0.0
|
||||
|
||||
string_decoder@1.3.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
strip-ansi@3.0.1:
|
||||
dependencies:
|
||||
ansi-regex: 2.1.1
|
||||
|
||||
strip-ansi@4.0.0:
|
||||
dependencies:
|
||||
ansi-regex: 3.0.1
|
||||
|
||||
strip-eof@1.0.0: {}
|
||||
|
||||
strip-json-comments@2.0.1: {}
|
||||
|
||||
tar-fs@2.1.1:
|
||||
dependencies:
|
||||
chownr: 1.1.4
|
||||
mkdirp-classic: 0.5.3
|
||||
pump: 3.0.2
|
||||
tar-stream: 2.2.0
|
||||
|
||||
tar-stream@2.2.0:
|
||||
dependencies:
|
||||
bl: 4.1.0
|
||||
end-of-stream: 1.4.4
|
||||
fs-constants: 1.0.0
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
|
||||
truncate-utf8-bytes@1.0.2:
|
||||
dependencies:
|
||||
utf8-byte-length: 1.0.5
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
utf8-byte-length@1.0.5: {}
|
||||
|
||||
util-deprecate@1.0.2: {}
|
||||
|
||||
which-module@2.0.1: {}
|
||||
|
||||
which@1.3.1:
|
||||
dependencies:
|
||||
isexe: 2.0.0
|
||||
|
||||
wrap-ansi@2.1.0:
|
||||
dependencies:
|
||||
string-width: 1.0.2
|
||||
strip-ansi: 3.0.1
|
||||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
y18n@4.0.3: {}
|
||||
|
||||
yargs-parser@11.1.1:
|
||||
dependencies:
|
||||
camelcase: 5.3.1
|
||||
decamelize: 1.2.0
|
||||
|
||||
yargs@12.0.5:
|
||||
dependencies:
|
||||
cliui: 4.1.0
|
||||
decamelize: 1.2.0
|
||||
find-up: 3.0.0
|
||||
get-caller-file: 1.0.3
|
||||
os-locale: 3.1.0
|
||||
require-directory: 2.1.1
|
||||
require-main-filename: 1.0.1
|
||||
set-blocking: 2.0.0
|
||||
string-width: 2.1.1
|
||||
which-module: 2.0.1
|
||||
y18n: 4.0.3
|
||||
yargs-parser: 11.1.1
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
(ns db-import
|
||||
"Imports given file(s) to a db graph. This script is primarily for
|
||||
developing the import feature and for engineers who want to customize
|
||||
the import process"
|
||||
(:require ["fs" :as fs]
|
||||
["fs/promises" :as fsp]
|
||||
["path" :as node-path]
|
||||
[babashka.cli :as cli]
|
||||
[cljs.pprint :as pprint]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.graph :as common-graph]
|
||||
[logseq.db.common.sqlite-cli :as sqlite-cli]
|
||||
[logseq.db.frontend.asset :as db-asset]
|
||||
[logseq.db.frontend.validate :as db-validate]
|
||||
[logseq.graph-parser.exporter :as gp-exporter]
|
||||
[logseq.outliner.cli :as outliner-cli]
|
||||
[nbb.classpath :as cp]
|
||||
[nbb.core :as nbb]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def tx-queue (atom cljs.core/PersistentQueue.EMPTY))
|
||||
;; This is a lower-level dev hook to inspect txs and shouldn't hook into ldb/transact!
|
||||
(def original-transact! d/transact!)
|
||||
(defn dev-transact! [conn tx-data tx-meta]
|
||||
(swap! tx-queue (fn [queue]
|
||||
(let [new-queue (conj queue {:tx-data tx-data :tx-meta tx-meta})]
|
||||
;; Only care about last few so vary 10 as needed
|
||||
(if (> (count new-queue) 10)
|
||||
(pop new-queue)
|
||||
new-queue))))
|
||||
(original-transact! conn tx-data tx-meta))
|
||||
|
||||
(defn- build-graph-files
|
||||
"Given a file graph directory, return all files including assets and adds relative paths
|
||||
on ::rpath since paths are absolute by default and exporter needs relative paths for
|
||||
some operations"
|
||||
[dir*]
|
||||
(let [dir (node-path/resolve dir*)]
|
||||
(->> (common-graph/get-files dir)
|
||||
(concat (when (fs/existsSync (node-path/join dir* "assets"))
|
||||
(common-graph/readdir (node-path/join dir* "assets"))))
|
||||
(mapv #(hash-map :path %
|
||||
::rpath (node-path/relative dir* %))))))
|
||||
|
||||
(defn- <read-file
|
||||
[file]
|
||||
(p/let [s (fsp/readFile (:path file))]
|
||||
(str s)))
|
||||
|
||||
(defn- exceed-limit-size?
|
||||
"Asset size no more than 100M"
|
||||
[^js buffer]
|
||||
(> (.-length buffer) (* 100 1024 1024)))
|
||||
|
||||
(defn- <read-and-copy-asset [db-graph-dir file assets buffer-handler]
|
||||
(p/let [buffer (fs/readFileSync (:path file))
|
||||
checksum (db-asset/<get-file-array-buffer-checksum buffer)
|
||||
asset-id (d/squuid)
|
||||
asset-name (gp-exporter/asset-path->name (:path file))
|
||||
asset-type (db-asset/asset-path->type (:path file))]
|
||||
(if (exceed-limit-size? buffer)
|
||||
(js/console.log (str "Skipped copying asset " (pr-str (:path file)) " because it is larger than the 100M max."))
|
||||
(p/let [parent-dir (node-path/join db-graph-dir common-config/local-assets-dir)
|
||||
{:keys [with-edn-content pdf-annotation?]} (buffer-handler buffer)]
|
||||
(fsp/mkdir parent-dir #js {:recursive true})
|
||||
(swap! assets assoc asset-name
|
||||
(with-edn-content
|
||||
{:size (.-length buffer)
|
||||
:type asset-type
|
||||
:path (:path file)
|
||||
:checksum checksum
|
||||
:asset-id asset-id}))
|
||||
(when-not pdf-annotation?
|
||||
(fsp/copyFile (:path file) (node-path/join parent-dir (str asset-id "." asset-type))))))))
|
||||
|
||||
(defn- notify-user [{:keys [continue debug]} m]
|
||||
(println (:msg m))
|
||||
(when (:ex-data m)
|
||||
(println "Ex-data:" (pr-str (merge (dissoc (:ex-data m) :error)
|
||||
(when-let [err (get-in m [:ex-data :error])]
|
||||
{:original-error (ex-data (.-cause err))}))))
|
||||
(println "\nStacktrace:")
|
||||
(if-let [stack (some-> (get-in m [:ex-data :error]) ex-data :sci.impl/callstack deref)]
|
||||
(println (string/join
|
||||
"\n"
|
||||
(map
|
||||
#(str (:file %)
|
||||
(when (:line %) (str ":" (:line %)))
|
||||
(when (:sci.impl/f-meta %)
|
||||
(str " calls #'" (get-in % [:sci.impl/f-meta :ns]) "/" (get-in % [:sci.impl/f-meta :name]))))
|
||||
(reverse stack))))
|
||||
(println (some-> (get-in m [:ex-data :error]) .-stack)))
|
||||
(when debug
|
||||
(when-let [matching-tx (seq (filter #(and (get-in m [:ex-data :path])
|
||||
(= (get-in % [:tx-meta ::gp-exporter/path]) (get-in m [:ex-data :path])))
|
||||
@tx-queue))]
|
||||
(println (str "\n" (count matching-tx)) "Tx Maps for failing path:")
|
||||
(pprint/pprint matching-tx))))
|
||||
(when (and (= :error (:level m)) (not continue))
|
||||
(js/process.exit 1)))
|
||||
|
||||
(defn default-export-options
|
||||
[file-graph-dir options]
|
||||
{;; common options
|
||||
:rpath-key ::rpath
|
||||
:notify-user (partial notify-user options)
|
||||
:<read-file <read-file
|
||||
;; :set-ui-state prn
|
||||
|
||||
;; config file options
|
||||
;; TODO: Add actual default
|
||||
:default-config {}
|
||||
:<get-file-stat (fn [path]
|
||||
(let [abs-path (if (node-path/isAbsolute path)
|
||||
path
|
||||
(node-path/resolve file-graph-dir path))]
|
||||
(fsp/stat abs-path)))})
|
||||
|
||||
(defn- import-file-graph-to-db
|
||||
"Import a file graph dir just like UI does. However, unlike the UI the
|
||||
exporter receives file maps containing keys :path and ::rpath since :path
|
||||
are full paths"
|
||||
[file-graph-dir db-graph-dir conn options]
|
||||
(let [*files (build-graph-files file-graph-dir)
|
||||
config-file (first (filter #(string/ends-with? (:path %) "logseq/config.edn") *files))
|
||||
_ (assert config-file "No 'logseq/config.edn' found for file graph dir")
|
||||
options (merge options
|
||||
(default-export-options file-graph-dir options)
|
||||
;; asset file options
|
||||
{:<read-and-copy-asset #(<read-and-copy-asset db-graph-dir %1 %2 %3)})]
|
||||
(p/with-redefs [d/transact! dev-transact!]
|
||||
(gp-exporter/export-file-graph conn conn config-file *files options))))
|
||||
|
||||
(defn- resolve-path
|
||||
"If relative path, resolve with $ORIGINAL_PWD"
|
||||
[path]
|
||||
(if (node-path/isAbsolute path)
|
||||
path
|
||||
(node-path/join (or js/process.env.ORIGINAL_PWD ".") path)))
|
||||
|
||||
(defn- import-files-to-db
|
||||
"Import specific doc files for dev purposes"
|
||||
[file conn {:keys [files] :as options}]
|
||||
(let [doc-options (gp-exporter/build-doc-options {:macros {}}
|
||||
;; Pass file-graph-dir as nil since individual files don't specify it
|
||||
(merge options (default-export-options nil options)))
|
||||
files' (mapv #(hash-map :path %)
|
||||
(into [file] (map resolve-path files)))]
|
||||
(p/with-redefs [d/transact! dev-transact!]
|
||||
(p/let [_ (gp-exporter/export-doc-files conn files' <read-file doc-options)]
|
||||
{:import-state (:import-state doc-options)}))))
|
||||
|
||||
(defn- validate-db [db db-name options]
|
||||
(if-let [errors (:errors
|
||||
(db-validate/validate-local-db!
|
||||
db
|
||||
(merge options {:db-name db-name :verbose true})))]
|
||||
(do
|
||||
(println "Found" (count errors)
|
||||
(if (= 1 (count errors)) "entity" "entities")
|
||||
"with errors:")
|
||||
(pprint/pprint errors)
|
||||
(js/process.exit 1))
|
||||
(println "Valid!")))
|
||||
|
||||
(def spec
|
||||
"Options spec"
|
||||
{:help {:alias :h
|
||||
:desc "Print help"}
|
||||
:verbose {:alias :v
|
||||
:desc "Verbose mode"}
|
||||
:debug {:alias :d
|
||||
:desc "Debug mode"}
|
||||
:continue {:alias :c
|
||||
:desc "Continue past import failures"}
|
||||
:all-tags {:alias :a
|
||||
:desc "All tags convert to classes"}
|
||||
:tag-classes {:alias :t
|
||||
:coerce []
|
||||
:desc "List of tags to convert to classes"}
|
||||
:files {:alias :f
|
||||
:coerce []
|
||||
:desc "Additional files to import"}
|
||||
:remove-inline-tags {:alias :r
|
||||
:desc "Remove inline tags"}
|
||||
:property-classes {:alias :p
|
||||
:coerce []
|
||||
:desc "List of properties whose values convert to classes"}
|
||||
:property-parent-classes
|
||||
{:alias :P
|
||||
:coerce []
|
||||
:desc "List of properties whose values convert to a parent class"}
|
||||
:extract-code-snippets?
|
||||
{:alias :C
|
||||
:desc "Extract code fence(s) to #Code"}
|
||||
:validate
|
||||
{:alias :V
|
||||
:desc "Validate db after creation"}})
|
||||
|
||||
(defn -main [args]
|
||||
(let [[file-graph db-graph-dir] args
|
||||
options (cli/parse-opts args {:spec spec})
|
||||
_ (when (or (< (count args) 2) (:help options))
|
||||
(println (str "Usage: $0 FILE-GRAPH DB-GRAPH [OPTIONS]\nOptions:\n"
|
||||
(cli/format-opts {:spec spec})))
|
||||
(js/process.exit 1))
|
||||
init-conn-args (sqlite-cli/->open-db-args db-graph-dir)
|
||||
db-name (if (= 1 (count init-conn-args)) (first init-conn-args) (second init-conn-args))
|
||||
db-full-dir (if (= 1 (count init-conn-args))
|
||||
(node-path/dirname (first init-conn-args))
|
||||
(apply node-path/join init-conn-args))
|
||||
file-graph' (resolve-path file-graph)
|
||||
conn (apply outliner-cli/init-conn (conj init-conn-args {:classpath (cp/get-classpath)
|
||||
:import-type :cli/db-import}))
|
||||
directory? (.isDirectory (fs/statSync file-graph'))
|
||||
user-options (cond-> (merge {:all-tags false} (dissoc options :verbose :files :help :continue))
|
||||
;; coerce option collection into strings
|
||||
(:tag-classes options)
|
||||
(update :tag-classes (partial mapv str))
|
||||
true
|
||||
(set/rename-keys {:all-tags :convert-all-tags? :remove-inline-tags :remove-inline-tags?}))
|
||||
_ (when (:verbose options) (prn :options user-options))
|
||||
options' (merge {:user-options user-options}
|
||||
(select-keys options [:files :verbose :continue :debug :validate]))]
|
||||
(p/let [{:keys [import-state]}
|
||||
(if directory?
|
||||
(import-file-graph-to-db file-graph' db-full-dir conn options')
|
||||
(import-files-to-db file-graph' conn options'))]
|
||||
|
||||
(when-let [ignored-props (seq @(:ignored-properties import-state))]
|
||||
(println "Ignored properties:" (pr-str ignored-props)))
|
||||
(when-let [ignored-assets (seq @(:ignored-assets import-state))]
|
||||
(println "Ignored assets:" (pr-str ignored-assets)))
|
||||
(when-let [ignored-files (seq @(:ignored-files import-state))]
|
||||
(println (count ignored-files) "ignored file(s):" (pr-str (vec ignored-files))))
|
||||
(when (:verbose options') (println "Transacted" (count (d/datoms @conn :eavt)) "datoms"))
|
||||
(println "Created graph" (str db-name "!"))
|
||||
(when (:validate options') (validate-db @conn db-name {})))))
|
||||
|
||||
(when (= nbb/*file* (nbb/invoked-file))
|
||||
(-main *command-line-args*))
|
||||
@@ -0,0 +1,906 @@
|
||||
(ns logseq.graph-parser.block
|
||||
"Given mldoc ast, prepares block data in preparation for db transaction.
|
||||
Used by file and DB graphs"
|
||||
(:require [clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.date :as common-date]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.block-ref :as block-ref]
|
||||
[logseq.common.util.date-time :as date-time-util]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.common.entity-plus :as entity-plus]
|
||||
[logseq.db.common.order :as db-order]
|
||||
[logseq.db.frontend.class :as db-class]
|
||||
[logseq.db.frontend.entity-util :as entity-util]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[logseq.graph-parser.text :as text]
|
||||
[logseq.graph-parser.utf8 :as utf8]))
|
||||
|
||||
(defn heading-block?
|
||||
[block]
|
||||
(and
|
||||
(vector? block)
|
||||
(= "Heading" (first block))))
|
||||
|
||||
(defn get-tag
|
||||
[block]
|
||||
(when-let [tag-value (and (vector? block)
|
||||
(= "Tag" (first block))
|
||||
(second block))]
|
||||
(->> tag-value
|
||||
(map (fn [[elem value]]
|
||||
(case elem
|
||||
"Plain" value
|
||||
"Link" (:full_text value)
|
||||
"Nested_link" (:content value)
|
||||
"")))
|
||||
(string/join))))
|
||||
|
||||
(defn get-page-reference
|
||||
[block format]
|
||||
(let [page (cond
|
||||
(and (vector? block) (= "Link" (first block)))
|
||||
(let [url-type (first (:url (second block)))
|
||||
value (second (:url (second block)))]
|
||||
;; {:url ["File" "file:../pages/hello_world.org"], :label [["Plain" "hello world"]], :title nil}
|
||||
(or
|
||||
(and
|
||||
(= url-type "Page_ref")
|
||||
(and (string? value)
|
||||
(not (common-config/local-relative-asset? value)))
|
||||
value)
|
||||
|
||||
(and
|
||||
(= url-type "Search")
|
||||
(page-ref/page-ref? value)
|
||||
(text/page-ref-un-brackets! value))
|
||||
|
||||
(and (= url-type "Search")
|
||||
(= format :org)
|
||||
(not (common-config/local-relative-asset? value))
|
||||
value)
|
||||
|
||||
(and
|
||||
(= url-type "File")
|
||||
(second (first (:label (second block)))))))
|
||||
|
||||
(and (vector? block) (= "Nested_link" (first block)))
|
||||
(let [content (:content (last block))]
|
||||
(subs content 2 (- (count content) 2)))
|
||||
|
||||
(and (vector? block)
|
||||
(= "Macro" (first block)))
|
||||
(let [{:keys [name arguments]} (second block)
|
||||
argument (string/join ", " arguments)]
|
||||
(if (= name "embed")
|
||||
(when (page-ref/page-ref? argument)
|
||||
(text/page-ref-un-brackets! argument))
|
||||
{:type "macro"
|
||||
:name name
|
||||
:arguments arguments}))
|
||||
|
||||
(and (vector? block)
|
||||
(= "Tag" (first block)))
|
||||
(let [text (get-tag block)]
|
||||
(text/page-ref-un-brackets! text))
|
||||
|
||||
:else
|
||||
nil)]
|
||||
(when page (or (when (string? page)
|
||||
(block-ref/get-block-ref-id page))
|
||||
page))))
|
||||
|
||||
(defn get-block-reference
|
||||
[block]
|
||||
(when-let [block-id (cond
|
||||
(and (vector? block)
|
||||
(= "Block_reference" (first block)))
|
||||
(last block)
|
||||
|
||||
(and (vector? block)
|
||||
(= "Link" (first block))
|
||||
(map? (second block))
|
||||
(= "Block_ref" (first (:url (second block)))))
|
||||
(second (:url (second block)))
|
||||
|
||||
(and (vector? block)
|
||||
(= "Macro" (first block)))
|
||||
(let [{:keys [name arguments]} (second block)]
|
||||
(when (and (= name "embed")
|
||||
(string? (first arguments))
|
||||
(block-ref/string-block-ref? (first arguments)))
|
||||
(block-ref/get-string-block-ref-id (first arguments))))
|
||||
|
||||
(and (vector? block)
|
||||
(= "Link" (first block))
|
||||
(map? (second block)))
|
||||
(if (= "id" (:protocol (second (:url (second block)))))
|
||||
(:link (second (:url (second block))))
|
||||
(let [id (second (:url (second block)))]
|
||||
;; these can be maps
|
||||
(when (string? id)
|
||||
(or (block-ref/get-block-ref-id id) id))))
|
||||
|
||||
:else
|
||||
nil)]
|
||||
(when (some-> block-id parse-uuid)
|
||||
block-id)))
|
||||
|
||||
(defn paragraph-block?
|
||||
[block]
|
||||
(and
|
||||
(vector? block)
|
||||
(= "Paragraph" (first block))))
|
||||
|
||||
(defn timestamp-block?
|
||||
[block]
|
||||
(and
|
||||
(vector? block)
|
||||
(= "Timestamp" (first block))))
|
||||
|
||||
(defn- get-page-refs-from-property-names
|
||||
[properties {:property-pages/keys [enabled? excludelist]}]
|
||||
(if (contains? #{true nil} enabled?)
|
||||
(sequence
|
||||
(comp (map (comp name first))
|
||||
(remove string/blank?)
|
||||
(remove (set (map name excludelist)))
|
||||
;; Remove built-in properties as we don't want pages
|
||||
;; created for them by default
|
||||
(remove (into #{}
|
||||
(map name)
|
||||
(apply conj
|
||||
(apply disj
|
||||
(gp-property/editable-built-in-properties)
|
||||
gp-property/editable-linkable-built-in-properties)
|
||||
(gp-property/hidden-built-in-properties))))
|
||||
(distinct))
|
||||
properties)
|
||||
[]))
|
||||
|
||||
(defn- extract-refs-from-property-value
|
||||
[value format]
|
||||
(cond
|
||||
(coll? value)
|
||||
(filter (fn [v] (and (string? v) (not (string/blank? v)))) value)
|
||||
(and (string? value) (= \" (first value) (last value)))
|
||||
nil
|
||||
(string? value)
|
||||
(let [ast (gp-mldoc/inline->edn value (gp-mldoc/default-config format))]
|
||||
(text/extract-refs-from-mldoc-ast ast))
|
||||
:else
|
||||
nil))
|
||||
|
||||
(defn- get-page-ref-names-from-properties
|
||||
[properties user-config]
|
||||
(let [page-refs (->>
|
||||
properties
|
||||
(remove (fn [[k _]]
|
||||
(contains?
|
||||
(set/union (apply disj
|
||||
(gp-property/editable-built-in-properties)
|
||||
gp-property/editable-linkable-built-in-properties)
|
||||
(gp-property/hidden-built-in-properties))
|
||||
(keyword k))))
|
||||
;; get links ast
|
||||
(map last)
|
||||
(mapcat (fn [value]
|
||||
(extract-refs-from-property-value value (get user-config :format :markdown))))
|
||||
;; comma separated collections
|
||||
(concat (->> (map second properties)
|
||||
(filter coll?)
|
||||
(apply concat))))
|
||||
page-refs-from-property-names (get-page-refs-from-property-names properties user-config)]
|
||||
(->> (concat page-refs page-refs-from-property-names)
|
||||
(remove string/blank?)
|
||||
distinct)))
|
||||
|
||||
(defn- extract-block-refs
|
||||
[nodes]
|
||||
(let [ref-blocks (atom nil)]
|
||||
(walk/postwalk
|
||||
(fn [form]
|
||||
(when-let [block (get-block-reference form)]
|
||||
(swap! ref-blocks conj block))
|
||||
form)
|
||||
nodes)
|
||||
(keep (fn [block]
|
||||
(when-let [id (parse-uuid block)]
|
||||
[:block/uuid id]))
|
||||
@ref-blocks)))
|
||||
|
||||
(defn extract-properties
|
||||
[properties user-config]
|
||||
(when (seq properties)
|
||||
(let [properties (seq properties)
|
||||
*invalid-properties (atom #{})
|
||||
properties (->> properties
|
||||
(map (fn [[k v mldoc-ast]]
|
||||
(let [k (if (or (keyword? k) (symbol? k))
|
||||
(subs (str k) 1)
|
||||
k)
|
||||
k (-> (string/lower-case k)
|
||||
(string/replace "/" "-")
|
||||
(string/replace " " "-")
|
||||
(string/replace "_" "-"))]
|
||||
(if (gp-property/valid-property-name? (str ":" k))
|
||||
(let [k' (keyword
|
||||
(if (contains? #{"custom_id" "custom-id"} k)
|
||||
"id"
|
||||
k))
|
||||
v' (text/parse-property k v mldoc-ast user-config)]
|
||||
[k' v' mldoc-ast v])
|
||||
(do (swap! *invalid-properties conj k)
|
||||
nil)))))
|
||||
(remove #(nil? (second %))))
|
||||
page-refs (get-page-ref-names-from-properties properties user-config)
|
||||
block-refs (extract-block-refs properties)
|
||||
properties-text-values (->> (map (fn [[k _v _refs original-text]] [k original-text]) properties)
|
||||
(into {}))
|
||||
properties (map (fn [[k v _]] [k v]) properties)
|
||||
properties' (into {} properties)]
|
||||
{:properties properties'
|
||||
:properties-order (map first properties)
|
||||
:properties-text-values properties-text-values
|
||||
:invalid-properties @*invalid-properties
|
||||
:page-refs page-refs
|
||||
:block-refs block-refs})))
|
||||
|
||||
(defn- paragraph-timestamp-block?
|
||||
[block]
|
||||
(and (paragraph-block? block)
|
||||
(or (timestamp-block? (first (second block)))
|
||||
(timestamp-block? (second (second block))))))
|
||||
|
||||
(defn- extract-timestamps
|
||||
[block]
|
||||
(some->>
|
||||
(second block)
|
||||
(filter timestamp-block?)
|
||||
(map last)
|
||||
(into {})))
|
||||
|
||||
(defn- timestamp->scheduled-or-deadline-value
|
||||
[{:keys [date repetition] timestamp-time :time}]
|
||||
(let [{:keys [year month day]} date
|
||||
day (js/parseInt (str year (common-util/zero-pad month) (common-util/zero-pad day)))]
|
||||
(if (or timestamp-time repetition)
|
||||
(cond-> {:date-int day}
|
||||
timestamp-time
|
||||
(assoc :time timestamp-time)
|
||||
repetition
|
||||
(assoc :repetition repetition))
|
||||
day)))
|
||||
|
||||
;; {"Deadline" {:date {:year 2020, :month 10, :day 20}, :wday "Tue", :time {:hour 8, :min 0}, :repetition [["DoublePlus"] ["Day"] 1], :active true}}
|
||||
(defn timestamps->scheduled-and-deadline
|
||||
[timestamps]
|
||||
(let [timestamps (update-keys timestamps (comp keyword string/lower-case))
|
||||
m (some->> (select-keys timestamps [:scheduled :deadline])
|
||||
(map (fn [[k v]]
|
||||
(let [value (timestamp->scheduled-or-deadline-value v)]
|
||||
(case k
|
||||
:scheduled
|
||||
{:scheduled value}
|
||||
:deadline
|
||||
{:deadline value})))))]
|
||||
(apply merge m)))
|
||||
|
||||
(defn- convert-page-if-journal-impl
|
||||
"Convert journal file name to user' custom date format"
|
||||
[original-page-name date-formatter & {:keys [export-to-db-graph?]}]
|
||||
(when original-page-name
|
||||
(let [page-name (common-util/page-name-sanity-lc original-page-name)
|
||||
day (when date-formatter
|
||||
(date-time-util/journal-title->int
|
||||
page-name
|
||||
;; When exporting, only use the configured date-formatter. Allowing for other date formatters allows
|
||||
;; for page names to change which breaks looking up journal refs for unconfigured journal pages
|
||||
(if export-to-db-graph? [date-formatter] (date-time-util/safe-journal-title-formatters date-formatter))))]
|
||||
(if day
|
||||
(let [original-page-name' (date-time-util/int->journal-title day date-formatter)
|
||||
default-journal-page-name (date-time-util/int->journal-title day date-time-util/default-journal-title-formatter)]
|
||||
[original-page-name' (common-util/page-name-sanity-lc default-journal-page-name) day])
|
||||
[original-page-name page-name day]))))
|
||||
|
||||
(def convert-page-if-journal (memoize convert-page-if-journal-impl))
|
||||
|
||||
;; Hack to detect export as some fns are too deeply nested to be refactored to get explicit option
|
||||
(def *export-to-db-graph? (atom false))
|
||||
|
||||
(defn- get-page
|
||||
"Similar to get-page but only for file graphs"
|
||||
[db page-name]
|
||||
(when (and db (string? page-name))
|
||||
(d/entity db
|
||||
(first (sort (map :e (entity-util/get-pages-by-name db page-name)))))))
|
||||
|
||||
(defn- page-name-string->map
|
||||
[original-page-name db date-formatter
|
||||
{:keys [with-timestamp? page-uuid from-page class? skip-existing-page-check? skip-journal?]}]
|
||||
(let [db-based? (entity-plus/db-based-graph? db)
|
||||
original-page-name (common-util/remove-boundary-slashes original-page-name)
|
||||
[original-page-name' page-name journal-day]
|
||||
(if skip-journal?
|
||||
[original-page-name (common-util/page-name-sanity-lc original-page-name) nil]
|
||||
(convert-page-if-journal original-page-name date-formatter {:export-to-db-graph? @*export-to-db-graph?}))
|
||||
namespace? (and (or (not db-based?) @*export-to-db-graph?)
|
||||
(not journal-day)
|
||||
(not (boolean (text/get-nested-page-name original-page-name')))
|
||||
(text/namespace-page? original-page-name'))
|
||||
page-entity (when (and db (not skip-existing-page-check?))
|
||||
(cond
|
||||
journal-day
|
||||
(ldb/get-journal-page-by-day db journal-day)
|
||||
|
||||
(and class? db-based?)
|
||||
(some->> (ldb/page-exists? db original-page-name' #{:logseq.class/Tag})
|
||||
first
|
||||
(d/entity db))
|
||||
|
||||
:else
|
||||
(get-page db original-page-name')))
|
||||
original-page-name' (or from-page (:block/title page-entity) original-page-name')
|
||||
page-name' (if (and journal-day page-entity)
|
||||
(:block/name page-entity)
|
||||
page-name)
|
||||
page (merge
|
||||
{:block/name page-name'
|
||||
:block/title original-page-name'}
|
||||
(when (and original-page-name
|
||||
(not= (string/lower-case original-page-name)
|
||||
(string/lower-case original-page-name'))
|
||||
(not @*export-to-db-graph?))
|
||||
{:block.temp/original-page-name original-page-name})
|
||||
(if (and class? page-entity (:db/ident page-entity))
|
||||
{:block/uuid (:block/uuid page-entity)
|
||||
:db/ident (:db/ident page-entity)}
|
||||
(let [new-uuid* (if (uuid? page-uuid)
|
||||
page-uuid
|
||||
(if journal-day
|
||||
(common-uuid/gen-uuid :journal-page-uuid journal-day)
|
||||
(common-uuid/gen-uuid)))
|
||||
new-uuid (if skip-existing-page-check?
|
||||
new-uuid*
|
||||
(or
|
||||
(cond page-entity (:block/uuid page-entity)
|
||||
(uuid? page-uuid) page-uuid)
|
||||
new-uuid*))]
|
||||
{:block/uuid new-uuid}))
|
||||
(when namespace?
|
||||
(let [namespace' (first (common-util/split-last "/" original-page-name))]
|
||||
(when-not (string/blank? namespace')
|
||||
{:block/namespace {:block/name (string/trim (common-util/page-name-sanity-lc namespace'))}})))
|
||||
(when (and with-timestamp? (or skip-existing-page-check? (not page-entity))) ;; Only assign timestamp on creating new entity
|
||||
(let [current-ms (common-util/time-ms)]
|
||||
{:block/created-at current-ms
|
||||
:block/updated-at current-ms}))
|
||||
(if journal-day
|
||||
(cond-> {:block/journal-day journal-day}
|
||||
db-based?
|
||||
(assoc :block/tags [:logseq.class/Journal])
|
||||
(not db-based?)
|
||||
(assoc :block/type "journal"))
|
||||
{}))]
|
||||
[page page-entity]))
|
||||
|
||||
(defn sanitize-hashtag-name
|
||||
"This must be kept in sync with its reverse operation in logseq.db.frontend.content"
|
||||
[s]
|
||||
(string/replace s "#" "HashTag-"))
|
||||
|
||||
(defn- page-entity?
|
||||
"Support DB or file graphs because of exporter"
|
||||
[entity]
|
||||
(or (entity-util/page? entity)
|
||||
(contains? #{"page" "journal"} (:block/type entity))))
|
||||
|
||||
;; TODO: refactor
|
||||
(defn page-name->map
|
||||
"Create a page's map structure given a original page name (string).
|
||||
map as input is supported for legacy compatibility.
|
||||
`with-timestamp?`: assign timestampes to the map structure.
|
||||
Useful when creating new pages from references or namespaces,
|
||||
as there's no chance to introduce timestamps via editing in page
|
||||
`skip-existing-page-check?`: if true, allows pages to have the same name"
|
||||
[original-page-name db with-timestamp? date-formatter
|
||||
& {:keys [page-uuid class?] :as options}]
|
||||
(when-not (and db (common-util/uuid-string? original-page-name)
|
||||
(not (page-entity? (d/entity db [:block/uuid (uuid original-page-name)]))))
|
||||
(let [db-based? (entity-plus/db-based-graph? db)
|
||||
original-page-name (cond-> (string/trim original-page-name)
|
||||
db-based?
|
||||
sanitize-hashtag-name)
|
||||
[page _page-entity] (cond
|
||||
(and original-page-name (string? original-page-name))
|
||||
(page-name-string->map original-page-name db date-formatter
|
||||
(assoc options :with-timestamp? with-timestamp?))
|
||||
:else
|
||||
(let [page (cond (and (map? original-page-name) (:block/uuid original-page-name))
|
||||
original-page-name
|
||||
|
||||
(map? original-page-name)
|
||||
(assoc original-page-name :block/uuid (or page-uuid (d/squuid)))
|
||||
|
||||
:else
|
||||
nil)]
|
||||
[page nil]))]
|
||||
(when page
|
||||
(if db-based?
|
||||
(let [tags (if class? [:logseq.class/Tag]
|
||||
(or (:block/tags page)
|
||||
[:logseq.class/Page]))]
|
||||
(assoc page :block/tags tags))
|
||||
(assoc page :block/type (or (:block/type page) "page")))))))
|
||||
|
||||
(defn- db-namespace-page?
|
||||
"Namespace page that're not journal pages"
|
||||
[db-based? page]
|
||||
(and db-based?
|
||||
(text/namespace-page? page)
|
||||
(not (common-date/valid-journal-title-with-slash? page))))
|
||||
|
||||
(defn- ref->map
|
||||
[db *col {:keys [date-formatter *name->id tag? db-based? structured-tags]}]
|
||||
(let [col (distinct (remove string/blank? @*col))
|
||||
children-pages (->> (mapcat (fn [p]
|
||||
(let [p (if (map? p)
|
||||
(:block/title p)
|
||||
p)]
|
||||
(when (string? p)
|
||||
(let [p (or (text/get-nested-page-name p) p)]
|
||||
(if (and (text/namespace-page? p)
|
||||
(not (common-date/valid-journal-title-with-slash? p))
|
||||
(not tag?))
|
||||
(common-util/split-namespace-pages p)
|
||||
[p])))))
|
||||
col)
|
||||
(remove string/blank?)
|
||||
(distinct))
|
||||
col (->> (distinct (concat col children-pages))
|
||||
(remove nil?))
|
||||
export-to-db-graph? @*export-to-db-graph?]
|
||||
(map
|
||||
(fn [item]
|
||||
(let [macro? (and (map? item)
|
||||
(= "macro" (:type item)))
|
||||
tag? (if export-to-db-graph?
|
||||
tag?
|
||||
(or (contains? structured-tags item) tag?))]
|
||||
(when-not macro?
|
||||
(let [m (page-name->map item db true date-formatter {:class? tag?})
|
||||
result (cond->> m
|
||||
(and db-based? tag? (not (:db/ident m)))
|
||||
(db-class/build-new-class db))
|
||||
page-name (if db-based? (:block/title result) (:block/name result))
|
||||
id (get @*name->id page-name)]
|
||||
(when (nil? id)
|
||||
(swap! *name->id assoc page-name (:block/uuid result)))
|
||||
;; Changing a :block/uuid should be done cautiously here as it can break
|
||||
;; the identity of built-in concepts in db graphs
|
||||
(if (and id
|
||||
(or (when-let [ident (:db/ident result)]
|
||||
(nil? (d/entity db ident)))
|
||||
export-to-db-graph?))
|
||||
(assoc result :block/uuid id)
|
||||
result))))) col)))
|
||||
|
||||
(defn- with-page-refs-and-tags
|
||||
[{:keys [title body tags refs marker priority] :as block} db date-formatter {:keys [structured-tags]
|
||||
:or {structured-tags #{}}}]
|
||||
(let [db-based? (and (entity-plus/db-based-graph? db) (not @*export-to-db-graph?))
|
||||
refs (->> (concat tags refs (when-not db-based? [marker priority]))
|
||||
(remove string/blank?)
|
||||
(distinct))
|
||||
*refs (atom refs)
|
||||
*structured-tags (atom (set structured-tags))]
|
||||
(walk/prewalk
|
||||
(fn [form]
|
||||
;; skip custom queries
|
||||
(when-not (and (vector? form)
|
||||
(= (first form) "Custom")
|
||||
(= (second form) "query"))
|
||||
(when-let [page (get-page-reference form (get block :format :markdown))]
|
||||
(when-let [page' (when-not (db-namespace-page? db-based? page)
|
||||
page)]
|
||||
(swap! *refs conj page')))
|
||||
(when-let [tag (get-tag form)]
|
||||
(let [tag (text/page-ref-un-brackets! tag)]
|
||||
(when-let [tag' (when-not (db-namespace-page? db-based? tag)
|
||||
tag)]
|
||||
(when (common-util/tag-valid? tag')
|
||||
(swap! *refs conj tag')
|
||||
(swap! *structured-tags conj tag')))))
|
||||
form))
|
||||
(concat title body))
|
||||
(swap! *refs #(remove string/blank? %))
|
||||
(let [*name->id (atom {})
|
||||
ref->map-options {:db-based? db-based?
|
||||
:date-formatter date-formatter
|
||||
:*name->id *name->id
|
||||
:structured-tags (set @*structured-tags)}
|
||||
refs (->> (ref->map db *refs ref->map-options)
|
||||
(remove nil?)
|
||||
(map (fn [ref]
|
||||
(cond-> ref
|
||||
(:block.temp/original-page-name ref)
|
||||
(assoc :block.temp/original-page-name (:block.temp/original-page-name ref))))))
|
||||
tags (ref->map db *structured-tags (assoc ref->map-options :tag? true))]
|
||||
(assoc block
|
||||
:refs refs
|
||||
:tags tags))))
|
||||
|
||||
(defn- with-block-refs
|
||||
[{:keys [title body] :as block}]
|
||||
(let [ref-blocks (extract-block-refs (concat title body))
|
||||
refs (distinct (concat (:refs block) ref-blocks))]
|
||||
(assoc block :refs refs)))
|
||||
|
||||
(defn block-keywordize
|
||||
[block]
|
||||
(update-keys
|
||||
block
|
||||
(fn [k]
|
||||
(if (namespace k)
|
||||
k
|
||||
(keyword "block" k)))))
|
||||
|
||||
(defn- sanity-blocks-data
|
||||
"Clean up blocks data and add `block` ns to all keys"
|
||||
[blocks]
|
||||
(map (fn [block]
|
||||
(if (map? block)
|
||||
(block-keywordize (common-util/remove-nils-non-nested block))
|
||||
block))
|
||||
blocks))
|
||||
|
||||
(defn get-block-content
|
||||
[utf8-content block format meta' block-pattern]
|
||||
(let [content (if-let [end-pos (:end_pos meta')]
|
||||
(utf8/substring utf8-content
|
||||
(:start_pos meta')
|
||||
end-pos)
|
||||
(utf8/substring utf8-content
|
||||
(:start_pos meta')))
|
||||
content (when content
|
||||
(let [content (text/remove-level-spaces content format block-pattern)]
|
||||
(if (or (:pre-block? block)
|
||||
(= (get block :format :markdown) :org))
|
||||
content
|
||||
(gp-mldoc/remove-indentation-spaces content (inc (:level block)) false))))]
|
||||
(if (= format :org)
|
||||
content
|
||||
(gp-property/->new-properties content))))
|
||||
|
||||
(defn get-custom-id-or-new-id
|
||||
[properties]
|
||||
(or (when-let [custom-id (or (get-in properties [:properties :custom-id])
|
||||
(get-in properties [:properties :custom_id])
|
||||
(get-in properties [:properties :id]))]
|
||||
;; guard against non-string custom-ids
|
||||
(when-let [custom-id (and (string? custom-id) (string/trim custom-id))]
|
||||
(some-> custom-id parse-uuid)))
|
||||
(d/squuid)))
|
||||
|
||||
(defn get-page-refs-from-properties
|
||||
[properties db date-formatter user-config]
|
||||
(let [page-refs (get-page-ref-names-from-properties properties user-config)]
|
||||
(map (fn [page] (page-name->map page db true date-formatter)) page-refs)))
|
||||
|
||||
(defn- with-page-block-refs
|
||||
[block db date-formatter opts]
|
||||
(some-> block
|
||||
(with-page-refs-and-tags db date-formatter opts)
|
||||
with-block-refs
|
||||
(update :refs (fn [col] (remove nil? col)))))
|
||||
|
||||
(defn- macro->block
|
||||
"macro: {:name \"\" arguments [\"\"]}"
|
||||
[macro]
|
||||
{:block/uuid (common-uuid/gen-uuid)
|
||||
:block/type "macro"
|
||||
:block/properties {:logseq.macro-name (:name macro)
|
||||
:logseq.macro-arguments (:arguments macro)}})
|
||||
|
||||
(defn extract-macros-from-ast
|
||||
[ast]
|
||||
(let [*result (atom #{})]
|
||||
(walk/postwalk
|
||||
(fn [f]
|
||||
(if (and (vector? f) (= (first f) "Macro"))
|
||||
(do
|
||||
(swap! *result conj (second f))
|
||||
nil)
|
||||
f))
|
||||
ast)
|
||||
(mapv macro->block @*result)))
|
||||
|
||||
(defn with-pre-block-if-exists
|
||||
[blocks body pre-block-properties encoded-content {:keys [db date-formatter user-config]}]
|
||||
(let [first-block (first blocks)
|
||||
first-block-start-pos (get-in first-block [:block/meta :start_pos])
|
||||
|
||||
;; Add pre-block
|
||||
blocks (if (or (> first-block-start-pos 0)
|
||||
(empty? blocks))
|
||||
(cons
|
||||
(merge
|
||||
(let [content (utf8/substring encoded-content 0 first-block-start-pos)
|
||||
{:keys [properties properties-order properties-text-values invalid-properties]} pre-block-properties
|
||||
id (get-custom-id-or-new-id {:properties properties})
|
||||
property-refs (->> (get-page-refs-from-properties
|
||||
properties db date-formatter
|
||||
user-config)
|
||||
(map :block/title))
|
||||
pre-block? (if (:heading properties) false true)
|
||||
block {:block/uuid id
|
||||
:block/title content
|
||||
:block/level 1
|
||||
:block/properties properties
|
||||
:block/properties-order (vec properties-order)
|
||||
:block/properties-text-values properties-text-values
|
||||
:block/invalid-properties invalid-properties
|
||||
:block/pre-block? pre-block?
|
||||
:block/macros (extract-macros-from-ast body)
|
||||
:block.temp/ast-body body}
|
||||
{:keys [tags refs]}
|
||||
(with-page-block-refs {:body body :refs property-refs} db date-formatter {})]
|
||||
(cond-> block
|
||||
tags
|
||||
(assoc :block/tags tags)
|
||||
true
|
||||
(assoc :block/refs (concat refs (:block-refs pre-block-properties)))))
|
||||
(select-keys first-block [:block/format :block/page]))
|
||||
blocks)
|
||||
blocks)]
|
||||
blocks))
|
||||
|
||||
(defn- with-heading-property
|
||||
[properties markdown-heading? size]
|
||||
(if markdown-heading?
|
||||
(assoc properties :heading size)
|
||||
properties))
|
||||
|
||||
(defn- construct-block
|
||||
[block properties* timestamps body encoded-content format pos-meta {:keys [block-pattern db date-formatter remove-properties? remove-logbook? remove-deadline-scheduled? db-graph-mode? export-to-db-graph?]}]
|
||||
(let [id (get-custom-id-or-new-id properties*)
|
||||
block-tags (and export-to-db-graph? (get-in properties* [:properties :tags]))
|
||||
;; For export, remove tags from properties as they are being converted to classes
|
||||
properties (if (seq block-tags)
|
||||
(-> properties*
|
||||
(update :properties #(dissoc % :tags))
|
||||
(update :properties-text-values #(dissoc % :tags))
|
||||
(update :properties-order (fn [v] (remove #(= :tags %) v)))
|
||||
(update :page-refs (fn [v] (remove #(= "tags" %) v))))
|
||||
properties*)
|
||||
ref-pages-in-properties (->> (:page-refs properties)
|
||||
(remove string/blank?))
|
||||
block (second block)
|
||||
unordered? (:unordered block)
|
||||
markdown-heading? (and (:size block) (= :markdown format))
|
||||
block (if markdown-heading?
|
||||
(assoc block
|
||||
:level (if unordered? (:level block) 1))
|
||||
block)
|
||||
block (cond->
|
||||
(-> (assoc block
|
||||
:uuid id
|
||||
:refs ref-pages-in-properties
|
||||
:format format
|
||||
:meta pos-meta)
|
||||
(dissoc :size :unordered))
|
||||
(or (seq (:properties properties)) markdown-heading?)
|
||||
(assoc :properties (with-heading-property (:properties properties) markdown-heading? (:size block))
|
||||
:properties-text-values (:properties-text-values properties)
|
||||
:properties-order (vec (:properties-order properties)))
|
||||
|
||||
(seq (:invalid-properties properties))
|
||||
(assoc :invalid-properties (:invalid-properties properties)))
|
||||
block (if (get-in block [:properties :collapsed])
|
||||
(-> (assoc block :collapsed? true)
|
||||
(update :properties (fn [m] (dissoc m :collapsed)))
|
||||
(update :properties-text-values dissoc :collapsed)
|
||||
(update :properties-order (fn [keys'] (vec (remove #{:collapsed} keys')))))
|
||||
block)
|
||||
title (cond->> (get-block-content encoded-content block format pos-meta block-pattern)
|
||||
remove-properties?
|
||||
(gp-property/remove-properties (get block :format :markdown))
|
||||
remove-logbook?
|
||||
(gp-property/remove-logbook)
|
||||
remove-deadline-scheduled?
|
||||
(gp-property/remove-deadline-scheduled))
|
||||
block (assoc block :block/title title)
|
||||
block (if (seq timestamps)
|
||||
(merge block (timestamps->scheduled-and-deadline timestamps))
|
||||
block)
|
||||
db-based? (or db-graph-mode? export-to-db-graph?)
|
||||
block (-> block
|
||||
(assoc :body body)
|
||||
(with-page-block-refs db date-formatter
|
||||
(cond-> {} (seq block-tags) (assoc :structured-tags block-tags))))
|
||||
block (if db-based? block
|
||||
(-> block
|
||||
(update :tags (fn [tags] (map #(assoc % :block/format format) tags)))
|
||||
(update :refs (fn [refs] (map #(if (map? %) (assoc % :block/format format) %) refs)))))
|
||||
block (update block :refs concat (:block-refs properties))
|
||||
{:keys [created-at updated-at]} (:properties properties)
|
||||
block (cond-> block
|
||||
(and created-at (integer? created-at))
|
||||
(assoc :block/created-at created-at)
|
||||
|
||||
(and updated-at (integer? updated-at))
|
||||
(assoc :block/updated-at updated-at))]
|
||||
(dissoc block :title :body :anchor)))
|
||||
|
||||
(defn fix-duplicate-id
|
||||
[block]
|
||||
(println "Logseq will assign a new id for block with content:" (pr-str (:block/title block)))
|
||||
(-> block
|
||||
(assoc :block/uuid (d/squuid))
|
||||
(update :block/properties dissoc :id)
|
||||
(update :block/properties-text-values dissoc :id)
|
||||
(update :block/properties-order #(vec (remove #{:id} %)))
|
||||
(update :block/title (fn [c]
|
||||
(let [replace-str (re-pattern
|
||||
(str
|
||||
"\n*\\s*"
|
||||
(if (= :markdown (get block :block/format :markdown))
|
||||
(str "id" gp-property/colons " " (:block/uuid block))
|
||||
(str (gp-property/colons-org "id") " " (:block/uuid block)))))]
|
||||
(string/replace-first c replace-str ""))))))
|
||||
|
||||
(defn fix-block-id-if-duplicated!
|
||||
"If the block exists in another page or the current page, we need to fix it"
|
||||
[db page-name *extracted-block-ids block]
|
||||
(let [block-page-name (:block/name (:block/page (d/entity db [:block/uuid (:block/uuid block)])))
|
||||
block (if (or (and block-page-name (not= block-page-name page-name))
|
||||
(contains? @*extracted-block-ids (:block/uuid block)))
|
||||
(fix-duplicate-id block)
|
||||
block)]
|
||||
(swap! *extracted-block-ids conj (:block/uuid block))
|
||||
block))
|
||||
|
||||
(defn extract-blocks
|
||||
"Extract headings from mldoc ast. Args:
|
||||
* `ast`: mldoc ast.
|
||||
* `content`: markdown or org-mode text.
|
||||
* `format`: content's format, it could be either :markdown or :org-mode.
|
||||
* `options`: Options are :user-config, :block-pattern, :date-formatter, :db and
|
||||
* :db-graph-mode? : Set when a db graph in the frontend
|
||||
* :export-to-db-graph? : Set when exporting to a db graph"
|
||||
[ast content format {:keys [user-config db-graph-mode? export-to-db-graph?] :as options}]
|
||||
{:pre [(seq ast) (string? content) (contains? #{:markdown :org} format)]}
|
||||
(let [encoded-content (utf8/encode content)
|
||||
all-blocks (vec (reverse ast))
|
||||
[blocks body pre-block-properties]
|
||||
(loop [headings []
|
||||
ast-blocks (reverse ast)
|
||||
block-idx 0
|
||||
timestamps {}
|
||||
properties {}
|
||||
body []
|
||||
prev-block-num 0]
|
||||
(if (seq ast-blocks)
|
||||
(let [[ast-block pos-meta] (first ast-blocks)]
|
||||
(cond
|
||||
(paragraph-timestamp-block? ast-block)
|
||||
(let [ts (extract-timestamps ast-block)
|
||||
timestamps' (merge timestamps ts)]
|
||||
(recur headings (rest ast-blocks) (inc block-idx) timestamps' properties body (inc prev-block-num)))
|
||||
|
||||
(gp-property/properties-ast? ast-block)
|
||||
(let [properties (extract-properties (second ast-block) (assoc user-config :format format))]
|
||||
(recur headings (rest ast-blocks) (inc block-idx) timestamps properties body (inc prev-block-num)))
|
||||
|
||||
(heading-block? ast-block)
|
||||
(let [cut-multiline? (and export-to-db-graph? (= prev-block-num 0))
|
||||
prev-blocks (map first (subvec all-blocks (max 0 (- block-idx prev-block-num)) block-idx))
|
||||
pos-meta' (if cut-multiline?
|
||||
pos-meta
|
||||
;; fix start_pos
|
||||
(assoc pos-meta :end_pos
|
||||
(if (seq headings)
|
||||
(get-in (last headings) [:meta :start_pos])
|
||||
nil)))
|
||||
;; Remove properties, deadline/scheduled and logbook text from title in db graphs
|
||||
options' (assoc options
|
||||
:remove-properties?
|
||||
(and export-to-db-graph? (some gp-property/properties-ast? prev-blocks))
|
||||
:remove-logbook?
|
||||
(and export-to-db-graph? (some #(= ["Drawer" "logbook"] (take 2 %)) prev-blocks))
|
||||
:remove-deadline-scheduled?
|
||||
(and export-to-db-graph? (some #(seq (set/intersection (set (flatten %)) #{"Deadline" "Scheduled"})) prev-blocks)))
|
||||
block' (construct-block ast-block properties timestamps body encoded-content format pos-meta' options')
|
||||
block'' (cond
|
||||
db-graph-mode?
|
||||
block'
|
||||
export-to-db-graph?
|
||||
(assoc block' :block.temp/ast-blocks (cons ast-block body))
|
||||
:else
|
||||
(assoc block' :macros (extract-macros-from-ast (cons ast-block body))))]
|
||||
(recur (conj headings block'') (rest ast-blocks) (inc block-idx) {} {} [] 0))
|
||||
|
||||
:else
|
||||
(recur headings (rest ast-blocks) (inc block-idx) timestamps properties (conj body ast-block) (inc prev-block-num))))
|
||||
[(-> (reverse headings)
|
||||
sanity-blocks-data)
|
||||
body
|
||||
properties]))
|
||||
result (with-pre-block-if-exists blocks body pre-block-properties encoded-content options)]
|
||||
(map #(dissoc % :block/meta) result)))
|
||||
|
||||
(defn with-parent-and-order
|
||||
[page-id blocks]
|
||||
(let [[blocks other-blocks] (split-with
|
||||
(fn [b]
|
||||
(not= "macro" (:block/type b)))
|
||||
blocks)
|
||||
result (loop [blocks (map (fn [block] (assoc block :block/level-spaces (:block/level block))) blocks)
|
||||
parents [{:page/id page-id ; db id or a map {:block/name "xxx"}
|
||||
:block/level 0
|
||||
:block/level-spaces 0}]
|
||||
result []]
|
||||
(if (empty? blocks)
|
||||
(map #(dissoc % :block/level-spaces) result)
|
||||
(let [[block & others] blocks
|
||||
level-spaces (:block/level-spaces block)
|
||||
{uuid' :block/uuid :block/keys [level parent] :as last-parent} (last parents)
|
||||
parent-spaces (:block/level-spaces last-parent)
|
||||
[blocks parents result]
|
||||
(cond
|
||||
(= level-spaces parent-spaces) ; sibling
|
||||
(let [block (assoc block
|
||||
:block/parent parent
|
||||
:block/level level)
|
||||
parents' (conj (vec (butlast parents)) block)
|
||||
result' (conj result block)]
|
||||
[others parents' result'])
|
||||
|
||||
(> level-spaces parent-spaces) ; child
|
||||
(let [parent (if uuid' [:block/uuid uuid'] (:page/id last-parent))
|
||||
block (cond->
|
||||
(assoc block
|
||||
:block/parent parent)
|
||||
;; fix block levels with wrong order
|
||||
;; For example:
|
||||
;; - a
|
||||
;; - b
|
||||
;; What if the input indentation is two spaces instead of 4 spaces
|
||||
(>= (- level-spaces parent-spaces) 1)
|
||||
(assoc :block/level (inc level)))
|
||||
parents' (conj parents block)
|
||||
result' (conj result block)]
|
||||
[others parents' result'])
|
||||
|
||||
(< level-spaces parent-spaces)
|
||||
(cond
|
||||
(some #(= (:block/level-spaces %) (:block/level-spaces block)) parents) ; outdent
|
||||
(let [parents' (vec (filter (fn [p] (<= (:block/level-spaces p) level-spaces)) parents))
|
||||
blocks (cons (assoc (first blocks)
|
||||
:block/level (dec level))
|
||||
(rest blocks))]
|
||||
[blocks parents' result])
|
||||
|
||||
:else
|
||||
(let [[f r] (split-with (fn [p] (<= (:block/level-spaces p) level-spaces)) parents)
|
||||
left (first r)
|
||||
parent-id (if-let [block-id (:block/uuid (last f))]
|
||||
[:block/uuid block-id]
|
||||
page-id)
|
||||
block (assoc block
|
||||
:block/parent parent-id
|
||||
:block/level (:block/level left)
|
||||
:block/level-spaces (:block/level-spaces left))
|
||||
|
||||
parents' (->> (concat f [block]) vec)
|
||||
result' (conj result block)]
|
||||
[others parents' result'])))]
|
||||
(recur blocks parents result))))
|
||||
result' (map (fn [block] (assoc block :block/order (db-order/gen-key))) result)]
|
||||
(concat result' other-blocks)))
|
||||
+3169
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,327 @@
|
||||
(ns logseq.graph-parser.extract
|
||||
"For file graphs, handles extraction of blocks, pages and mldoc ast in
|
||||
preparation for db transaction"
|
||||
;; Disable clj linters since we don't support clj
|
||||
#?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
|
||||
:unresolved-symbol {:level :off}}}})
|
||||
(:require #?(:org.babashka/nbb [logseq.common.log :as log]
|
||||
:default [lambdaisland.glogi :as log])
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[logseq.graph-parser.text :as text]))
|
||||
|
||||
(defn- mldoc-support?
|
||||
[format']
|
||||
(contains? #{:org :markdown :md} (keyword format')))
|
||||
|
||||
(defn- path->file-name
|
||||
;; Only for internal paths, as they are converted to POXIS already
|
||||
;; https://github.com/logseq/logseq/blob/48b8e54e0fdd8fbd2c5d25b7f1912efef8814714/deps/graph-parser/src/logseq/graph_parser/extract.cljc#L32
|
||||
;; Should be converted to POXIS first for external paths
|
||||
[path]
|
||||
(if (string/includes? path "/")
|
||||
(last (common-util/split-last "/" path))
|
||||
path))
|
||||
|
||||
(defn- path->file-body
|
||||
[path]
|
||||
(when-let [file-name (path->file-name path)]
|
||||
(if (string/includes? file-name ".")
|
||||
(first (common-util/split-last "." file-name))
|
||||
file-name)))
|
||||
|
||||
(defn- safe-url-decode
|
||||
[string]
|
||||
(if (string/includes? string "%")
|
||||
(some-> string str common-util/safe-decode-uri-component)
|
||||
string))
|
||||
|
||||
(defn- decode-namespace-underlines
|
||||
"Decode namespace underlines to slashed;
|
||||
If continuous underlines, only decode at start;
|
||||
Having empty namespace is invalid."
|
||||
[string]
|
||||
(string/replace string "___" "/"))
|
||||
|
||||
(defn- make-valid-namespaces
|
||||
"Remove those empty namespaces from title to make it a valid page name."
|
||||
[title]
|
||||
(->> (string/split title "/")
|
||||
(remove empty?)
|
||||
(string/join "/")))
|
||||
|
||||
(defn- tri-lb-title-parsing
|
||||
"Parsing file name under the new file name format
|
||||
Avoid calling directly"
|
||||
[file-name]
|
||||
(some-> file-name
|
||||
(decode-namespace-underlines)
|
||||
(string/replace common-util/url-encoded-pattern safe-url-decode)
|
||||
(make-valid-namespaces)))
|
||||
|
||||
;; Keep for backward compatibility
|
||||
;; Rule of dir-ver 0
|
||||
;; Source: https://github.com/logseq/logseq/blob/e7110eea6790eda5861fdedb6b02c2a78b504cd9/deps/graph-parser/src/logseq/graph_parser/extract.cljc#L35
|
||||
(defn- legacy-title-parsing
|
||||
[file-name-body]
|
||||
(let [title (string/replace file-name-body "." "/")]
|
||||
(or (common-util/safe-decode-uri-component title) title)))
|
||||
|
||||
(defn title-parsing
|
||||
"Convert file name in the given file name format to page title"
|
||||
[file-name-body filename-format]
|
||||
(case filename-format
|
||||
:triple-lowbar (tri-lb-title-parsing file-name-body)
|
||||
(legacy-title-parsing file-name-body)))
|
||||
|
||||
(defn- get-page-name
|
||||
"Get page name with overridden order of
|
||||
`title::` property
|
||||
file name parsing
|
||||
first block content
|
||||
note: `page-name-order` is deprecated on Apr. 2021
|
||||
uri-encoded? - since paths on mobile are uri-encoded, need to decode them first
|
||||
filename-format - the format used to parse file name
|
||||
"
|
||||
[file-path ast uri-encoded? filename-format]
|
||||
;; headline
|
||||
(let [ast (map first ast)
|
||||
file (if uri-encoded? (js/decodeURI file-path) file-path)]
|
||||
;; check backward compatibility?
|
||||
;; FIXME: use pre-config dir
|
||||
(if (string/starts-with? file "pages/contents.")
|
||||
"Contents"
|
||||
(let [first-block (last (first (filter gp-block/heading-block? ast)))
|
||||
property-name (some (fn [ast-node]
|
||||
(when (contains? #{"Properties" "Property_Drawer"} (first ast-node))
|
||||
(let [properties-ast (second ast-node)
|
||||
properties (zipmap (map (comp keyword string/lower-case first) properties-ast)
|
||||
(map second properties-ast))]
|
||||
(:title properties))))
|
||||
ast)
|
||||
first-block-name (let [title (last (first (:title first-block)))]
|
||||
(and first-block
|
||||
(string? title)
|
||||
title))
|
||||
file-name (when-let [result (path->file-body file)]
|
||||
(if (mldoc-support? (common-util/get-file-ext file))
|
||||
(title-parsing result filename-format)
|
||||
result))]
|
||||
(or property-name
|
||||
file-name
|
||||
first-block-name)))))
|
||||
|
||||
(defn- extract-page-alias-and-tags
|
||||
[page-m page-name properties]
|
||||
(let [alias (:alias properties)
|
||||
alias' (if (coll? alias) alias [(str alias)])
|
||||
aliases (and alias'
|
||||
(seq (remove #(or (= page-name (common-util/page-name-sanity-lc %))
|
||||
(string/blank? %)) ;; disable blank alias
|
||||
alias')))
|
||||
aliases' (keep
|
||||
(fn [alias]
|
||||
(let [page-name (common-util/page-name-sanity-lc alias)]
|
||||
{:block/name page-name
|
||||
:block/title alias}))
|
||||
aliases)
|
||||
result (cond-> page-m
|
||||
(seq aliases')
|
||||
(assoc :block/alias aliases')
|
||||
|
||||
(:tags properties)
|
||||
(assoc :block/tags (concat
|
||||
(:block/tags page-m)
|
||||
(let [tags (:tags properties)
|
||||
tags (if (coll? tags) tags [(str tags)])
|
||||
tags (remove string/blank? tags)]
|
||||
(map (fn [tag] {:block/name (common-util/page-name-sanity-lc tag)
|
||||
:block/title tag})
|
||||
tags)))))]
|
||||
(update result :block/properties #(apply dissoc % gp-property/editable-linkable-built-in-properties))))
|
||||
|
||||
(defn- build-page-map
|
||||
[properties invalid-properties properties-text-values file page page-name
|
||||
{:keys [date-formatter db from-page skip-journal?]}]
|
||||
(let [[*valid-properties *invalid-properties]
|
||||
((juxt filter remove)
|
||||
(fn [[k _v]] (gp-property/valid-property-name? (str k))) properties)
|
||||
valid-properties (into {} *valid-properties)
|
||||
invalid-properties (set (->> (map (comp name first) *invalid-properties)
|
||||
(concat invalid-properties)))
|
||||
page-m (->
|
||||
(common-util/remove-nils-non-nested
|
||||
(assoc
|
||||
(gp-block/page-name->map page db true date-formatter
|
||||
:from-page from-page
|
||||
:skip-journal? skip-journal?)
|
||||
:block/file {:file/path (common-util/path-normalize file)}))
|
||||
(extract-page-alias-and-tags page-name properties))]
|
||||
(cond->
|
||||
page-m
|
||||
|
||||
(seq valid-properties)
|
||||
(assoc :block/properties valid-properties
|
||||
:block/properties-text-values (select-keys properties-text-values (keys valid-properties)))
|
||||
|
||||
(seq invalid-properties)
|
||||
(assoc :block/invalid-properties invalid-properties))))
|
||||
|
||||
(defn- attach-block-ids-if-match
|
||||
"If block-ids are provided and match the number of blocks, attach them to blocks
|
||||
If block-ids are provided but don't match the number of blocks, WARN and ignore
|
||||
If block-ids are not provided (nil), just ignore"
|
||||
[block-ids blocks]
|
||||
(or (when block-ids
|
||||
(if (= (count block-ids) (count blocks))
|
||||
(mapv (fn [block-id block]
|
||||
(if (some? block-id)
|
||||
(assoc block :block/uuid (uuid block-id))
|
||||
block))
|
||||
block-ids blocks)
|
||||
(log/error :gp-extract/attach-block-ids-not-match "attach-block-ids-if-match: block-ids provided, but doesn't match the number of blocks, ignoring")))
|
||||
blocks))
|
||||
|
||||
(defn- build-pages-aux
|
||||
[db page-map ref-pages date-formatter format]
|
||||
(let [namespace-pages (let [page (:block/title page-map)]
|
||||
(when (and (not (:block/journal-day page-map))
|
||||
(text/namespace-page? page))
|
||||
(->> (common-util/split-namespace-pages page)
|
||||
(map (fn [page]
|
||||
(-> (gp-block/page-name->map page db true date-formatter)
|
||||
(assoc :block/format format)))))))
|
||||
pages (->> (concat
|
||||
[page-map]
|
||||
@ref-pages
|
||||
namespace-pages)
|
||||
;; remove block references
|
||||
(remove vector?)
|
||||
(remove nil?)
|
||||
(filter :block/name))
|
||||
pages (common-util/distinct-by :block/name pages)
|
||||
pages (remove nil? pages)]
|
||||
(map (fn [page]
|
||||
(let [page-id (if-let [journal-day (:block/journal-day page)]
|
||||
(common-uuid/gen-uuid :journal-page-uuid journal-day)
|
||||
(or (when db
|
||||
(:block/uuid (ldb/get-page db (:block/name page))))
|
||||
(d/squuid)))]
|
||||
(assoc page :block/uuid page-id)))
|
||||
pages)))
|
||||
|
||||
;; TODO: performance improvement
|
||||
(defn- extract-pages-and-blocks
|
||||
"uri-encoded? - if is true, apply URL decode on the file path
|
||||
options -
|
||||
:resolve-uuid-fn - Optional fn which is called to resolve uuids of each block. Enables diff-merge
|
||||
(2 ways diff) based uuid resolution upon external editing.
|
||||
returns a list of the uuids, given the receiving ast, or nil if not able to resolve.
|
||||
Implemented in reset-file-handler/diff-merge-uuids-2ways for IoC
|
||||
Called in gp-extract/extract as AST is being parsed and properties are extracted there"
|
||||
[format ast properties file content {:keys [date-formatter db filename-format resolve-uuid-fn skip-journal?]
|
||||
:or {resolve-uuid-fn (constantly nil)}
|
||||
:as options}]
|
||||
(assert db "Datascript DB is required")
|
||||
(try
|
||||
(let [page (get-page-name file ast false filename-format)
|
||||
[page page-name _journal-day]
|
||||
(if skip-journal?
|
||||
[page (common-util/page-name-sanity-lc page) nil]
|
||||
(gp-block/convert-page-if-journal page date-formatter))
|
||||
options' (assoc options :page-name page-name)
|
||||
;; In case of diff-merge (2way) triggered, use the uuids to override the ones extracted from the AST
|
||||
override-uuids (resolve-uuid-fn format ast content options')
|
||||
*extracted-block-ids (atom #{})
|
||||
blocks (->> (gp-block/extract-blocks ast content format options')
|
||||
(attach-block-ids-if-match override-uuids)
|
||||
(mapv #(gp-block/fix-block-id-if-duplicated! db page-name *extracted-block-ids %))
|
||||
;; FIXME: use page uuid
|
||||
(gp-block/with-parent-and-order {:block/name page-name})
|
||||
(vec))
|
||||
ref-pages (atom #{})
|
||||
blocks (map (fn [block]
|
||||
(if (= (:block/type block) "macro")
|
||||
block
|
||||
(let [block-ref-pages (seq (:block/refs block))]
|
||||
(when block-ref-pages
|
||||
(swap! ref-pages set/union (set block-ref-pages)))
|
||||
(-> block
|
||||
(dissoc :ref-pages)
|
||||
(assoc :block/page [:block/name page-name]
|
||||
:block/refs block-ref-pages
|
||||
:block/format format)))))
|
||||
blocks)
|
||||
[properties invalid-properties properties-text-values]
|
||||
(if (:block/pre-block? (first blocks))
|
||||
[(:block/properties (first blocks))
|
||||
(:block/invalid-properties (first blocks))
|
||||
(:block/properties-text-values (first blocks))]
|
||||
[properties [] {}])
|
||||
page-map (build-page-map properties invalid-properties properties-text-values file page page-name (assoc options' :from-page page))
|
||||
pages (build-pages-aux db page-map ref-pages date-formatter format)
|
||||
blocks (->> (remove nil? blocks)
|
||||
(map (fn [b] (dissoc b :block.temp/ast-title :block.temp/ast-body :block/level :block/children :block/meta))))]
|
||||
[pages blocks])
|
||||
(catch :default e
|
||||
(log/error :exception e))))
|
||||
|
||||
(defn extract
|
||||
"Extracts pages, blocks and ast from given file"
|
||||
[file-path content {:keys [user-config verbose] :or {verbose true} :as options}]
|
||||
(if (string/blank? content)
|
||||
{}
|
||||
(let [format (common-util/get-format file-path)
|
||||
_ (when verbose (println "Parsing start: " file-path))
|
||||
ast (gp-mldoc/->edn content (gp-mldoc/default-config format
|
||||
;; {:parse_outline_only? true}
|
||||
))]
|
||||
(when verbose (println "Parsing finished: " file-path))
|
||||
(let [first-block (ffirst ast)
|
||||
properties (let [properties (and (gp-property/properties-ast? first-block)
|
||||
(->> (last first-block)
|
||||
(map (fn [[x y mldoc-ast]]
|
||||
(let [k (if (keyword? x)
|
||||
(subs (str x) 1)
|
||||
x)]
|
||||
[(string/lower-case k) (text/parse-property k y mldoc-ast (assoc user-config :format format))])))
|
||||
(into {})
|
||||
(walk/keywordize-keys)))]
|
||||
(when (and properties (seq properties))
|
||||
(if (:filters properties)
|
||||
(update properties :filters
|
||||
(fn [v]
|
||||
(string/replace (or v "") "\\" "")))
|
||||
properties)))
|
||||
[pages blocks] (extract-pages-and-blocks format ast properties file-path content options)]
|
||||
{:pages pages
|
||||
:blocks blocks
|
||||
:ast ast}))))
|
||||
|
||||
(defn- with-block-uuid
|
||||
[pages]
|
||||
(->> (common-util/distinct-by :block/name pages)
|
||||
(map (fn [page]
|
||||
(if-let [journal-day (:block/journal-day page)]
|
||||
(assoc page :block/uuid (common-uuid/gen-uuid :journal-page-uuid journal-day))
|
||||
(cond-> page
|
||||
(nil? (:block/uuid page))
|
||||
(assoc :block/uuid (d/squuid))))))))
|
||||
|
||||
(defn with-ref-pages
|
||||
[pages blocks]
|
||||
(let [ref-pages (->> (mapcat :block/refs blocks)
|
||||
(filter :block/name))]
|
||||
(->> (concat pages ref-pages)
|
||||
(group-by :block/name)
|
||||
vals
|
||||
(map (partial apply merge))
|
||||
(with-block-uuid))))
|
||||
@@ -0,0 +1,417 @@
|
||||
(ns logseq.graph-parser.mldoc
|
||||
"Wraps https://github.com/logseq/mldoc to parse files into mldoc ast. This ns
|
||||
encapsulates mldoc's json api by only taking and returning edn"
|
||||
;; Disable clj linters since we don't support clj
|
||||
#?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
|
||||
:unresolved-symbol {:level :off}}}})
|
||||
(:require #?(:org.babashka/nbb ["mldoc$default" :refer [Mldoc]]
|
||||
:default ["mldoc" :refer [Mldoc]])
|
||||
#?(:org.babashka/nbb [logseq.common.log :as log]
|
||||
:default [lambdaisland.glogi :as log])
|
||||
[cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
[goog.object :as gobj]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[logseq.graph-parser.utf8 :as utf8]))
|
||||
|
||||
(defonce parseJson (gobj/get Mldoc "parseJson"))
|
||||
(defonce parseInlineJson (gobj/get Mldoc "parseInlineJson"))
|
||||
(defonce astExportMarkdown (gobj/get Mldoc "astExportMarkdown"))
|
||||
(defonce getReferences (gobj/get Mldoc "getReferences"))
|
||||
|
||||
(def default-references
|
||||
(js/JSON.stringify
|
||||
(clj->js {:embed_blocks []
|
||||
:embed_pages []})))
|
||||
|
||||
(defn- convert-export-md-remove-options [opts]
|
||||
(->> opts
|
||||
(mapv (fn [opt]
|
||||
(case opt
|
||||
:page-ref ["Page_ref"]
|
||||
:emphasis ["Emphasis"]
|
||||
[])))
|
||||
(remove empty?)))
|
||||
|
||||
(defn parse-json
|
||||
[content config]
|
||||
(parseJson content config))
|
||||
|
||||
(defn inline-parse-json
|
||||
[text config]
|
||||
(parseInlineJson text config))
|
||||
|
||||
(defn get-references
|
||||
[text config]
|
||||
(when-not (string/blank? text)
|
||||
(common-util/json->clj (getReferences text config))))
|
||||
|
||||
(defn ast-export-markdown
|
||||
[ast config references]
|
||||
(astExportMarkdown ast
|
||||
config
|
||||
(or references default-references)))
|
||||
|
||||
(defn default-config-map
|
||||
([format]
|
||||
(default-config-map format {:export-heading-to-list? false}))
|
||||
([format {:keys [export-heading-to-list? export-keep-properties? export-md-indent-style export-md-remove-options parse_outline_only?]}]
|
||||
(let [format (string/capitalize (name (or format :markdown)))]
|
||||
(->> {:toc false
|
||||
:parse_outline_only (or parse_outline_only? false)
|
||||
:heading_number false
|
||||
:keep_line_break true
|
||||
:format format
|
||||
:heading_to_list (or export-heading-to-list? false)
|
||||
:exporting_keep_properties export-keep-properties?
|
||||
:export_md_indent_style export-md-indent-style
|
||||
:export_md_remove_options
|
||||
(convert-export-md-remove-options export-md-remove-options)}
|
||||
(filter #(not (nil? (second %))))
|
||||
(into {})))))
|
||||
|
||||
(defn default-config
|
||||
([format]
|
||||
(default-config format {:export-heading-to-list? false}))
|
||||
([format opts]
|
||||
(->> (default-config-map format opts)
|
||||
bean/->js
|
||||
js/JSON.stringify)))
|
||||
|
||||
(defn remove-indentation-spaces
|
||||
"Remove the indentation spaces from the content. Only for markdown.
|
||||
level - ast level + 1 (2 for the first level, 3 for the second level, etc., as the non-first line of multi-line block has 2 more space
|
||||
Ex.
|
||||
- level 1 multiline block first line
|
||||
level 1 multiline block second line
|
||||
\t- level 2 multiline block first line
|
||||
\t level 2 multiline block second line
|
||||
remove-first-line? - apply the indentation removal to the first line or not"
|
||||
[s level remove-first-line?]
|
||||
(let [lines (string/split-lines s)
|
||||
[f & r] lines
|
||||
body (map (fn [line]
|
||||
;; Check if the indentation area only contains white spaces
|
||||
;; Level = ast level + 1, 1-based indentation level
|
||||
;; For markdown in Logseq, the indentation area for the non-first line of multi-line block is (ast level - 1) * "\t" + 2 * "(space)"
|
||||
(if (string/blank? (common-util/safe-subs line 0 level))
|
||||
;; If valid, then remove the indentation area spaces. Keep the rest of the line (might contain leading spaces)
|
||||
(common-util/safe-subs line level)
|
||||
;; Otherwise, trim these invalid spaces
|
||||
(string/triml line)))
|
||||
(if remove-first-line? lines r))
|
||||
content (if remove-first-line? body (cons f body))]
|
||||
(string/join "\n" content)))
|
||||
|
||||
(defn- update-src-full-content
|
||||
[ast content]
|
||||
(let [content (utf8/encode content)]
|
||||
(map (fn [[block pos-meta]]
|
||||
(if (and (vector? block)
|
||||
(= "Src" (first block)))
|
||||
(let [{:keys [start_pos end_pos]} pos-meta
|
||||
content (utf8/substring content start_pos end_pos)
|
||||
spaces (re-find #"^[\t ]+" (first (string/split-lines content)))
|
||||
content (if spaces (remove-indentation-spaces content (count spaces) true)
|
||||
content)
|
||||
block ["Src" (assoc (second block) :full_content content)]]
|
||||
[block pos-meta])
|
||||
[block pos-meta])) ast)))
|
||||
|
||||
(def ^:private inline-ast-types
|
||||
#{"Plain" "Spaces" "Link" "Nested_link" "Target" "Subscript" "Superscript"
|
||||
"Footnote_Reference" "Cookie" "Latex_Fragment" "Macro" "Entity" "Timestamp"
|
||||
"Radio_Target" "Export_Snippet" "Inline_Source_Block" "Email" "Inline_Hiccup"
|
||||
"Inline_Html" "Emphasis" "Verbatim" "Code" "Break_Line" "Hard_Break_Line"})
|
||||
|
||||
(defn- inline-coll?
|
||||
[x]
|
||||
(and (vector? x)
|
||||
(seq x)
|
||||
(every? #(and (vector? %)
|
||||
(string? (first %))
|
||||
(contains? inline-ast-types (first %)))
|
||||
x)))
|
||||
|
||||
(defn- inline-ast->source
|
||||
;; Only reconstructs the source text for the node types that appear when
|
||||
;; mldoc splits a macro containing ^{}/{_{}. Nested rich-inline types
|
||||
;; (Emphasis, Code, etc.) inside a Superscript/Subscript will produce nil,
|
||||
;; which (apply str ...) silently drops. This is intentional: the function
|
||||
;; is only called during macro-recovery, not for general rendering.
|
||||
[[typ content]]
|
||||
(case typ
|
||||
"Plain" content
|
||||
"Spaces" content
|
||||
"Link" (:full_text content)
|
||||
;; Nested_link is the AST node for [[page name]]; :content is the page name
|
||||
;; string. Without this case, collect-macro-source aborts via when-let
|
||||
;; whenever a page ref appears inside a fragmented macro.
|
||||
"Nested_link" (str "[[" (:content content) "]]")
|
||||
"Superscript" (str "^{" (apply str (map inline-ast->source content)) "}")
|
||||
"Subscript" (str "_{" (apply str (map inline-ast->source content)) "}")
|
||||
nil))
|
||||
|
||||
(defn- starts-with-at?
|
||||
[s prefix idx]
|
||||
(let [end (+ idx (count prefix))]
|
||||
(and (<= end (count s))
|
||||
(= prefix (subs s idx end)))))
|
||||
|
||||
(defn- unclosed-script-markup?
|
||||
[s]
|
||||
(loop [idx 0
|
||||
depth 0]
|
||||
(if (< idx (count s))
|
||||
(cond
|
||||
(or (starts-with-at? s "^{" idx)
|
||||
(starts-with-at? s "_{" idx))
|
||||
(recur (+ idx 2) (inc depth))
|
||||
|
||||
(and (pos? depth) (= \} (nth s idx)))
|
||||
(recur (inc idx) (dec depth))
|
||||
|
||||
:else
|
||||
(recur (inc idx) depth))
|
||||
(pos? depth))))
|
||||
|
||||
(defn- split-macro-arguments
|
||||
[s]
|
||||
(if (string/blank? s)
|
||||
[]
|
||||
(loop [idx 0
|
||||
start 0
|
||||
page-ref-depth 0
|
||||
script-depth 0
|
||||
quoted? false
|
||||
escaped? false
|
||||
result []]
|
||||
(if (< idx (count s))
|
||||
(let [c (nth s idx)]
|
||||
(cond
|
||||
escaped?
|
||||
(recur (inc idx) start page-ref-depth script-depth quoted? false result)
|
||||
|
||||
(= \\ c)
|
||||
(recur (inc idx) start page-ref-depth script-depth quoted? true result)
|
||||
|
||||
(= \" c)
|
||||
(recur (inc idx) start page-ref-depth script-depth (not quoted?) false result)
|
||||
|
||||
quoted?
|
||||
(recur (inc idx) start page-ref-depth script-depth quoted? false result)
|
||||
|
||||
(starts-with-at? s "[[" idx)
|
||||
(recur (+ idx 2) start (inc page-ref-depth) script-depth quoted? false result)
|
||||
|
||||
(and (pos? page-ref-depth) (starts-with-at? s "]]" idx))
|
||||
(recur (+ idx 2) start (dec page-ref-depth) script-depth quoted? false result)
|
||||
|
||||
(or (starts-with-at? s "^{" idx)
|
||||
(starts-with-at? s "_{" idx))
|
||||
(recur (+ idx 2) start page-ref-depth (inc script-depth) quoted? false result)
|
||||
|
||||
(and (pos? script-depth) (= \} c))
|
||||
(recur (inc idx) start page-ref-depth (dec script-depth) quoted? false result)
|
||||
|
||||
(and (zero? page-ref-depth) (zero? script-depth) (= \, c))
|
||||
(recur (inc idx) (inc idx) page-ref-depth script-depth quoted? false
|
||||
(conj result (string/trim (subs s start idx))))
|
||||
|
||||
:else
|
||||
(recur (inc idx) start page-ref-depth script-depth quoted? false result)))
|
||||
(conj result (string/trim (subs s start)))))))
|
||||
|
||||
(defn- macro-source->ast
|
||||
[s]
|
||||
(when (and (string/starts-with? s "{{")
|
||||
(string/ends-with? s "}}"))
|
||||
(let [content (-> s
|
||||
(subs 2 (- (count s) 2))
|
||||
string/triml)
|
||||
[_ name arguments] (re-matches #"([^\s]+)(?:\s+([\s\S]*))?" content)]
|
||||
(when name
|
||||
["Macro" {:name name
|
||||
:arguments (split-macro-arguments arguments)}]))))
|
||||
|
||||
(defn- collect-macro-source
|
||||
[items]
|
||||
(loop [remaining items
|
||||
source ""]
|
||||
(when-let [[item & more] (seq remaining)]
|
||||
(let [[typ content] item]
|
||||
(cond
|
||||
(= "Plain" typ)
|
||||
(if-let [idx (string/index-of content "}}")]
|
||||
(let [macro-source (str source (subs content 0 (+ idx 2)))]
|
||||
(when-let [macro (macro-source->ast macro-source)]
|
||||
(let [suffix (subs content (+ idx 2))]
|
||||
{:macro macro
|
||||
:suffix (when-not (string/blank? suffix) ["Plain" suffix])
|
||||
:remaining more})))
|
||||
(recur more (str source content)))
|
||||
|
||||
:else
|
||||
(when-let [item-source (inline-ast->source item)]
|
||||
(recur more (str source item-source))))))))
|
||||
|
||||
(defn- close-script-markup-in-macro
|
||||
;; Appends a single "}" to the last argument to close the outermost
|
||||
;; unmatched ^{/{_ bracket. Handles only depth-1 cases; deeper nesting
|
||||
;; (e.g. Ca^{^{2}}) is not supported and is not expected in practice.
|
||||
[macro]
|
||||
(update-in macro [1 :arguments]
|
||||
(fn [arguments]
|
||||
(update arguments (dec (count arguments)) str "}"))))
|
||||
|
||||
(defn- recover-inline-macros
|
||||
[inline-list]
|
||||
(loop [remaining inline-list
|
||||
result []]
|
||||
(if-let [[item & more] (seq remaining)]
|
||||
(let [[typ content] item]
|
||||
(cond
|
||||
(and (= "Plain" typ)
|
||||
(string/includes? content "{{"))
|
||||
(let [idx (string/index-of content "{{")
|
||||
prefix (subs content 0 idx)
|
||||
start-item ["Plain" (subs content idx)]]
|
||||
(if-let [{:keys [macro suffix remaining]} (collect-macro-source (cons start-item more))]
|
||||
(recur (if suffix
|
||||
(cons suffix remaining)
|
||||
remaining)
|
||||
(cond-> result
|
||||
(not (string/blank? prefix)) (conj ["Plain" prefix])
|
||||
true (conj macro)))
|
||||
(recur more (conj result item))))
|
||||
|
||||
(and (= "Macro" typ)
|
||||
(seq (:arguments content))
|
||||
(unclosed-script-markup? (last (:arguments content)))
|
||||
(= "Plain" (ffirst more))
|
||||
(string/starts-with? (second (first more)) "}"))
|
||||
(let [[_ plain] (first more)
|
||||
suffix (subs plain 1)]
|
||||
(recur (if (string/blank? suffix)
|
||||
(rest more)
|
||||
(cons ["Plain" suffix] (rest more)))
|
||||
(conj result (close-script-markup-in-macro item))))
|
||||
|
||||
:else
|
||||
(recur more (conj result item))))
|
||||
result)))
|
||||
|
||||
(defn- normalize-macro-asts
|
||||
[ast]
|
||||
(walk/postwalk
|
||||
(fn [x]
|
||||
(if (inline-coll? x)
|
||||
(recover-inline-macros x)
|
||||
x))
|
||||
ast))
|
||||
|
||||
(defn- macro-with-script-markup?
|
||||
[content]
|
||||
(and (string/includes? content "{{")
|
||||
(or (string/includes? content "^{")
|
||||
(string/includes? content "_{"))))
|
||||
|
||||
(defn collect-page-properties
|
||||
[ast config]
|
||||
(when (seq ast)
|
||||
(let [original-ast ast
|
||||
directive? (fn [[item _]] (= "directive" (string/lower-case (first item))))
|
||||
grouped-ast (group-by directive? original-ast)
|
||||
[properties-ast other-ast] [(->> (get grouped-ast true)
|
||||
(map first))
|
||||
(get grouped-ast false)]
|
||||
properties (map (fn [[_directive k v]]
|
||||
[k v (get-references v config)])
|
||||
properties-ast)]
|
||||
(if (seq properties)
|
||||
(cons [["Properties" properties] nil] other-ast)
|
||||
original-ast))))
|
||||
|
||||
(defn get-default-config
|
||||
"Gets a mldoc default config for the given format. Works for DB and file graphs"
|
||||
[repo format]
|
||||
(let [db-based? (sqlite-util/db-based-graph? repo)]
|
||||
(->>
|
||||
(cond-> (default-config-map format)
|
||||
db-based?
|
||||
(assoc :enable_drawers false
|
||||
:parse_marker false
|
||||
:parse_priority false))
|
||||
bean/->js
|
||||
js/JSON.stringify)))
|
||||
|
||||
(defn ->edn
|
||||
;; TODO: Re-enable schema
|
||||
;; {:malli/schema [:=> [:cat :string :string] mldoc-schema/block-ast-with-pos-coll-schema]}
|
||||
([content config]
|
||||
(if (string? content)
|
||||
(try
|
||||
(if (string/blank? content)
|
||||
[]
|
||||
(-> content
|
||||
(parse-json config)
|
||||
(common-util/json->clj)
|
||||
(cond-> (macro-with-script-markup? content)
|
||||
(normalize-macro-asts))
|
||||
(update-src-full-content content)
|
||||
(collect-page-properties config)))
|
||||
(catch :default e
|
||||
(log/error :unexpected-error e)
|
||||
[]))
|
||||
(log/error :edn/wrong-content-type content)))
|
||||
([repo content format]
|
||||
(->edn content (get-default-config repo format))))
|
||||
|
||||
(defn ->db-edn
|
||||
"Wrapper around ->edn for DB graphs"
|
||||
[content format]
|
||||
(->edn "logseq_db_repo_stub" content format))
|
||||
|
||||
(defn inline->edn
|
||||
[text config]
|
||||
(try
|
||||
(if (string/blank? text)
|
||||
{}
|
||||
(-> text
|
||||
(inline-parse-json config)
|
||||
(common-util/json->clj)
|
||||
(cond-> (macro-with-script-markup? text)
|
||||
(normalize-macro-asts))))
|
||||
(catch :default _e
|
||||
[])))
|
||||
|
||||
(defn ast-link?
|
||||
[[type link]]
|
||||
(let [[ref-type ref-value] (:url link)]
|
||||
(and (= "Link" type)
|
||||
(or
|
||||
;; 1. url
|
||||
(not (contains? #{"Page_ref" "Block_ref"} ref-type))
|
||||
|
||||
(and (contains? #{"Page_ref"} ref-type)
|
||||
(boolean (common-config/local-relative-asset? ref-value)))))))
|
||||
|
||||
(defn mldoc-link?
|
||||
"Check whether s is a link (including page/block refs)."
|
||||
[format s]
|
||||
(let [result (inline->edn s (default-config format))]
|
||||
(and
|
||||
(= 1 (count result))
|
||||
(let [result' (first result)]
|
||||
(or (contains? #{"Nested_link"} (first result'))
|
||||
(contains? #{"Page_ref" "Block_ref" "Complex"} (first (:url (second result')))))))))
|
||||
|
||||
(defn block-with-title?
|
||||
[type]
|
||||
(contains? #{"Paragraph"
|
||||
"Raw_Html"
|
||||
"Hiccup"
|
||||
"Heading"} type))
|
||||
@@ -0,0 +1,221 @@
|
||||
(ns logseq.graph-parser.property
|
||||
"For file graphs, core vars and util fns for properties"
|
||||
(:require [clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]
|
||||
[goog.string.format]
|
||||
[logseq.common.util :as common-util]))
|
||||
|
||||
(def colons "Property delimiter for markdown mode" "::")
|
||||
(defn colons-org
|
||||
"Property delimiter for org mode"
|
||||
[property]
|
||||
(str ":" property ":"))
|
||||
|
||||
(defn properties-ast?
|
||||
[block]
|
||||
(and
|
||||
(vector? block)
|
||||
(contains? #{"Property_Drawer" "Properties"}
|
||||
(first block))))
|
||||
|
||||
(defn valid-property-name?
|
||||
[s]
|
||||
{:pre [(string? s)]}
|
||||
(and (common-util/valid-edn-keyword? s)
|
||||
(not (re-find #"[\"|^|(|)|{|}]+" s))
|
||||
;; Disallow tags as property names
|
||||
(not (re-find #"^:#" s))))
|
||||
|
||||
;; Built-in properties are properties that logseq uses for its features. Most of
|
||||
;; these properties are hidden from the user but a few like the editable ones
|
||||
;; are visible for the user to edit.
|
||||
|
||||
(def editable-linkable-built-in-properties
|
||||
"Properties used by logseq that user can edit and that can have linkable property values"
|
||||
#{:alias :aliases :tags})
|
||||
|
||||
(defn editable-built-in-properties
|
||||
"Properties used by logseq that user can edit"
|
||||
[]
|
||||
(set/union #{:title :icon :template :template-including-parent :public :filters :exclude-from-graph-view
|
||||
:logseq.query/nlp-date
|
||||
;; org-mode only
|
||||
:macro :filetags}
|
||||
editable-linkable-built-in-properties))
|
||||
|
||||
(defn hidden-built-in-properties
|
||||
"Properties used by logseq that user can't edit or see"
|
||||
[]
|
||||
#{:custom-id :background_color :created_at :last_modified_at ; backward compatibility only
|
||||
:id :background-color :heading :collapsed
|
||||
:created-at :updated-at :last-modified-at
|
||||
:query-table :query-properties :query-sort-by :query-sort-desc :ls-type
|
||||
:hl-type :hl-page :hl-stamp :hl-color :hl-value :logseq.macro-name :logseq.macro-arguments
|
||||
:logseq.order-list-type
|
||||
; task markers
|
||||
:todo :doing :now :later :done})
|
||||
|
||||
(def built-in-property-types
|
||||
"Types for built-in properties. Built-in properties whose values are to be
|
||||
parsed by gp-text/parse-non-string-property-value should be added here"
|
||||
{:template-including-parent :boolean
|
||||
:public :boolean
|
||||
:exclude-from-graph-view :boolean
|
||||
:logseq.query/nlp-date :boolean
|
||||
:heading :boolean ; FIXME: or integer
|
||||
:collapsed :boolean
|
||||
:created-at :integer
|
||||
:created_at :integer
|
||||
:updated-at :integer
|
||||
:last-modified-at :integer
|
||||
:last_modified_at :integer
|
||||
:query-table :boolean
|
||||
:query-sort-desc :boolean
|
||||
:hl-page :integer
|
||||
:hl-stamp :integer
|
||||
:todo :integer
|
||||
:doing :integer
|
||||
:now :integer
|
||||
:later :integer
|
||||
:done :integer})
|
||||
|
||||
(assert (set/subset? (set (keys built-in-property-types))
|
||||
(set/union (hidden-built-in-properties)
|
||||
(editable-built-in-properties)))
|
||||
"Keys of built-in-property-types must be valid built-in properties")
|
||||
|
||||
(defn unparsed-built-in-properties
|
||||
"Properties whose values will not be parsed by gp-text/parse-property"
|
||||
[]
|
||||
(set/difference (set/union (hidden-built-in-properties)
|
||||
(editable-built-in-properties))
|
||||
;; Refs need to be parsed
|
||||
editable-linkable-built-in-properties
|
||||
;; All these should be parsed by gp-text/parse-non-string-property-value
|
||||
(set (keys built-in-property-types))))
|
||||
|
||||
(defonce properties-start ":PROPERTIES:")
|
||||
(defonce properties-end ":END:")
|
||||
(defonce properties-end-pattern
|
||||
(re-pattern (gstring/format "%s[\t\r ]*\n|(%s\\s*$)" properties-end properties-end)))
|
||||
|
||||
(defn- contains-properties?
|
||||
[content]
|
||||
(when content
|
||||
(and (string/includes? content properties-start)
|
||||
(re-find properties-end-pattern content))))
|
||||
|
||||
(defn ->new-properties
|
||||
"New syntax: key:: value"
|
||||
[content]
|
||||
(if (contains-properties? content)
|
||||
(let [lines (string/split-lines content)
|
||||
start-idx (.indexOf lines properties-start)
|
||||
end-idx (.indexOf lines properties-end)]
|
||||
(if (and (>= start-idx 0) (> end-idx 0) (> end-idx start-idx))
|
||||
(let [before (subvec lines 0 start-idx)
|
||||
middle (->> (subvec lines (inc start-idx) end-idx)
|
||||
(map (fn [text]
|
||||
(let [[k v] (common-util/split-first ":" (subs text 1))]
|
||||
(if (and k v)
|
||||
(let [k (string/replace k "_" "-")
|
||||
compare-k (keyword (string/lower-case k))
|
||||
k (if (contains? #{:id :custom_id :custom-id} compare-k) "id" k)
|
||||
k (if (contains? #{:last-modified-at} compare-k) "updated-at" k)]
|
||||
(str k colons " " (string/trim v)))
|
||||
text)))))
|
||||
after (subvec lines (inc end-idx))
|
||||
lines (concat before middle after)]
|
||||
(string/join "\n" lines))
|
||||
content))
|
||||
content))
|
||||
|
||||
(defn simplified-property?
|
||||
[line]
|
||||
(boolean
|
||||
(and (string? line)
|
||||
(re-find (re-pattern (str "^\\s?[^ ]+" colons)) line))))
|
||||
|
||||
(defn remove-properties
|
||||
[format content]
|
||||
(cond
|
||||
(contains-properties? content)
|
||||
(let [lines (string/split-lines content)
|
||||
[title-lines properties&body] (split-with #(-> (string/triml %)
|
||||
string/upper-case
|
||||
(string/starts-with? properties-start)
|
||||
not)
|
||||
lines)
|
||||
body (drop-while #(-> (string/trim %)
|
||||
string/upper-case
|
||||
(string/starts-with? properties-end)
|
||||
not
|
||||
(or (string/blank? %)))
|
||||
properties&body)
|
||||
body (if (and (seq body)
|
||||
(-> (first body)
|
||||
string/triml
|
||||
string/upper-case
|
||||
(string/starts-with? properties-end)))
|
||||
(let [line (string/replace (first body) #"(?i):END:\s?" "")]
|
||||
(if (string/blank? line)
|
||||
(rest body)
|
||||
(cons line (rest body))))
|
||||
body)]
|
||||
(->> (concat title-lines body)
|
||||
(string/join "\n")))
|
||||
|
||||
(not= format :org)
|
||||
(let [lines (string/split-lines content)
|
||||
lines (if (simplified-property? (first lines))
|
||||
(drop-while simplified-property? lines)
|
||||
(cons (first lines)
|
||||
(drop-while simplified-property? (rest lines))))]
|
||||
(string/join "\n" lines))
|
||||
|
||||
:else
|
||||
content))
|
||||
|
||||
(defn remove-logbook
|
||||
[content]
|
||||
(when (string? content)
|
||||
(let [lines (string/split-lines content)
|
||||
[result _in-logbook?]
|
||||
(reduce (fn [[acc in-logbook?] line]
|
||||
(let [trimmed (string/trim line)
|
||||
upper (string/upper-case trimmed)]
|
||||
(cond
|
||||
(string/starts-with? upper ":LOGBOOK:")
|
||||
[acc true]
|
||||
|
||||
(and in-logbook? (string/starts-with? upper ":END:"))
|
||||
[acc false]
|
||||
|
||||
in-logbook?
|
||||
[acc true]
|
||||
|
||||
:else
|
||||
[(conj acc line) in-logbook?])))
|
||||
[[] false]
|
||||
lines)]
|
||||
(string/join "\n" result))))
|
||||
|
||||
(defn remove-deadline-scheduled
|
||||
[content]
|
||||
(when (string? content)
|
||||
(let [lines (string/split-lines content)]
|
||||
(if (= 1 (count lines))
|
||||
content
|
||||
(let [first-line (first lines)
|
||||
rest-lines (rest lines)
|
||||
rest-lines (keep (fn [line]
|
||||
(let [upper (string/upper-case (string/triml line))]
|
||||
(if (or (string/starts-with? upper "DEADLINE: ")
|
||||
(string/starts-with? upper "SCHEDULED: "))
|
||||
(let [cleaned (-> line (string/replace #"(?i)(?:^|\s)(DEADLINE|SCHEDULED):\s+<[^>]*>" "") string/trim)]
|
||||
(when-not (string/blank? cleaned)
|
||||
cleaned))
|
||||
line)))
|
||||
rest-lines)]
|
||||
(string/join "\n" (cons first-line rest-lines)))))))
|
||||
@@ -0,0 +1,217 @@
|
||||
(ns logseq.graph-parser.schema.mldoc
|
||||
"Malli schema for mldoc AST")
|
||||
|
||||
(defn- field-optional-and-maybe-nil
|
||||
[k v]
|
||||
[k {:optional true} [:maybe v]])
|
||||
|
||||
(def pos-schema
|
||||
[:map
|
||||
[:start_pos :int]
|
||||
[:end_pos :int]])
|
||||
|
||||
(def nested-link-schema
|
||||
[:schema {:registry {::nested-link
|
||||
[:map
|
||||
[:content :string]
|
||||
[:children [:sequential [:or
|
||||
[:tuple [:= "Label"] :string]
|
||||
[:tuple [:= "Nested_link"] [:ref ::nested-link]]]]]]}}
|
||||
::nested-link])
|
||||
|
||||
(def timestamp-schema
|
||||
[:map
|
||||
[:date [:map
|
||||
[:year :int]
|
||||
[:month :int]
|
||||
[:day :int]]]
|
||||
[:wday :string]
|
||||
(field-optional-and-maybe-nil
|
||||
:time [:map
|
||||
[:hour :int]
|
||||
[:min :int]])
|
||||
(field-optional-and-maybe-nil
|
||||
:repetition
|
||||
:any)
|
||||
[:active :boolean]])
|
||||
|
||||
(def ^:private time-range-schema
|
||||
[:map
|
||||
[:start [:ref ::timestamp]]
|
||||
[:stop [:ref ::timestamp]]])
|
||||
|
||||
(def ^:private link-schema
|
||||
[:map
|
||||
[:url [:or
|
||||
[:cat [:= "File"] :string]
|
||||
[:cat [:= "Search"] :string]
|
||||
[:cat [:= "Complex"] [:map
|
||||
[:protocol :string]
|
||||
[:link :string]]]
|
||||
[:cat [:= "Page_ref"] :string]
|
||||
[:cat [:= "Block_ref"] :string]
|
||||
[:cat [:= "Embed_data"] :string]]]
|
||||
[:label [:sequential [:ref ::inline]]]
|
||||
(field-optional-and-maybe-nil :title :string)
|
||||
[:full_text :string]
|
||||
[:metadata :string]])
|
||||
|
||||
(def latex-fragment-schema
|
||||
[:or
|
||||
[:tuple [:= "Inline"] :string]
|
||||
[:tuple [:= "Displayed"] :string]])
|
||||
|
||||
(def inline-ast-schema
|
||||
[:schema {:registry {::timestamp timestamp-schema
|
||||
::time-range time-range-schema
|
||||
::link link-schema
|
||||
::inline
|
||||
[:or
|
||||
[:tuple [:= "Emphasis"]
|
||||
[:tuple
|
||||
[:tuple [:enum "Italic" "Bold" "Underline" "Strike_through" "Highlight"]]
|
||||
[:sequential [:ref ::inline]]]]
|
||||
|
||||
[:tuple [:= "Break_Line"]]
|
||||
[:tuple [:= "Hard_Break_Line"]]
|
||||
[:tuple [:= "Verbatim"] :string]
|
||||
[:tuple [:= "Code"] :string]
|
||||
[:tuple [:= "Tag"] [:sequential [:ref ::inline]]]
|
||||
[:tuple [:= "Spaces"] :string]
|
||||
[:tuple [:= "Plain"] :string]
|
||||
[:tuple [:= "Link"] [:ref ::link]]
|
||||
[:tuple [:= "Nested_link"] nested-link-schema]
|
||||
[:tuple [:= "Target"] :string]
|
||||
[:tuple [:= "Subscript"] [:sequential [:ref ::inline]]]
|
||||
[:tuple [:= "Superscript"] [:sequential [:ref ::inline]]]
|
||||
[:tuple [:= "Footnote_Reference"] [:map
|
||||
[:id :int]
|
||||
[:name :string]
|
||||
(field-optional-and-maybe-nil
|
||||
:definition [:sequential [:ref ::inline]])]]
|
||||
[:tuple [:= "Cookie"] [:or
|
||||
[:tuple [:= "Percent"] :int]
|
||||
[:catn [:label [:= "Absolute"]] [:current :int] [:total :int]]]]
|
||||
[:tuple [:= "Latex_Fragment"] latex-fragment-schema]
|
||||
[:tuple [:= "Macro"] [:map
|
||||
[:name :string]
|
||||
[:arguments [:sequential :string]]]]
|
||||
[:tuple [:= "Entity"] [:map
|
||||
[:name :string]
|
||||
[:latex :string]
|
||||
[:latex_mathp :boolean]
|
||||
[:html :string]
|
||||
[:ascii :string]
|
||||
[:unicode :string]]]
|
||||
[:tuple [:= "Timestamp"] [:or
|
||||
[:tuple [:= "Scheduled"] [:ref ::timestamp]]
|
||||
[:tuple [:= "Deadline"] [:ref ::timestamp]]
|
||||
[:tuple [:= "Date"] [:ref ::timestamp]]
|
||||
[:tuple [:= "Closed"] [:ref ::timestamp]]
|
||||
[:tuple [:= "Clock"] [:or
|
||||
[:tuple [:= "Started"] [:ref ::timestamp]]
|
||||
[:tuple [:= "Stopped"] [:ref ::time-range]]]]
|
||||
[:tuple [:= "Range"] [:ref ::time-range]]]]
|
||||
[:tuple [:= "Radio_Target"] :string]
|
||||
[:tuple [:= "Export_Snippet"] :string :string]
|
||||
[:tuple [:= "Inline_Source_Block"] [:map
|
||||
[:language :string]
|
||||
[:options :string]
|
||||
[:code :string]]]
|
||||
[:tuple [:= "Email"] [:map
|
||||
[:local_part :string]
|
||||
[:domain :string]]]
|
||||
[:tuple [:= "Inline_Hiccup"] :string]
|
||||
[:tuple [:= "Inline_Html"] :string]]}}
|
||||
::inline])
|
||||
|
||||
(def ^:private list-item-schema
|
||||
[:map
|
||||
[:content [:sequential [:ref ::block]]]
|
||||
[:items [:sequential [:ref ::list-item]]]
|
||||
(field-optional-and-maybe-nil
|
||||
:number :int)
|
||||
[:name [:sequential [:ref ::inline]]]
|
||||
(field-optional-and-maybe-nil
|
||||
:checkbox :boolean)
|
||||
[:indent :int]
|
||||
[:ordered :boolean]])
|
||||
|
||||
(def ^:private heading-schema
|
||||
[:map
|
||||
[:title [:sequential [:ref ::inline]]]
|
||||
[:tags [:sequential :string]]
|
||||
(field-optional-and-maybe-nil
|
||||
:marker :string)
|
||||
[:level :int]
|
||||
(field-optional-and-maybe-nil
|
||||
:numbering [:sequential :int])
|
||||
(field-optional-and-maybe-nil
|
||||
:priority :string)
|
||||
[:anchor :string]
|
||||
[:meta :map]
|
||||
(field-optional-and-maybe-nil
|
||||
:size :int)])
|
||||
|
||||
(def block-ast-schema
|
||||
[:schema {:registry {::inline inline-ast-schema
|
||||
::list-item list-item-schema
|
||||
::block
|
||||
[:or
|
||||
[:tuple [:= "Paragraph"] [:sequential [:ref ::inline]]]
|
||||
[:tuple [:= "Paragraph_Sep"] :int]
|
||||
[:tuple [:= "Heading"] heading-schema]
|
||||
[:tuple [:= "List"] [:sequential [:ref ::list-item]]]
|
||||
[:tuple [:= "Directive"] :string :string]
|
||||
[:tuple [:= "Results"]]
|
||||
[:tuple [:= "Example"] [:sequential :string]]
|
||||
[:tuple [:= "Src"] [:map
|
||||
[:lines [:sequential :string]]
|
||||
(field-optional-and-maybe-nil
|
||||
:language :string)
|
||||
(field-optional-and-maybe-nil
|
||||
:options [:sequential :string])
|
||||
[:pos_meta pos-schema]]]
|
||||
[:tuple [:= "Quote"] [:sequential [:ref ::block]]]
|
||||
[:catn
|
||||
[:label [:= "Export"]]
|
||||
[:type :string]
|
||||
[:options [:maybe [:sequential :string]]]
|
||||
[:content :string]]
|
||||
[:tuple [:= "CommentBlock"] [:sequential :string]]
|
||||
[:catn
|
||||
[:label [:= "Custom"]]
|
||||
[:type :string]
|
||||
[:options [:maybe :string]]
|
||||
[:result [:sequential [:ref ::block]]]
|
||||
[:content :string]]
|
||||
[:tuple [:= "Latex_Fragment"] latex-fragment-schema]
|
||||
[:catn
|
||||
[:label [:= "Latex_Environment"]]
|
||||
[:name :string]
|
||||
[:options [:maybe :string]]
|
||||
[:content :string]]
|
||||
[:tuple [:= "Displayed_Math"] :string]
|
||||
[:tuple [:= "Drawer"] :string [:sequential :string]]
|
||||
[:tuple [:= "Property_Drawer"]
|
||||
[:sequential
|
||||
[:catn [:k :string] [:v :string] [:other-info [:sequential [:ref ::inline]]]]]]
|
||||
[:tuple [:= "Footnote_Definition"] :string [:sequential [:ref ::inline]]]
|
||||
[:tuple [:= "Horizontal_Rule"]]
|
||||
[:tuple [:= "Table"]
|
||||
[:map
|
||||
(field-optional-and-maybe-nil
|
||||
:header [:sequential [:sequential [:ref ::inline]]])
|
||||
[:groups [:sequential [:sequential [:sequential [:sequential [:ref ::inline]]]]]]
|
||||
[:col_groups [:sequential :int]]]]
|
||||
[:tuple [:= "Comment"] :string]
|
||||
[:tuple [:= "Raw_Html"] :string]
|
||||
[:tuple [:= "Hiccup"] :string]
|
||||
|
||||
;; this block type is not from mldoc,
|
||||
;; but from `logseq.graph-parser.mldoc/collect-page-properties`
|
||||
[:tuple [:= "Properties"] [:sequential :any]]]}}
|
||||
::block])
|
||||
|
||||
(def block-ast-with-pos-coll-schema
|
||||
[:sequential [:cat block-ast-schema [:maybe pos-schema]]])
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
(ns logseq.graph-parser.text
|
||||
"Miscellaneous text util fns for the parser. Used by file and DB graphs"
|
||||
(:require ["path" :as node-path]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.namespace :as ns-util]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
[logseq.graph-parser.property :as gp-property]))
|
||||
|
||||
(def get-file-basename page-ref/get-file-basename)
|
||||
|
||||
(defn- get-file-rootname
|
||||
"Returns the rootname of a file path. e.g. /a/b/c.md -> c"
|
||||
[path]
|
||||
(when-not (string/blank? path)
|
||||
(.-name (node-path/parse (string/replace path "+" "/")))))
|
||||
|
||||
(defn get-page-name
|
||||
"Similar to page-ref/get-page-name but handles format-specific page-refs e.g. org/md"
|
||||
[s]
|
||||
(and (string? s)
|
||||
(or (when-let [[_ label _path] (re-matches page-ref/markdown-page-ref-re s)]
|
||||
(string/trim label))
|
||||
(when-let [[_ path _label] (re-matches #"\[\[(file:.*)\]\[.+?\]\]" s)]
|
||||
(some-> (get-file-rootname path)
|
||||
(string/replace "." "/")))
|
||||
(-> (re-matches page-ref/page-ref-any-re s)
|
||||
second))))
|
||||
|
||||
(def page-ref-un-brackets! page-ref/page-ref-un-brackets!)
|
||||
|
||||
(defn get-nested-page-name
|
||||
[page-name]
|
||||
(when-let [first-match (re-find page-ref/page-ref-without-nested-re page-name)]
|
||||
(second first-match)))
|
||||
|
||||
(defn- remove-level-space-aux!
|
||||
[text pattern space? trim-left?]
|
||||
(let [pattern (gstring/format
|
||||
(if space?
|
||||
"^[%s]+\\s+"
|
||||
"^[%s]+\\s?")
|
||||
pattern)
|
||||
text (if trim-left? (string/triml text) text)]
|
||||
(string/replace-first text (re-pattern pattern) "")))
|
||||
|
||||
(defn remove-level-spaces
|
||||
([text format block-pattern]
|
||||
(remove-level-spaces text format block-pattern false true))
|
||||
([text format block-pattern space?]
|
||||
(remove-level-spaces text format block-pattern space? true))
|
||||
([text format block-pattern space? trim-left?]
|
||||
(when format
|
||||
(cond
|
||||
(string/blank? text)
|
||||
""
|
||||
|
||||
(and (= "markdown" (name format))
|
||||
(string/starts-with? text "---"))
|
||||
text
|
||||
|
||||
:else
|
||||
(remove-level-space-aux! text block-pattern space? trim-left?)))))
|
||||
|
||||
(defn parse-non-string-property-value
|
||||
"Return parsed non-string property value or nil if none is found"
|
||||
[v]
|
||||
(cond
|
||||
(= v "true")
|
||||
true
|
||||
|
||||
(= v "false")
|
||||
false
|
||||
|
||||
(re-find #"^\d+$" v)
|
||||
(parse-long v)))
|
||||
|
||||
(defn- get-ref-from-ast
|
||||
[[typ data]]
|
||||
(case typ
|
||||
"Link"
|
||||
(case (first (:url data))
|
||||
"Page_ref"
|
||||
(second (:url data))
|
||||
|
||||
"Search"
|
||||
(second (:url data))
|
||||
|
||||
nil)
|
||||
|
||||
"Nested_link"
|
||||
(get-page-name (:content data))
|
||||
|
||||
"Tag"
|
||||
(if (= "Plain" (ffirst data))
|
||||
(second (first data))
|
||||
(get-ref-from-ast (first data)))
|
||||
|
||||
nil))
|
||||
|
||||
(defn extract-refs-from-mldoc-ast
|
||||
[v]
|
||||
(into #{}
|
||||
(comp
|
||||
(remove gp-mldoc/ast-link?)
|
||||
(keep get-ref-from-ast)
|
||||
(map string/trim))
|
||||
v))
|
||||
|
||||
(defn- sep-by-comma
|
||||
[s]
|
||||
{:pre (string? s)}
|
||||
(->>
|
||||
(string/split s #"[\,,]{1}")
|
||||
(map string/trim)
|
||||
(remove string/blank?)
|
||||
(set)))
|
||||
|
||||
(defn separated-by-commas?
|
||||
[config-state k]
|
||||
(let [k' (if (keyword? k) k (keyword k))]
|
||||
(contains? (set/union gp-property/editable-linkable-built-in-properties
|
||||
(set (get config-state :property/separated-by-commas)))
|
||||
k')))
|
||||
|
||||
(defn- extract-refs-by-commas
|
||||
[v format]
|
||||
(let [plains (->> (map first (gp-mldoc/->edn v (gp-mldoc/default-config format)))
|
||||
first
|
||||
second
|
||||
(filter #(and (vector? %) (= "Plain" (first %))))
|
||||
(map second))]
|
||||
(set (mapcat sep-by-comma plains))))
|
||||
|
||||
(defn- parse-property-refs [k v mldoc-references-ast config-state]
|
||||
(let [refs (extract-refs-from-mldoc-ast mldoc-references-ast)
|
||||
property-separated-by-commas? (separated-by-commas? config-state k)]
|
||||
(if property-separated-by-commas?
|
||||
(->> (extract-refs-by-commas v (get config-state :format :markdown))
|
||||
(set/union refs))
|
||||
refs)))
|
||||
|
||||
(defn parse-property
|
||||
"Property value parsing that takes into account built-in properties, format
|
||||
and user config"
|
||||
[k v mldoc-references-ast config-state]
|
||||
(let [v' (string/trim (str v))]
|
||||
(cond
|
||||
(contains? (set/union
|
||||
(set (map name (gp-property/unparsed-built-in-properties)))
|
||||
(get config-state :ignored-page-references-keywords))
|
||||
(name k))
|
||||
v'
|
||||
|
||||
(common-util/wrapped-by-quotes? v')
|
||||
v'
|
||||
|
||||
;; parse property value as needed
|
||||
:else
|
||||
(let [refs (parse-property-refs k v' mldoc-references-ast config-state)]
|
||||
(if (seq refs)
|
||||
refs
|
||||
(if-some [new-val (parse-non-string-property-value v')]
|
||||
new-val
|
||||
v'))))))
|
||||
|
||||
(def namespace-page? ns-util/namespace-page?)
|
||||
(def get-namespace-last-part ns-util/get-last-part)
|
||||
@@ -0,0 +1,24 @@
|
||||
(ns logseq.graph-parser.utf8
|
||||
"Utf8 utilities used by the parser")
|
||||
|
||||
(defonce encoder
|
||||
(js/TextEncoder. "utf-8"))
|
||||
|
||||
(defonce decoder
|
||||
(js/TextDecoder. "utf-8"))
|
||||
|
||||
(defn encode
|
||||
[s]
|
||||
(.encode encoder s))
|
||||
|
||||
(defn decode
|
||||
[arr]
|
||||
(.decode decoder arr))
|
||||
|
||||
(defn substring
|
||||
([arr start]
|
||||
(decode (.subarray arr start)))
|
||||
([arr start end]
|
||||
(if end
|
||||
(decode (.subarray arr start end))
|
||||
(decode (.subarray arr start)))))
|
||||
@@ -0,0 +1,171 @@
|
||||
(ns logseq.graph-parser.block-test
|
||||
(:require [cljs.test :refer [deftest are testing is]]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db.test.helper :as db-test]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]))
|
||||
|
||||
(defn- extract-properties
|
||||
[properties user-config]
|
||||
(gp-block/extract-properties
|
||||
(map
|
||||
(fn [[k v]]
|
||||
(let [mldoc-ast (gp-mldoc/get-references v (gp-mldoc/default-config :markdown))]
|
||||
[k v mldoc-ast]))
|
||||
properties)
|
||||
user-config))
|
||||
|
||||
(deftest test-fix-duplicate-id
|
||||
(are [x y]
|
||||
(let [result (gp-block/fix-duplicate-id (gp-block/block-keywordize x))]
|
||||
(and (:block/uuid result)
|
||||
(not= (:uuid x) (:block/uuid result))
|
||||
(= (select-keys result
|
||||
[:block/properties :block/title :block/properties-text-values :block/properties-order]) (gp-block/block-keywordize y))))
|
||||
{:properties {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :tags [], :format :markdown, :meta {:start_pos 51, :end_pos 101}, :macros [], :title "bar\nid:: 63f199bc-c737-459f-983d-84acfcda14fe", :properties-text-values {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :level 1, :uuid #uuid "63f199bc-c737-459f-983d-84acfcda14fe", :properties-order [:id]}
|
||||
{:properties {},
|
||||
:title "bar",
|
||||
:properties-text-values {},
|
||||
:properties-order []}
|
||||
|
||||
{:properties {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :tags [], :format :org, :meta {:start_pos 51, :end_pos 101}, :macros [], :title "bar\n:id: 63f199bc-c737-459f-983d-84acfcda14fe", :properties-text-values {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :level 1, :uuid #uuid "63f199bc-c737-459f-983d-84acfcda14fe", :properties-order [:id]}
|
||||
{:properties {},
|
||||
:title "bar",
|
||||
:properties-text-values {},
|
||||
:properties-order []}
|
||||
|
||||
{:properties {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :tags [], :format :markdown, :meta {:start_pos 51, :end_pos 101}, :macros [], :title "bar\n \n id:: 63f199bc-c737-459f-983d-84acfcda14fe\nblock body", :properties-text-values {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :level 1, :uuid #uuid "63f199bc-c737-459f-983d-84acfcda14fe", :properties-order [:id]}
|
||||
{:properties {},
|
||||
:title "bar\nblock body",
|
||||
:properties-text-values {},
|
||||
:properties-order []}))
|
||||
|
||||
(deftest test-extract-properties
|
||||
(are [x y] (= (:properties (extract-properties x {})) y)
|
||||
;; Built-in properties
|
||||
[["background-color" "#000000"]] {:background-color "#000000"}
|
||||
[["alias" "[[name/with space]]"]] {:alias #{"name/with space"}}
|
||||
[["tags" "[[foo]], [[bar]]"]] {:tags #{"foo" "bar"}}
|
||||
[["tags" "[[foo]] [[bar]]"]] {:tags #{"foo" "bar"}}
|
||||
[["tags" "bar"]] {:tags #{"bar"}}
|
||||
[["file-path" "file:///home/x, y.pdf"]] {:file-path "file:///home/x, y.pdf"}
|
||||
|
||||
;; User properties
|
||||
[["year" "1000"]] {:year 1000}
|
||||
[["year" "\"1000\""]] {:year "\"1000\""}
|
||||
[["year" "1000"] ["alias" "[[name/with space]]"]] {:year 1000, :alias #{"name/with space"}}
|
||||
[["year" "1000"] ["tags" "[[name/with space]]"]] {:year 1000, :tags #{"name/with space"}}
|
||||
[["year" "1000"] ["tags" "[[name/with space]], [[another]]"]] {:year 1000, :tags #{"name/with space" "another"}}
|
||||
[["year" "1000"] ["alias" "[[name/with space]], [[another]]"]] {:year 1000, :alias #{"name/with space" "another"}}
|
||||
[["year" "1000"] ["alias" "[[name/with space]], [[another [[nested]]]]"]] {:year 1000, :alias #{"name/with space" "another [[nested]]"}}
|
||||
[["year" "1000"] ["alias" "[[name/with space]], [[[[nested]] another]]"]] {:year 1000, :alias #{"name/with space" "[[nested]] another"}}
|
||||
[["foo" "bar"]] {:foo "bar"}
|
||||
[["foo" "[[bar]], [[baz]]"]] {:foo #{"bar" "baz"}}
|
||||
[["foo" "[[bar]], [[baz]]"]] {:foo #{"bar" "baz"}}
|
||||
[["foo" "[[bar]], [[baz]]"]] {:foo #{"bar" "baz"}}
|
||||
[["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
|
||||
[["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
|
||||
[["foo" "[[bar]], [[baz, test]]"]] {:foo #{"bar" "baz, test"}}
|
||||
[["foo" "[[bar]], [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}})
|
||||
|
||||
(testing "page-refs"
|
||||
(are [x y] (= (vec (:page-refs
|
||||
(extract-properties x {:property-pages/enabled? true}))) y)
|
||||
[["year" "1000"]] ["year"]
|
||||
[["year" "\"1000\""]] ["year"]
|
||||
[["year" "1000"] ["month" "12"]] ["year" "month"]
|
||||
[["foo" "[[bar]] test"]] ["bar" "foo"]
|
||||
[["foo" "[[bar]] test [[baz]]"]] ["bar" "baz" "foo"]
|
||||
[["foo" "[[bar]] test [[baz]] [[nested [[baz]]]]"]] ["bar" "baz" "nested [[baz]]" "foo"]
|
||||
[["foo" "#bar, #baz"]] ["bar" "baz" "foo"]
|
||||
[["foo" "[[nested [[page]]]], test"]] ["nested [[page]]" "foo"])
|
||||
|
||||
(are [x y] (= (vec (:page-refs
|
||||
(extract-properties x {:property-pages/enabled? false}))) y)
|
||||
[["year" "1000"]] []
|
||||
[["year" "1000"] ["month" "12"]] []
|
||||
[["foo" "[[bar]] test"]] ["bar"])
|
||||
|
||||
(is (= ["year"]
|
||||
(:page-refs
|
||||
(extract-properties [["year" "1000"] ["month" "12"]]
|
||||
{:property-pages/enabled? true
|
||||
:property-pages/excludelist #{:month :day}})))
|
||||
":property-pages/exclude-list excludes specified properties")
|
||||
|
||||
(is (= ["year"]
|
||||
(:page-refs
|
||||
(extract-properties [["year" "1000"]]
|
||||
{})))
|
||||
"Default to enabled when :property-pages/enabled? is not in config")
|
||||
|
||||
(is (= ["foo" "bar" "tags"]
|
||||
(:page-refs
|
||||
(extract-properties
|
||||
;; tags is linkable and background-color is not
|
||||
[["tags" "[[foo]], [[bar]]"] ["background-color" "#008000"]]
|
||||
{:property-pages/enabled? true})))
|
||||
"Only editable linkable built-in properties have page-refs in property values")))
|
||||
|
||||
(deftest test-page-name-map-namespace-for-slash-journals
|
||||
(testing "slash-formatted journals do not keep namespace metadata"
|
||||
(let [journal (gp-block/page-name->map "2026/05/18" nil false "yyyy/MM/dd")]
|
||||
(is (= 20260518 (:block/journal-day journal)))
|
||||
(is (= "2026/05/18" (:block/title journal)))
|
||||
(is (= "may 18th, 2026" (:block/name journal)))
|
||||
(is (= (common-uuid/gen-uuid :journal-page-uuid 20260518)
|
||||
(:block/uuid journal)))
|
||||
(is (nil? (:block/namespace journal)))))
|
||||
(testing "non-journal slash pages keep namespace metadata"
|
||||
(is (= {:block/name "project"}
|
||||
(:block/namespace (gp-block/page-name->map "project/child" nil false "yyyy/MM/dd"))))))
|
||||
|
||||
(deftest existing-journal-reference-reuses-stored-identity-test
|
||||
(testing "a legacy journal name is not rewritten while parsing a reference"
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:pages-and-blocks [{:page {:build/journal 20260727}}]})
|
||||
journal (db-test/find-journal-by-journal-day @conn 20260727)
|
||||
journal-uuid (:block/uuid journal)]
|
||||
(d/transact! conn [[:db/add :logseq.class/Journal
|
||||
:logseq.property.journal/title-format "yyyy-MM-dd"]
|
||||
{:db/id (:db/id journal)
|
||||
:block/title "2026-07-27"
|
||||
:block/name "2026-07-27"}])
|
||||
(let [reference (gp-block/page-name->map "2026-07-27" @conn false "yyyy-MM-dd")]
|
||||
(is (= {:block/uuid journal-uuid
|
||||
:block/title "2026-07-27"
|
||||
:block/name "2026-07-27"
|
||||
:block/journal-day 20260727}
|
||||
(select-keys reference
|
||||
[:block/uuid :block/title :block/name :block/journal-day]))))))
|
||||
|
||||
(testing "an existing journal is found by day after the configured format changes"
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:pages-and-blocks [{:page {:build/journal 20260727}}]})
|
||||
journal (db-test/find-journal-by-journal-day @conn 20260727)
|
||||
journal-uuid (:block/uuid journal)]
|
||||
(d/transact! conn [[:db/add :logseq.class/Journal
|
||||
:logseq.property.journal/title-format "yyyy-MM-dd"]
|
||||
{:db/id (:db/id journal)
|
||||
:block/title "2026-07-27"
|
||||
:block/name "2026-07-27"}])
|
||||
(d/transact! conn [[:db/add :logseq.class/Journal
|
||||
:logseq.property.journal/title-format "dd/MM/yyyy"]])
|
||||
(let [reference (gp-block/page-name->map "27/07/2026" @conn false "dd/MM/yyyy")]
|
||||
(is (= {:block/uuid journal-uuid
|
||||
:block/title "2026-07-27"
|
||||
:block/name "2026-07-27"
|
||||
:block/journal-day 20260727}
|
||||
(select-keys reference
|
||||
[:block/uuid :block/title :block/name :block/journal-day])))))))
|
||||
|
||||
(defn find-block-for-content
|
||||
[db content]
|
||||
(->> (d/q '[:find (pull ?b [* {:block/refs [:block/uuid]}])
|
||||
:in $ ?content
|
||||
:where [?b :block/title ?content]]
|
||||
db
|
||||
content)
|
||||
(map first)
|
||||
first))
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,131 @@
|
||||
(ns logseq.graph-parser.extract-test
|
||||
(:require [cljs.test :refer [deftest is are]]
|
||||
[datascript.core :as d]
|
||||
[logseq.graph-parser.extract :as extract]))
|
||||
|
||||
;; This is a copy of frontend.components.repo/multiplatform-reserved-chars for reserved chars testing
|
||||
(def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")
|
||||
|
||||
;; Stuffs should be parsable (don't crash) when users dump some random files
|
||||
(deftest page-name-parsing-tests
|
||||
(is (string? (#'extract/tri-lb-title-parsing "___-_-_-_---___----")))
|
||||
(is (string? (#'extract/tri-lb-title-parsing "_____///____---___----")))
|
||||
(is (string? (#'extract/tri-lb-title-parsing "/_/////---/_----")))
|
||||
(is (string? (#'extract/tri-lb-title-parsing "/\\#*%lasdf\\//__--dsll_____----....-._0x2B")))
|
||||
(is (string? (#'extract/tri-lb-title-parsing "/\\#*%l;;&&;&\\//__--dsll_____----....-._0x2B")))
|
||||
(is (string? (#'extract/tri-lb-title-parsing multiplatform-reserved-chars)))
|
||||
(is (string? (#'extract/tri-lb-title-parsing "dsa&;l dsalfjk jkl"))))
|
||||
|
||||
(deftest uri-decoding-tests
|
||||
(is (= (#'extract/safe-url-decode "%*-sd%%%saf%=lks") "%*-sd%%%saf%=lks")) ;; Contains %, but invalid
|
||||
(is (= (#'extract/safe-url-decode "%2FDownloads%2FCNN%3AIs%5CAll%3AYou%20Need.pdf") "/Downloads/CNN:Is\\All:You Need.pdf"))
|
||||
(is (= (#'extract/safe-url-decode "asldkflksdaf啦放假啦睡觉啦啊啥的都撒娇浪费;dla") "asldkflksdaf啦放假啦睡觉啦啊啥的都撒娇浪费;dla")))
|
||||
|
||||
(deftest page-name-sanitization-backward-tests
|
||||
(is (= "abc.def.ghi.jkl" (#'extract/tri-lb-title-parsing "abc.def.ghi.jkl")))
|
||||
(is (= "abc/def/ghi/jkl" (#'extract/tri-lb-title-parsing "abc%2Fdef%2Fghi%2Fjkl")))
|
||||
(is (= "abc%/def/ghi/jkl" (#'extract/tri-lb-title-parsing "abc%25%2Fdef%2Fghi%2Fjkl")))
|
||||
(is (= "abc%2——ef/ghi/jkl" (#'extract/tri-lb-title-parsing "abc%2——ef%2Fghi%2Fjkl")))
|
||||
(is (= "abc&2Fghi/jkl" (#'extract/tri-lb-title-parsing "abc&2Fghi%2Fjkl")))
|
||||
(is (= "abc<2Fghi/jkl" (#'extract/tri-lb-title-parsing "abc<2Fghi%2Fjkl")))
|
||||
(is (= "abc%2Fghi/jkl" (#'extract/tri-lb-title-parsing "abc%2Fghi%2Fjkl")))
|
||||
(is (= "abc;&;2Fghi/jkl" (#'extract/tri-lb-title-parsing "abc;&;2Fghi%2Fjkl")))
|
||||
;; happens when importing some compatible files on *nix / macOS
|
||||
(is (= multiplatform-reserved-chars (#'extract/tri-lb-title-parsing multiplatform-reserved-chars))))
|
||||
|
||||
(deftest path-utils-tests
|
||||
(is (= "asldk lakls " (#'extract/path->file-body "/data/app/asldk lakls .lsad")))
|
||||
(is (= "asldk lakls " (#'extract/path->file-body "asldk lakls .lsad")))
|
||||
(is (= "asldk lakls" (#'extract/path->file-body "asldk lakls")))
|
||||
(is (= "asldk lakls" (#'extract/path->file-body "/data/app/asldk lakls")))
|
||||
(is (= "asldk lakls" (#'extract/path->file-body "file://data/app/asldk lakls.as")))
|
||||
(is (= "中文asldk lakls" (#'extract/path->file-body "file://中文data/app/中文asldk lakls.as"))))
|
||||
|
||||
;; Bare minimum schema to test extract
|
||||
(def file-schema
|
||||
{:block/uuid {:db/unique :db.unique/identity}
|
||||
:block/name {:db/unique :db.unique/identity}})
|
||||
|
||||
(defn- extract [file content & [options]]
|
||||
(extract/extract file
|
||||
content
|
||||
(merge {:block-pattern "-" :db (d/empty-db file-schema)
|
||||
:verbose false}
|
||||
options)))
|
||||
|
||||
(defn- extract-block-content
|
||||
[text]
|
||||
(let [{:keys [blocks]} (extract "a.md" text)]
|
||||
(mapv :block/title blocks)))
|
||||
|
||||
(defn- extract-title [file text]
|
||||
(-> (extract file text) :pages first :block/properties :title))
|
||||
|
||||
(deftest extract-blocks-for-headings
|
||||
(is (= ["a" "b" "c"]
|
||||
(extract-block-content
|
||||
"- a
|
||||
- b
|
||||
- c")))
|
||||
|
||||
(is (= ["## hello" "world" "nice" "nice" "bingo" "world"]
|
||||
(extract-block-content "## hello
|
||||
- world
|
||||
- nice
|
||||
- nice
|
||||
- bingo
|
||||
- world")))
|
||||
|
||||
(is (= ["# a" "## b" "### c" "#### d" "### e" "f" "g" "h" "i" "j"]
|
||||
(extract-block-content "# a
|
||||
## b
|
||||
### c
|
||||
#### d
|
||||
### e
|
||||
- f
|
||||
- g
|
||||
- h
|
||||
- i
|
||||
- j"))))
|
||||
|
||||
(deftest parse-page-title
|
||||
(is (= nil
|
||||
(extract-title "foo.org" "")))
|
||||
(is (= "Howdy"
|
||||
(extract-title "foo.org" "#+title: Howdy")))
|
||||
(is (= "Howdy"
|
||||
(extract-title "foo.org" "#+TITLE: Howdy")))
|
||||
(is (= "Howdy"
|
||||
(extract-title "foo.org" "#+TiTlE: Howdy")))
|
||||
(is (= "diagram/abcdef"
|
||||
(extract-title "foo.org" ":PROPERTIES:
|
||||
:ID: 72289d9a-eb2f-427b-ad97-b605a4b8c59b
|
||||
:END:
|
||||
#+TITLE: diagram/abcdef")))
|
||||
(is (= "diagram/abcdef"
|
||||
(extract-title "foo.org" ":PROPERTIES:
|
||||
:ID: 72289d9a-eb2f-427b-ad97-b605a4b8c59b
|
||||
:END:
|
||||
#+title: diagram/abcdef"))))
|
||||
|
||||
(deftest extract-blocks-with-property-pages-config
|
||||
(are [extract-args expected-refs]
|
||||
(= expected-refs
|
||||
(->> (apply extract extract-args)
|
||||
:blocks
|
||||
(mapcat #(->> % :block/refs (map :block/name)))
|
||||
set))
|
||||
|
||||
["a.md" "foo:: #bar\nbaz:: #bing" {:user-config {:property-pages/enabled? true}}]
|
||||
#{"bar" "bing" "foo" "baz"}
|
||||
|
||||
["a.md" "foo:: #bar\nbaz:: #bing" {:user-config {:property-pages/enabled? false}}]
|
||||
#{"bar" "bing"}))
|
||||
|
||||
(deftest test-regression-1902
|
||||
(is (= ["line1" "line2" "line3" "line4"]
|
||||
(extract-block-content
|
||||
"- line1
|
||||
- line2
|
||||
- line3
|
||||
- line4"))))
|
||||
@@ -0,0 +1,150 @@
|
||||
(ns logseq.graph-parser.mldoc-test
|
||||
(:require [cljs.test :refer [testing deftest are is]]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
[logseq.graph-parser.text :as text]))
|
||||
|
||||
(def md-config (gp-mldoc/default-config :markdown))
|
||||
|
||||
(deftest src-test
|
||||
(is (= [["Src"
|
||||
{:lines [": hello" "\n"],
|
||||
:pos_meta {:start_pos 4, :end_pos 12},
|
||||
:full_content "```\n: hello\n```"}]
|
||||
{:start_pos 0, :end_pos 15}]
|
||||
(first (gp-mldoc/->edn "```
|
||||
: hello
|
||||
```" md-config)))
|
||||
"Basic src example")
|
||||
|
||||
(is (= [["Src"
|
||||
{:lines [" hello" "\n" " world" "\n"],
|
||||
:pos_meta {:start_pos 7, :end_pos 25},
|
||||
:full_content "```\nhello\nworld\n```"}]
|
||||
{:start_pos 1, :end_pos 29}]
|
||||
(second (gp-mldoc/->edn "
|
||||
```
|
||||
hello
|
||||
world
|
||||
```
|
||||
" md-config)))
|
||||
"Src example with leading whitespace"))
|
||||
|
||||
(defn- get-properties
|
||||
[x]
|
||||
(->> (gp-mldoc/->edn x md-config)
|
||||
ffirst second
|
||||
(map (fn [[k v ast]]
|
||||
[(keyword k) (text/parse-property k v ast {})]))
|
||||
(into {})))
|
||||
|
||||
(deftest md-properties-test
|
||||
(are [x y] (= y (get-properties x))
|
||||
|
||||
;; reference values
|
||||
"property:: [[foo]], [[bar]]"
|
||||
{:property #{"foo" "bar"}}
|
||||
|
||||
;; comma separated
|
||||
"tags:: foo, bar, foo"
|
||||
{:tags #{"foo" "bar"}}))
|
||||
|
||||
(deftest name-definition-test
|
||||
(is (= [["List"
|
||||
[{:content [["Paragraph" [["Plain" "definition"]]]],
|
||||
:items [],
|
||||
:name [["Plain" "term"]],
|
||||
:indent 0,
|
||||
:ordered false}]]
|
||||
{:start_pos 0, :end_pos 17}]
|
||||
(first (gp-mldoc/->edn "term
|
||||
: definition" md-config)))))
|
||||
|
||||
(deftest macro-with-script-markup-test
|
||||
(testing "inline macros can contain superscript and subscript markup"
|
||||
(are [content ast] (= ast (gp-mldoc/inline->edn content md-config))
|
||||
"{{cloze Ca^{ +2} ions}}"
|
||||
[["Macro" {:name "cloze" :arguments ["Ca^{ +2} ions"]}]]
|
||||
|
||||
"{{cloze H_{2}O}}"
|
||||
[["Macro" {:name "cloze" :arguments ["H_{2}O"]}]]
|
||||
|
||||
"{{cloze Ca^{+2}}}"
|
||||
[["Macro" {:name "cloze" :arguments ["Ca^{+2}"]}]]
|
||||
|
||||
"{{foo Ca^{ +2} ions, [[a, b]], \"c, d\"}}"
|
||||
[["Macro" {:name "foo" :arguments ["Ca^{ +2} ions" "[[a, b]]" "\"c, d\""]}]]
|
||||
|
||||
;; page ref inside a macro that also has script markup — exercises
|
||||
;; the Nested_link case in inline-ast->source
|
||||
"{{cloze Ca^{ +2} [[water]]}}"
|
||||
[["Macro" {:name "cloze" :arguments ["Ca^{ +2} [[water]]"]}]]))
|
||||
|
||||
(testing "normal macros without script markup are not modified"
|
||||
(are [content ast] (= ast (gp-mldoc/inline->edn content md-config))
|
||||
"{{cloze simple text}}"
|
||||
[["Macro" {:name "cloze" :arguments ["simple text"]}]]
|
||||
|
||||
"{{foo a, b, c}}"
|
||||
[["Macro" {:name "foo" :arguments ["a" "b" "c"]}]]
|
||||
|
||||
"{{cloze [[page name]]}}"
|
||||
[["Macro" {:name "cloze" :arguments ["[[page name]]"]}]]))
|
||||
|
||||
(testing "block parsing keeps the issue reproduction as macro nodes"
|
||||
(is (= [["Plain" "This is usually highlighted by the accumulation of the "]
|
||||
["Macro" {:name "cloze" :arguments ["Ca^{ +2} ions"]}]
|
||||
["Plain" " . This will be seen as "]
|
||||
["Macro" {:name "cloze" :arguments ["<ins>large flocculent amorphous densities in TEM</ins>"]}]]
|
||||
(-> (gp-mldoc/->edn
|
||||
"- This is usually highlighted by the accumulation of the {{cloze Ca^{ +2} ions}} . This will be seen as {{cloze <ins>large flocculent amorphous densities in TEM</ins>}}"
|
||||
md-config)
|
||||
ffirst
|
||||
second
|
||||
:title)))
|
||||
|
||||
(is (= [["Plain" "Water formula is "]
|
||||
["Macro" {:name "cloze" :arguments ["H_{2}O"]}]]
|
||||
(-> (gp-mldoc/->edn
|
||||
"- Water formula is {{cloze H_{2}O}}"
|
||||
md-config)
|
||||
ffirst
|
||||
second
|
||||
:title)))))
|
||||
|
||||
(defn- parse-properties
|
||||
[text]
|
||||
(->> (gp-mldoc/->edn text (gp-mldoc/default-config :org))
|
||||
(filter #(= "Properties" (ffirst %)))
|
||||
ffirst
|
||||
second))
|
||||
|
||||
(deftest org-properties-test
|
||||
(testing "just title"
|
||||
(let [content "#+TITLE: some title "
|
||||
props (parse-properties content)]
|
||||
(is (= "some title " (second (first props))))))
|
||||
|
||||
(testing "filetags"
|
||||
(let [content "#+FILETAGS: :tag1:tag2:@tag:
|
||||
#+TAGS: tag3
|
||||
body"
|
||||
props (parse-properties content)]
|
||||
(is ["@tag" "tag1" "tag2"] (sort (:filetags props)))
|
||||
(is ["@tag" "tag1" "tag2" "tag3"] (sort (:tags props))))))
|
||||
|
||||
(deftest remove-indentation-spaces
|
||||
(testing "Remove indentations for every line"
|
||||
(is (= "block 1.1\n line 1\n line 2\nline 3\nline 4"
|
||||
(let [s "block 1.1
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4"]
|
||||
(gp-mldoc/remove-indentation-spaces s 2 false))))
|
||||
(is (= "\t- block 1.1\n line 1\n line 2\nline 3\nline 4"
|
||||
(let [s "\t- block 1.1
|
||||
\t line 1
|
||||
\t line 2
|
||||
\t line 3
|
||||
\tline 4"]
|
||||
(gp-mldoc/remove-indentation-spaces s 3 false))))))
|
||||
@@ -0,0 +1,62 @@
|
||||
(ns logseq.graph-parser.property-test
|
||||
(:require [cljs.test :refer [are deftest testing]]
|
||||
[logseq.graph-parser.property :as gp-property]))
|
||||
|
||||
(def test-db "test-db")
|
||||
|
||||
(deftest test->new-properties
|
||||
(are [x y] (= (gp-property/->new-properties x) y)
|
||||
":PROPERTIES:\n:foo: bar\n:END:"
|
||||
"foo:: bar"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:END:"
|
||||
"hello\nfoo:: bar"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:nice: bingo\n:END:"
|
||||
"hello\nfoo:: bar\nnice:: bingo"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:nice: bingo\n:END:"
|
||||
"hello\nfoo:: bar\nnice:: bingo"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:nice: bingo\n:END:\nnice"
|
||||
"hello\nfoo:: bar\nnice:: bingo\nnice"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:nice:\n:END:\nnice"
|
||||
"hello\nfoo:: bar\nnice:: \nnice"
|
||||
|
||||
"hello\n:PROPERTIES:\n:foo: bar\n:nice\n:END:\nnice"
|
||||
"hello\nfoo:: bar\n:nice\nnice"))
|
||||
|
||||
(deftest test-remove-properties
|
||||
(testing "properties with non-blank lines"
|
||||
(are [x y] (= x y)
|
||||
(gp-property/remove-properties :org "** hello\n:PROPERTIES:\n:x: y\n:END:\n")
|
||||
"** hello"
|
||||
|
||||
(gp-property/remove-properties :org "** hello\n:PROPERTIES:\n:x: y\na:b\n:END:\n")
|
||||
"** hello"
|
||||
|
||||
(gp-property/remove-properties :markdown "** hello\nx:: y\na:: b\n")
|
||||
"** hello"
|
||||
|
||||
(gp-property/remove-properties :markdown "** hello\nx:: y\na::b\n")
|
||||
"** hello"))
|
||||
|
||||
(testing "properties with blank lines"
|
||||
(are [x y] (= x y)
|
||||
(gp-property/remove-properties :org "** hello\n:PROPERTIES:\n\n:x: y\n:END:\n")
|
||||
"** hello"
|
||||
|
||||
(gp-property/remove-properties :org "** hello\n:PROPERTIES:\n:x: y\n\na:b\n:END:\n")
|
||||
"** hello"))
|
||||
|
||||
(testing "invalid-properties"
|
||||
(are [x y] (= x y)
|
||||
(gp-property/remove-properties :markdown "hello\nnice\nfoo:: bar")
|
||||
"hello\nnice\nfoo:: bar"
|
||||
|
||||
(gp-property/remove-properties :markdown "hello\nnice\nfoo:: bar\ntest")
|
||||
"hello\nnice\nfoo:: bar\ntest"
|
||||
|
||||
(gp-property/remove-properties :markdown "** hello\nx:: y\n\na:: b\n")
|
||||
"** hello\n\na:: b")))
|
||||
@@ -0,0 +1,20 @@
|
||||
(ns logseq.graph-parser.test.docs-graph-helper
|
||||
"Helper fns for setting up and running tests against docs graph"
|
||||
(:require ["child_process" :as child-process]
|
||||
["fs" :as fs]))
|
||||
|
||||
;; Helper fns for test setup
|
||||
;; =========================
|
||||
(defn- sh
|
||||
"Run shell cmd synchronously and print to inherited streams by default. Aims
|
||||
to be similar to babashka.tasks/shell"
|
||||
[cmd opts]
|
||||
(child-process/spawnSync (first cmd)
|
||||
(clj->js (rest cmd))
|
||||
(clj->js (merge {:stdio "inherit"} opts))))
|
||||
|
||||
(defn clone-docs-repo-if-not-exists
|
||||
[dir branch]
|
||||
(when-not (.existsSync fs dir)
|
||||
(sh ["git" "clone" "--depth" "1" "-b" branch "-c" "advice.detachedHead=false"
|
||||
"https://github.com/logseq/docs" dir] {})))
|
||||
@@ -0,0 +1,25 @@
|
||||
(ns logseq.graph-parser.test.helper)
|
||||
|
||||
;; Copied from https://github.com/babashka/nbb/blob/e5d84b0fac59774f5d7a4a9e807240cce04bf252/test/nbb/test_macros.clj
|
||||
(defmacro deftest-async
|
||||
"A wrapper around deftest that handles async and done in all cases.
|
||||
Importantly, it prevents unexpected failures in an async test from abruptly
|
||||
ending a test suite"
|
||||
[name opts & body]
|
||||
(let [[opts body]
|
||||
(if (map? opts)
|
||||
[opts body]
|
||||
[nil (cons opts body)])]
|
||||
`(cljs.test/deftest ~name
|
||||
~@(when-let [pre (:before opts)]
|
||||
[pre])
|
||||
(cljs.test/async
|
||||
~'done
|
||||
(-> (do ~@body)
|
||||
(.catch (fn [err#]
|
||||
(cljs.test/is (= 1 0) (str err# (.-stack err#)))))
|
||||
(.finally
|
||||
(fn []
|
||||
~@(when-let [post (:after opts)]
|
||||
[post])
|
||||
(~'done))))))))
|
||||
@@ -0,0 +1,6 @@
|
||||
(ns logseq.graph-parser.test-runner
|
||||
"Test runner which enables https://github.com/PEZ/baldr by default"
|
||||
(:require [nextjournal.test-runner :as next-runner]
|
||||
[pez.baldr]))
|
||||
|
||||
(def -main next-runner/-main)
|
||||
@@ -0,0 +1,117 @@
|
||||
(ns logseq.graph-parser.text-test
|
||||
(:require [cljs.test :refer [are deftest testing]]
|
||||
[logseq.graph-parser.text :as text]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]))
|
||||
|
||||
(deftest test-get-page-name
|
||||
(are [x y] (= (text/get-page-name x) y)
|
||||
"[[page]]" "page"
|
||||
"[[another page]]" "another page"
|
||||
"[single bracket]" nil
|
||||
"no brackets" nil
|
||||
|
||||
"[[another page]]" "another page"
|
||||
"[[nested [[page]]]]" "nested [[page]]"
|
||||
|
||||
"[[file:./page.org][page]]" "page"
|
||||
"[[file:./pages/page.org][page]]" "page"
|
||||
|
||||
"[[file:./namespace.page.org][namespace/page]]" "namespace/page"
|
||||
"[[file:./pages/namespace.page.org][namespace/page]]" "namespace/page"
|
||||
"[[file:./pages/namespace.page.org][please don't change me]]" "namespace/page"
|
||||
|
||||
"[page](file:./page.md)" "page"
|
||||
"[page](file:.pages/page.md)" "page"
|
||||
|
||||
"[logseq/page](file:./logseq.page.md)" "logseq/page"
|
||||
"[logseq/page](file:./pages/logseq.page.md)" "logseq/page"))
|
||||
|
||||
(deftest page-ref-un-brackets!
|
||||
(are [x y] (= (text/page-ref-un-brackets! x) y)
|
||||
"[[page]]" "page"
|
||||
"[[another page]]" "another page"
|
||||
"[[nested [[page]]]]" "nested [[page]]"
|
||||
"[single bracket]" "[single bracket]"
|
||||
"no brackets" "no brackets"))
|
||||
|
||||
(def block-patterns
|
||||
{:markdown "-"
|
||||
:org "*"})
|
||||
|
||||
(deftest remove-level-spaces
|
||||
(testing "markdown"
|
||||
(are [x y] (= (text/remove-level-spaces x :markdown (block-patterns :markdown) true) y)
|
||||
"- foobar" "foobar"
|
||||
" - foobar" "foobar"))
|
||||
(testing "markdown without spaces between the `#` and title"
|
||||
(are [x y] (= (text/remove-level-spaces x :markdown (block-patterns :markdown)) y)
|
||||
"-foobar" "foobar"))
|
||||
(testing "org"
|
||||
(are [x y] (= (text/remove-level-spaces x :org (block-patterns :org) true) y)
|
||||
"* foobar" "foobar"
|
||||
"** foobar" "foobar"
|
||||
"********************* foobar" "foobar"))
|
||||
(testing "org without spaces between the `#` and title"
|
||||
(are [x y] (= (text/remove-level-spaces x :org (block-patterns :org)) y)
|
||||
"*foobar" "foobar"
|
||||
"**foobar" "foobar"
|
||||
"*********************foobar" "foobar")))
|
||||
|
||||
(defn- parse-property
|
||||
[k v user-config]
|
||||
(let [references (gp-mldoc/get-references v (gp-mldoc/default-config :markdown))]
|
||||
(text/parse-property k v references user-config)))
|
||||
|
||||
(deftest test-parse-property
|
||||
(testing "for default comma separated properties"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:tags "foo" #{"foo"}
|
||||
:tags "comma, separated" #{"comma" "separated"}
|
||||
:alias "one, two, one" #{"one" "two"}))
|
||||
|
||||
(testing "for user comma separated properties"
|
||||
(are [k v y] (= (parse-property k v {:property/separated-by-commas #{:comma-prop}}) y)
|
||||
:comma-prop "foo" #{"foo"}
|
||||
:comma-prop "comma, separated" #{"comma" "separated"}
|
||||
:comma-prop "one, two, one" #{"one" "two"}))
|
||||
|
||||
(testing "for user comma separated properties with mixed values"
|
||||
(are [k v y] (= (parse-property k v {:property/separated-by-commas #{:comma-prop}}) y)
|
||||
:comma-prop "foo, #bar" #{"foo", "bar"}
|
||||
:comma-prop "comma, separated, [[page ref]], [[nested [[page]]]], #[[nested [[tag]]]], end" #{"page ref" "nested [[page]]" "nested [[tag]]" "comma" "separated" "end"}))
|
||||
|
||||
(testing "for normal properties"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:normal "[[foo]] [[bar]]" #{"foo" "bar"}
|
||||
:normal "[[foo]], [[bar]]" #{"foo" "bar"}
|
||||
:normal "[[foo]]" #{"foo"}
|
||||
:normal "[[foo]], [[bar]], #baz" #{"foo" "bar" "baz"}
|
||||
:normal "[[foo [[bar]]]]" #{"foo [[bar]]"}
|
||||
:normal "[[foo [[bar]]]], [[baz]]" #{"baz" "foo [[bar]]"}
|
||||
:title "comma, is ok" "comma, is ok"))
|
||||
|
||||
(testing "for tags in properties with punctuation"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:prop "#foo, #bar. #baz!" #{"foo" "bar" "baz"}
|
||||
:prop "#foo: '#bar'" #{"foo" "bar"}))
|
||||
|
||||
(testing "parse-property with quoted strings"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:tags "\"foo, bar\"" "\"foo, bar\""
|
||||
:tags "\"[[foo]], [[bar]]\"" "\"[[foo]], [[bar]]\""))
|
||||
|
||||
(testing "parse title property with square bracket"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:title "[[Jan 11th, 2022]] 21:26" "[[Jan 11th, 2022]] 21:26"
|
||||
:title "[[[[aldsfkd]] a.b/c.d]]" "[[[[aldsfkd]] a.b/c.d]]"))
|
||||
|
||||
(testing "built-in properties parse as expected"
|
||||
(are [k v y] (= (parse-property k v {}) y)
|
||||
:id "62e98716-9c0b-4253-83e7-7f8e8a23fe19" "62e98716-9c0b-4253-83e7-7f8e8a23fe19"
|
||||
:filters "{\"product process\" true}" "{\"product process\" true}"
|
||||
:collapsed "false" false
|
||||
:created-at "1609233702047" 1609233702047
|
||||
:background-color "#533e7d" "#533e7d")))
|
||||
|
||||
|
||||
#_(cljs.test/test-ns 'logseq.graph-parser.text-test)
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
/logseq/bak
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
+42
@@ -0,0 +1,42 @@
|
||||
{:highlights [{:id #uuid "687022ae-dac1-42a6-9d4c-39a0dba05918",
|
||||
:page 1,
|
||||
:position {:bounding {:x1 131,
|
||||
:y1 336,
|
||||
:x2 483,
|
||||
:y2 399,
|
||||
:width 574.0000000000001,
|
||||
:height 573.999986224},
|
||||
:rects (),
|
||||
:page 1},
|
||||
:content {:text "", :image 1752179374600},
|
||||
:properties {:color "yellow"}}
|
||||
{:id #uuid "68702394-3613-4bac-85a7-28643d58237f",
|
||||
:page 8,
|
||||
:position {:bounding {:x1 10.680589094758034,
|
||||
:y1 183.2645263671875,
|
||||
:x2 119.76637782156467,
|
||||
:y2 204.954345703125,
|
||||
:width 574.0000000000001,
|
||||
:height 573.999986224},
|
||||
:rects ({:x1 10.680589094758034,
|
||||
:y1 183.2645263671875,
|
||||
:x2 119.76637782156467,
|
||||
:y2 204.954345703125,
|
||||
:width 574.0000000000001,
|
||||
:height 573.999986224}),
|
||||
:page 8},
|
||||
:content {:text "Duke School"},
|
||||
:properties {:color "blue"}}
|
||||
{:id #uuid "68702499-159a-4a14-a0cf-cf5f015535c2",
|
||||
:page 2,
|
||||
:position {:bounding {:x1 120,
|
||||
:y1 240,
|
||||
:x2 360,
|
||||
:y2 280,
|
||||
:width 574.0000000000001,
|
||||
:height 573.999986224},
|
||||
:rects (),
|
||||
:page 2},
|
||||
:content {:text nil},
|
||||
:properties {:color "yellow"}}],
|
||||
:extra {:page 2}}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
+53
@@ -0,0 +1,53 @@
|
||||
{:highlights [{:id #uuid "697874ba-26e9-4e8a-a55d-0639d337dcc6",
|
||||
:page 6,
|
||||
:position {:bounding {:x1 67.03125,
|
||||
:y1 344.90625,
|
||||
:x2 612.7423095703125,
|
||||
:y2 379.3333740234375,
|
||||
:width 702,
|
||||
:height 993.418487394958},
|
||||
:rects ({:x1 67.03125,
|
||||
:y1 344.90625,
|
||||
:x2 612.7423095703125,
|
||||
:y2 364.2396240234375,
|
||||
:width 702,
|
||||
:height 993.418487394958}
|
||||
{:x1 67.03125,
|
||||
:y1 360,
|
||||
:x2 238.0740203857422,
|
||||
:y2 379.3333740234375,
|
||||
:width 702,
|
||||
:height 993.418487394958}),
|
||||
:page 6},
|
||||
:content {:text "EXPLAIN is a really nice command that gives you lots of information but it's often easy to not know what to do with all this"},
|
||||
:properties {:color "yellow"}}
|
||||
{:id #uuid "69787518-9eb8-4fd0-ad3b-b394e28bb547",
|
||||
:page 8,
|
||||
:position {:bounding {:x1 84,
|
||||
:y1 163,
|
||||
:x2 637,
|
||||
:y2 327,
|
||||
:width 702,
|
||||
:height 993.418487394958},
|
||||
:rects (),
|
||||
:page 8},
|
||||
:content {:text "[:span]", :image 1769501975346},
|
||||
:properties {:color "green"}}
|
||||
{:id #uuid "69787540-7a52-40af-a70a-cedd315934cf",
|
||||
:page 42,
|
||||
:position {:bounding {:x1 119.05208587646484,
|
||||
:y1 95.67709350585938,
|
||||
:x2 243.25509643554688,
|
||||
:y2 133.01040649414062,
|
||||
:width 702,
|
||||
:height 993.418487394958},
|
||||
:rects ({:x1 119.05208587646484,
|
||||
:y1 95.67709350585938,
|
||||
:x2 243.25509643554688,
|
||||
:y2 133.01040649414062,
|
||||
:width 702,
|
||||
:height 993.418487394958}),
|
||||
:page 42},
|
||||
:content {:text "Conclusion"},
|
||||
:properties {:color "blue"}}],
|
||||
:extra {:page 8}}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 736 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,36 @@
|
||||
{:highlights [{:id #uuid "69787399-f51c-45a2-8971-78dc6c66a0ec",
|
||||
:page 1,
|
||||
:position {:bounding {:x1 123.89583587646484,
|
||||
:y1 164.3125,
|
||||
:x2 438.8349304199219,
|
||||
:y2 180.9791717529297,
|
||||
:width 702,
|
||||
:height 908.470588235294},
|
||||
:rects ({:x1 123.89583587646484,
|
||||
:y1 164.3125,
|
||||
:x2 438.8349304199219,
|
||||
:y2 180.9791717529297,
|
||||
:width 702,
|
||||
:height 908.470588235294}
|
||||
{:x1 143.625,
|
||||
:y1 166.9791717529297,
|
||||
:x2 432.40625,
|
||||
:y2 178.4479217529297,
|
||||
:width 702,
|
||||
:height 908.470588235294}),
|
||||
:page 1},
|
||||
:content {:text "The zlib library is a general purpose data compression library."},
|
||||
:properties {:color "red"}}
|
||||
{:id #uuid "697873d7-5953-4753-897e-62ac47348634",
|
||||
:page 1,
|
||||
:position {:bounding {:x1 116,
|
||||
:y1 530,
|
||||
:x2 627,
|
||||
:y2 690,
|
||||
:width 702,
|
||||
:height 908.470588235294},
|
||||
:rects (),
|
||||
:page 1},
|
||||
:content {:text "[:span]", :image 1769501651181},
|
||||
:properties {:color "blue"}}],
|
||||
:extra {:page 2}}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
@@ -0,0 +1,65 @@
|
||||
#+TITLE: About
|
||||
|
||||
** Hi, welcome to [[https://logseq.com][Logseq]].
|
||||
|
||||
*Logseq* is a /local-only/, /non-linear/, /outliner/ notebook for organizing and
|
||||
[[https://logseq.com/blog][sharing]] your personal knowledge base.
|
||||
|
||||
Use it to organize your todo list, to write your journals, or to record your unique
|
||||
life.
|
||||
|
||||
The server will never store or analyze your private notes. Your data are
|
||||
plain text files, we support both Markdown and Emacs Org mode for the time being. Even if the website is down or can't be maintained, your data is always yours.
|
||||
|
||||
*Logseq* is hugely inspired by [[https://roamresearch.com/][Roam Research]], [[https://orgmode.org/][Org Mode]], [[https://tiddlywiki.com/][Tiddlywiki]] and [[https://workflowy.com/][Workflowy]], hats off to all of them!
|
||||
[[https://cdn.logseq.com/%2F8b9a461d-437e-4ca5-a2da-18b51077b5142020_07_25_Screenshot%202020-07-25%2013-29-49%20%2B0800.png?Expires=4749255017&Signature=Qbx6jkgAytqm6nLxVXQQW1igfcf~umV1OcG6jXUt09TOVhgXyA2Z5jHJ3AGJASNcphs31pZf4CjFQ5mRCyVKw6N8wb8Nn-MxuTJl0iI8o-jLIAIs9q1v-2cusCvuFfXH7bq6ir8Lpf0KYAprzuZ00FENin3dn6RBW35ENQwUioEr5Ghl7YOCr8bKew3jPV~OyL67MttT3wJig1j3IC8lxDDT8Ov5IMG2GWcHERSy00F3mp3tJtzGE17-OUILdeuTFz6d-NDFAmzB8BebiurYz0Bxa4tkcdLUpD5ToFHU08jKzZExoEUY8tvaZ1-t7djmo3d~BAXDtlEhC2L1YC2aVQ__&Key-Pair-Id=APKAJE5CCD6X7MP6PTEA][2020_07_25_Screenshot 2020-07-25 13-29-49 +0800.png]]
|
||||
** Where are my notes saved?
|
||||
Your notes will be stored in the local browser storage. We are using IndexedDB.
|
||||
** How do I use it?
|
||||
*** 1. Sync between multiple devices
|
||||
Currently, we only support syncing through GitHub, more options (e.g.
|
||||
Gitlab, Dropbox, Google Drive, WebDAV, etc.) will be added soon.
|
||||
|
||||
We are using an excellent web git client called [[https://isomorphic-git.org/][isomorphic-git]].
|
||||
**** Step 1
|
||||
Click the button /Login with GitHub/.
|
||||
**** Step 2
|
||||
Set your GitHub personal access token, the token will be encrypted and
|
||||
stored in the browser local storage, our server will never store it.
|
||||
|
||||
If you know nothing about either Git or the personal access token, no worries,
|
||||
just follow the steps here: https://logseq.com/blog/faq#How_to_create_a_Github_personal_access_token-3f-
|
||||
**** Step 3
|
||||
Start writing!
|
||||
*** 2. Use it locally (no need to login)
|
||||
Just remember to backup your notes periodically (we'll provide export and import soon)!
|
||||
** Features
|
||||
- Backlinks between ~[[Page]]~s
|
||||
- Block embed
|
||||
- Page embed
|
||||
- Graph visualization
|
||||
- Heading properties
|
||||
- Datalog queries, the notes db is powered by [[https://github.com/tonsky/datascript][Datascript]]
|
||||
- Custom view component
|
||||
- Document built-in supports:
|
||||
* Code highlights
|
||||
* Katex latex
|
||||
* Raw [[https://github.com/weavejester/hiccup][hiccup]]
|
||||
* Raw html
|
||||
** Learn more
|
||||
- Twitter: https://twitter.com/logseq
|
||||
- Discord: https://discord.gg/KpN4eHY where we ask questions and share tips
|
||||
- Website: https://logseq.com/
|
||||
- GitHub: https://github.com/logseq/logseq everyone is encouraged to report issues!
|
||||
- Our blog: https://logseq.com/blog
|
||||
** Credits to
|
||||
- [[https://roamresearch.com/][Roam Research]]
|
||||
- [[https://orgmode.org/][Org Mode]]
|
||||
- [[https://tiddlywiki.com/][Tiddlywiki]]
|
||||
- [[https://workflowy.com/][Workflowy]]
|
||||
- [[https://clojure.org][Clojure && Clojurescript]]
|
||||
- [[https://ocaml.org/][OCaml]] && [[https://github.com/inhabitedtype/angstrom][Angstrom]], the document [[https://github.com/mldoc/mldoc][parser]] is built on Angstrom.
|
||||
- [[https://github.com/talex5/cuekeeper][Cuekeeper]] - Browser-based GTD (TODO list) system.
|
||||
- [[https://github.com/tonsky/datascript][Datascript]] - Immutable database and Datalog query engine for Clojure, ClojureScript and JS
|
||||
- [[https://github.com/borkdude/sci][sci]] - Small Clojure Interpreter
|
||||
- [[https://isomorphic-git.org/][isomorphic-git]]
|
||||
@@ -0,0 +1,4 @@
|
||||
icon:: 😆
|
||||
|
||||
- has some content
|
||||
icon:: 😆
|
||||
@@ -0,0 +1,2 @@
|
||||
- test!
|
||||
- child block
|
||||
@@ -0,0 +1,3 @@
|
||||
- [[some page]] tests page ref being parsed before page
|
||||
- [[prop-num]] tests page existing before being used as and converted into a property
|
||||
- {:height 288, :width 252}
|
||||
@@ -0,0 +1,4 @@
|
||||
- b1
|
||||
prop-string:: woot
|
||||
prop-num:: 5
|
||||
Prop-bool:: true
|
||||
@@ -0,0 +1,2 @@
|
||||
- Inception #Movie
|
||||
- TODO do X #p0
|
||||
@@ -0,0 +1,3 @@
|
||||
- original block
|
||||
id:: 65cbb772-fb79-462d-87c8-6f0dad751dee
|
||||
- ref to ((65cbb772-fb79-462d-87c8-6f0dad751dee))
|
||||
@@ -0,0 +1,10 @@
|
||||
- TODO old todo block
|
||||
todo:: 1612237041309
|
||||
done:: 1612237041309
|
||||
now:: 1612237041309
|
||||
later:: 1612237041309
|
||||
- {{query (property :prop-string)}}
|
||||
query-table:: true
|
||||
query-properties:: [:block :page :prop-string :prop-num]
|
||||
query-sort-by:: prop-num
|
||||
query-sort-desc:: true
|
||||
@@ -0,0 +1,10 @@
|
||||
- existing :number to :default
|
||||
duration:: 20
|
||||
- Review 15 candidates #Meeting
|
||||
participants:: [[Gabriel]] [[Jakob]]
|
||||
description:: [[Jakob]] thought candidate was #awesome
|
||||
- numbered list
|
||||
- list one
|
||||
logseq.order-list-type:: number
|
||||
- list two
|
||||
logseq.order-list-type:: number
|
||||
@@ -0,0 +1,51 @@
|
||||
- test :dates
|
||||
startedAt:: [[Feb 6th, 2024]]
|
||||
finishedAt:: [[Feb 7th, 2024]]
|
||||
- MEETING TITLE
|
||||
template:: meeting
|
||||
participants:: TODO
|
||||
- TITLE
|
||||
template:: title-only-no-children
|
||||
- template:: properties-only-no-children
|
||||
name::
|
||||
author::
|
||||
- TITLE
|
||||
template:: title-only-with-children
|
||||
- intro
|
||||
- notes
|
||||
-
|
||||
template:: empty-title-with-children
|
||||
- intro
|
||||
- notes
|
||||
- it should not be included in the template
|
||||
template:: children-only
|
||||
template-including-parent:: false
|
||||
- intro
|
||||
- notes
|
||||
- it's a template with nested templates
|
||||
template:: nested-father
|
||||
template-including-parent:: true
|
||||
name:: you named it
|
||||
- child-1
|
||||
template:: nested-child-1
|
||||
name::
|
||||
- child-1-1
|
||||
name::
|
||||
- child-2
|
||||
template:: nested-child-2
|
||||
template-including-parent:: false
|
||||
name::
|
||||
- child-2-1
|
||||
name::
|
||||
- child-3
|
||||
name::
|
||||
- pending block for :number to :default
|
||||
duration:: 10
|
||||
- test :number to :default
|
||||
duration:: 20m
|
||||
- test :default to :node
|
||||
description:: [[Jakob]]
|
||||
- test :node -> :date
|
||||
participants:: [[Feb 7th, 2024]]
|
||||
- :node people
|
||||
people:: [[Jakob]] [[Gabriel]]
|
||||
@@ -0,0 +1,5 @@
|
||||
- The Creator
|
||||
type:: [[Movie]]
|
||||
testTagClass:: #Movie
|
||||
- test :date -> :node
|
||||
finishedAt:: [[Gabriel]]
|
||||
@@ -0,0 +1,7 @@
|
||||
- collapsed block
|
||||
collapsed:: true
|
||||
- child
|
||||
- pending block for :node to :default
|
||||
people:: [[Gabriel]] [[Jakob]]
|
||||
- test :node :many to :default
|
||||
people:: some text
|
||||
@@ -0,0 +1,4 @@
|
||||
- b1
|
||||
rating:: 5
|
||||
- :rating float
|
||||
rating:: 5.5
|
||||
@@ -0,0 +1,5 @@
|
||||
- test ignore blank values so that property type doesn't change
|
||||
sameAs::
|
||||
- replace tags edge cases
|
||||
- replace with same start string #foo #foo-bar
|
||||
- replace case insensitive #foo #Foo
|
||||
@@ -0,0 +1,13 @@
|
||||
- only deadline
|
||||
id:: 669168ed-8734-4943-8a86-5e3a553a526d
|
||||
DEADLINE: <2022-11-26 Sat>
|
||||
- deadline and scheduled, also tests using same day on one block
|
||||
DEADLINE: <2022-11-25 Sat>
|
||||
SCHEDULED: <2022-11-25 Fri .+1d>
|
||||
- [#A] high priority
|
||||
- DOING [#B] status test
|
||||
:LOGBOOK:
|
||||
CLOCK: [2024-04-01 Mon 10:39:40]
|
||||
:END:
|
||||
- deadline on same day
|
||||
DEADLINE: <2024-04-01 Mon 13:50>
|
||||
@@ -0,0 +1,3 @@
|
||||
- unusual class example #123
|
||||
- unusual property example
|
||||
123:: works
|
||||
@@ -0,0 +1,76 @@
|
||||
- For example, here's a query with title text:
|
||||
{{query (property type book)}}
|
||||
- test multilines in this page
|
||||
- |markdown| table|
|
||||
|some|thing|
|
||||
- block with props
|
||||
prop-num:: 10
|
||||
- normal multiline block
|
||||
a 2nd
|
||||
and a 3rd
|
||||
- colored multiline block
|
||||
background-color:: red
|
||||
last line
|
||||
- multiline block with prop and deadline
|
||||
background-color:: red
|
||||
DEADLINE: <2022-11-26 Sat>
|
||||
last line
|
||||
- multiline block with deadline and scheduled in 1 line and sth else
|
||||
DEADLINE: <2022-11-26 Sat> SCHEDULED: <2022-11-26 Sat> something else
|
||||
last line
|
||||
- DONE multiline logbook block
|
||||
:LOGBOOK:
|
||||
CLOCK: [2024-08-07 Wed 11:47:50]
|
||||
CLOCK: [2024-08-07 Wed 11:47:53]
|
||||
:END:
|
||||
last line
|
||||
- DOING logbook block
|
||||
:LOGBOOK:
|
||||
CLOCK: [2024-08-07 Wed 11:47:50]
|
||||
CLOCK: [2024-08-07 Wed 11:47:53]
|
||||
:END:
|
||||
- TODO
|
||||
- Text before
|
||||
query-table:: false
|
||||
query-properties:: [:block]
|
||||
#+BEGIN_QUERY
|
||||
{:title "tasks with todo and doing"
|
||||
:query (task todo doing)}
|
||||
#+END_QUERY
|
||||
Text after
|
||||
- collapsed:: true
|
||||
#+BEGIN_QUERY
|
||||
{:title "⌛ Pretty print advanced query test"
|
||||
:query [:find (pull ?b [*])
|
||||
:in $ ?today
|
||||
:where
|
||||
[?b :block/page ?p]
|
||||
[?p :page/journal? true]
|
||||
[?p :page/journal-day ?jd]
|
||||
[(str ?jd) ?jds]
|
||||
[(subs ?jds 4 8) ?md1]
|
||||
[(str ?today) ?td]
|
||||
[(subs ?td 4 8) ?md2]
|
||||
[(= ?md1 ?md2)]
|
||||
[(< ?jd ?today)]
|
||||
]
|
||||
:inputs [:today]
|
||||
:breadcrumb-show? true
|
||||
:collapsed? False
|
||||
}
|
||||
#+END_QUERY
|
||||
- Get all tasks with a tag "project"
|
||||
#+BEGIN_SRC clojure
|
||||
#+BEGIN_QUERY
|
||||
{:title "All blocks with tag project"
|
||||
:query [:find (pull ?b [*])
|
||||
:where
|
||||
[?p :block/name "project"]
|
||||
[?b :block/refs ?p]]}
|
||||
#+END_QUERY
|
||||
#+END_SRC
|
||||
- Find the blocks containing `tag2` but not `tag1`
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
{{query (and [[tag2]] (not [[tag1]]))}}
|
||||
#+END_EXAMPLE
|
||||
@@ -0,0 +1,3 @@
|
||||
- test linked ref filters
|
||||
- [[ref1]] [[chat-gpt]]
|
||||
- [[ref2]] [[chat-gpt]]
|
||||
@@ -0,0 +1,5 @@
|
||||
- test namespaces
|
||||
- [[y]]
|
||||
- [[n1/x/z]]
|
||||
- [[n2/x/z]]
|
||||
- [[n2/alias]] tests name that overlaps with built-in ones
|
||||
@@ -0,0 +1,2 @@
|
||||
- block with namespace tag #Quotes/life
|
||||
- block with namespace ref [[Quotes/life]]
|
||||
@@ -0,0 +1,2 @@
|
||||
- Block with journal ref [[Nov 3rd, 2020]]
|
||||
- Another block with #Quotes/life
|
||||
@@ -0,0 +1,11 @@
|
||||
- card 1 #card
|
||||
card-last-score:: 3
|
||||
card-repeats:: 1
|
||||
card-next-schedule:: 2024-11-30T20:27:33.372Z
|
||||
card-last-interval:: 4
|
||||
card-ease-factor:: 2.36
|
||||
card-last-reviewed:: 2024-11-26T20:27:33.373Z
|
||||
- card 2 with cloze {{cloze surprise!}} #card
|
||||
card-next-schedule:: 2024-11-27T05:00:00.000Z
|
||||
- This block should test a page with a future parent class `#Property`
|
||||
FIXME: Property tag triggers an intermittent, invalid hanging block ref
|
||||
@@ -0,0 +1 @@
|
||||
- A page ref with same as a block (task in this case) shouldn't fail [[do X]]
|
||||
@@ -0,0 +1,61 @@
|
||||
- Test paragraph before an asset
|
||||
|
||||
|
||||
{:width 105} tests an asset with a manual link, custom title and in a subdirectory
|
||||
- {:height 288, :width 252} and {:width 335.99774169921875}
|
||||
- From Inception:
|
||||
#+BEGIN_QUOTE
|
||||
Saito: Cobb? Impossible. We were young men together. I'm an old man.
|
||||
...
|
||||
Cobb: I've come back for you... to remind you of something. Something you once knew...
|
||||
#+END_QUOTE
|
||||
- > markdown quote
|
||||
[[wut]]
|
||||
line 3
|
||||
- Test of various ast types:
|
||||
#+BEGIN_QUOTE
|
||||
*Italic* ~~Strikethrough~~ ^^Highlight^^ #[[foo]]
|
||||
**Learn Datalog Today** is an interactive tutorial designed to teach you the [Datomic](http://datomic.com/) dialect of [Datalog](http://en.wikipedia.org/wiki/Datalog). Datalog is a declarative **database query language** with roots in logic programming. Datalog has similar expressive power as [SQL](http://en.wikipedia.org/wiki/Sql).
|
||||
#+END_QUOTE
|
||||
- test page embed
|
||||
{{embed [[page embed]]}}
|
||||
- test block embed
|
||||
id:: 685434e1-0bb9-468c-a660-1642b00b2854
|
||||
- {{embed ((685434e1-0bb9-468c-a660-1642b00b2854))}}
|
||||
- > Blockquotes
|
||||
- > Blockquotes
|
||||
and
|
||||
|
||||
something else
|
||||
- #+BEGIN_QUOTE
|
||||
Blockquotes
|
||||
and
|
||||
#+END_QUOTE
|
||||
something else
|
||||
- > Blockquotes
|
||||
>> Nested Blockquotes
|
||||
- Q:
|
||||
> Question 1
|
||||
|
||||
A:
|
||||
> Answer 1
|
||||
and
|
||||
>> nested
|
||||
|
||||
and something else
|
||||
- Q:
|
||||
|
||||
> Question 2
|
||||
|
||||
> Question 3
|
||||
|
||||
A:
|
||||
|
||||
> Answer 2
|
||||
>
|
||||
> Answer 3
|
||||
- #+BEGIN_QUOTE
|
||||
it's a
|
||||
|
||||
org blockquote
|
||||
#+END_QUOTE
|
||||
@@ -0,0 +1,4 @@
|
||||
- tests :node to :default like :people property but for a new property
|
||||
people2:: [[Gabriel]]
|
||||
- changes :node to :default
|
||||
people2:: some text
|
||||
@@ -0,0 +1 @@
|
||||
- 
|
||||
@@ -0,0 +1,7 @@
|
||||
- Test ref to an annotation: ((68702394-3613-4bac-85a7-28643d58237f))
|
||||
- background-color:: yellow
|
||||
> The distribution of $x^n ~\text{mod}~ 1$ is more subtle. We have three basic facts.
|
||||
>
|
||||
> 1. If $0 ≤ x < 1$, then $x^n → 0$ as $n → ∞$.
|
||||
> 2. If $x = 1$ then $x^n = 1$ for all $n$.
|
||||
> 3. For almost all $x > 1$ the sequence $x^n ~\text{mod}~ 1$ is uniformly distributed. But for some values of $x$ it is not, and there’s no known classification for these exceptional values of $x$.
|
||||
@@ -0,0 +1,8 @@
|
||||
- #+BEGIN_QUOTE
|
||||
test a code block in a quote:
|
||||
|
||||
```shell
|
||||
$ echo hi
|
||||
$ echo gbye
|
||||
```
|
||||
#+END_QUOTE
|
||||
@@ -0,0 +1,5 @@
|
||||
tags:: #diary
|
||||
- This journal has a tag to test journals with tags
|
||||
- Block tags #p1
|
||||
tags:: ai, #block-tag
|
||||
- block w/ longer ns tag #n1/n2/n3
|
||||
@@ -0,0 +1,2 @@
|
||||
- [[zlib]]
|
||||
- [[Understanding EXPLAIN]]
|
||||
@@ -0,0 +1,5 @@
|
||||
- 2nd instance of block w/ longer ns tag #n1/n2/n3
|
||||
- property pages with '/' should be valid
|
||||
key/value:: 1
|
||||
- block with multi word tag #[[another test]] doesn't get removed by page-ref replacement
|
||||
- [[Jan 1st, 2026]]
|
||||
@@ -0,0 +1,35 @@
|
||||
- ```markdown
|
||||
it's an individual code snippet with language tag
|
||||
```
|
||||
- ```
|
||||
it's an individual code snippet without language tag
|
||||
```
|
||||
- before code snippet
|
||||
```
|
||||
echo "ok"
|
||||
exit
|
||||
```
|
||||
- before code snippet
|
||||
```bash
|
||||
echo "ok"
|
||||
exit
|
||||
```
|
||||
after code snippet
|
||||
- ```bash
|
||||
echo "ok"
|
||||
exit
|
||||
```
|
||||
after code snippet
|
||||
- before code snippet
|
||||
```bash
|
||||
echo "ok"
|
||||
exit
|
||||
```
|
||||
middle
|
||||
```bash
|
||||
echo "bye"
|
||||
exit
|
||||
```
|
||||
after code snippet
|
||||
- $$E=mc^2$$
|
||||
- {{cards (tags #Card)}}
|
||||
@@ -0,0 +1,408 @@
|
||||
{:meta/version 1
|
||||
|
||||
;; Set the preferred format.
|
||||
;; This is _only_ for file graphs.
|
||||
;; Available options:
|
||||
;; - Markdown (default)
|
||||
;; - Org
|
||||
;; :preferred-format "Markdown"
|
||||
|
||||
;; Set the preferred workflow style.
|
||||
;; Available options:
|
||||
;; - :now for NOW/LATER style (default)
|
||||
;; - :todo for TODO/DOING style
|
||||
:preferred-workflow :now
|
||||
|
||||
;; Exclude directories/files.
|
||||
;; Example usage:
|
||||
;; :hidden ["/archived" "/test.md" "../assets/archived"]
|
||||
:hidden ["ignored"]
|
||||
|
||||
;; Define the default journal page template.
|
||||
;; Enter the template name between the quotes.
|
||||
:default-templates
|
||||
{:journals ""}
|
||||
|
||||
;; Set a custom date format for the journal page title.
|
||||
;; Default value: "MMM do, yyyy"
|
||||
;; e.g., "Jan 19th, 2038"
|
||||
;; Example usage e.g., "Tue 19th, Jan 2038"
|
||||
;; :journal/page-title-format "EEE do, MMM yyyy"
|
||||
|
||||
;; Specify the journal filename format using a valid date format string.
|
||||
;; !Warning:
|
||||
;; This configuration is not retroactive and affects only new journals.
|
||||
;; To show old journal files in the app, manually rename the files in the
|
||||
;; journal directory to match the new format.
|
||||
;; Default value: "yyyy_MM_dd"
|
||||
;; :journal/file-name-format "yyyy_MM_dd"
|
||||
|
||||
;; Enable tooltip preview on hover.
|
||||
;; Default value: true
|
||||
:ui/enable-tooltip? true
|
||||
|
||||
;; Display brackets [[]] around page references.
|
||||
;; Default value: true
|
||||
;; :ui/show-brackets? true
|
||||
|
||||
;; Display all lines of a block when referencing ((block)).
|
||||
;; Default value: false
|
||||
:ui/show-full-blocks? false
|
||||
|
||||
;; Automatically expand block references when zooming in.
|
||||
;; Default value: true
|
||||
:ui/auto-expand-block-refs? true
|
||||
|
||||
;; Disable accent marks when searching.
|
||||
;; After changing this setting, rebuild the search index by pressing (^C ^S).
|
||||
;; Default value: true
|
||||
:feature/enable-search-remove-accents? true
|
||||
|
||||
;; Enable journals.
|
||||
;; Default value: true
|
||||
;; :feature/enable-journals? true
|
||||
|
||||
;; Enable flashcards.
|
||||
;; Default value: true
|
||||
;; :feature/enable-flashcards? true
|
||||
|
||||
;; Enable whiteboards.
|
||||
;; Default value: true
|
||||
;; :feature/enable-whiteboards? true
|
||||
|
||||
;; Disable the journal's built-in 'Scheduled tasks and deadlines' query.
|
||||
;; Default value: false
|
||||
;; :feature/disable-scheduled-and-deadline-query? false
|
||||
|
||||
;; Specify the number of days displayed in the future for
|
||||
;; the 'scheduled tasks and deadlines' query.
|
||||
;; Example usage:
|
||||
;; Display all scheduled and deadline blocks for the next 14 days:
|
||||
;; :scheduled/future-days 14
|
||||
;; Default value: 7
|
||||
;; :scheduled/future-days 7
|
||||
|
||||
;; Specify the first day of the week.
|
||||
;; Available options:
|
||||
;; - integer from 0 to 6 (Monday to Sunday)
|
||||
;; Default value: 6 (Sunday)
|
||||
:start-of-week 6
|
||||
|
||||
;; Specify a custom CSS import.
|
||||
;; This option takes precedence over the local `logseq/custom.css` file.
|
||||
;; Example usage:
|
||||
;; :custom-css-url "@import url('https://cdn.jsdelivr.net/gh/dracula/logseq@master/custom.css');"
|
||||
|
||||
;; Specify a custom JS import.
|
||||
;; This option takes precedence over the local `logseq/custom.js` file.
|
||||
;; Example usage:
|
||||
;; :custom-js-url "https://cdn.logseq.com/custom.js"
|
||||
|
||||
;; Set bullet indentation when exporting
|
||||
;; Available options:
|
||||
;; - `:eight-spaces` as eight spaces
|
||||
;; - `:four-spaces` as four spaces
|
||||
;; - `:two-spaces` as two spaces
|
||||
;; - `:tab` as a tab character (default)
|
||||
;; :export/bullet-indentation :tab
|
||||
|
||||
;; Publish all pages within the Graph
|
||||
;; Regardless of whether individual pages have been marked as public.
|
||||
;; Default value: false
|
||||
;; :publishing/all-pages-public? false
|
||||
|
||||
;; Define the default home page and sidebar status.
|
||||
;; If unspecified, the journal page will be loaded on startup and the right sidebar will stay hidden.
|
||||
;; The `:page` value represents the name of the page displayed at startup.
|
||||
;; Available options for `:sidebar` are:
|
||||
;; - "Contents" to display the Contents page in the right sidebar.
|
||||
;; - A specific page name to display in the right sidebar.
|
||||
;; - An array of multiple pages, e.g., ["Contents" "Page A" "Page B"].
|
||||
;; If `:sidebar` remains unset, the right sidebar will stay hidden.
|
||||
;; Examples:
|
||||
;; 1. Set "Changelog" as the home page and display "Contents" in the right sidebar:
|
||||
;; :default-home {:page "Changelog", :sidebar "Contents"}
|
||||
;; 2. Set "Jun 3rd, 2021" as the home page without the right sidebar:
|
||||
;; :default-home {:page "Jun 3rd, 2021"}
|
||||
;; 3. Set "home" as the home page and display multiple pages in the right sidebar:
|
||||
;; :default-home {:page "home", :sidebar ["Page A" "Page B"]}
|
||||
|
||||
;; Set the default location for storing notes.
|
||||
;; Default value: "pages"
|
||||
;; :pages-directory "pages"
|
||||
|
||||
;; Set the default location for storing journals.
|
||||
;; Default value: "journals"
|
||||
;; :journals-directory "journals"
|
||||
|
||||
;; Set the default location for storing whiteboards.
|
||||
;; Default value: "whiteboards"
|
||||
;; :whiteboards-directory "whiteboards"
|
||||
|
||||
;; Enabling this option converts
|
||||
;; [[Grant Ideas]] to [[file:./grant_ideas.org][Grant Ideas]] for org-mode.
|
||||
;; For more information, visit https://github.com/logseq/logseq/issues/672
|
||||
;; :org-mode/insert-file-link? false
|
||||
|
||||
;; Configure custom shortcuts.
|
||||
;; Syntax:
|
||||
;; 1. + indicates simultaneous key presses, e.g., `Ctrl+Shift+a`.
|
||||
;; 2. A space between keys represents key chords, e.g., `t s` means
|
||||
;; pressing `t` followed by `s`.
|
||||
;; 3. mod refers to `Ctrl` for Windows/Linux and `Command` for Mac.
|
||||
;; 4. Use false to disable a specific shortcut.
|
||||
;; 5. You can define multiple bindings for a single action, e.g., ["ctrl+j" "down"].
|
||||
;; The full list of configurable shortcuts is available at:
|
||||
;; https://github.com/logseq/logseq/blob/master/src/main/frontend/modules/shortcut/config.cljs
|
||||
;; Example:
|
||||
;; :shortcuts
|
||||
;; {:editor/new-block "enter"
|
||||
;; :editor/new-line "shift+enter"
|
||||
;; :editor/insert-link "mod+shift+k"
|
||||
;; :editor/highlight false
|
||||
;; :ui/toggle-settings "t s"
|
||||
;; :editor/up ["ctrl+k" "up"]
|
||||
;; :editor/down ["ctrl+j" "down"]
|
||||
;; :editor/left ["ctrl+h" "left"]
|
||||
;; :editor/right ["ctrl+l" "right"]}
|
||||
:shortcuts {}
|
||||
|
||||
;; Configure the behavior of pressing Enter in document mode.
|
||||
;; if set to true, pressing Enter will create a new block.
|
||||
;; Default value: false
|
||||
:shortcut/doc-mode-enter-for-new-block? false
|
||||
|
||||
;; Block content larger than `block/title-max-length` will not be searchable
|
||||
;; or editable for performance.
|
||||
;; Default value: 10000
|
||||
:block/title-max-length 10000
|
||||
|
||||
;; Display command documentation on hover.
|
||||
;; Default value: true
|
||||
:ui/show-command-doc? true
|
||||
|
||||
;; Display empty bullet points.
|
||||
;; Default value: false
|
||||
:ui/show-empty-bullets? false
|
||||
|
||||
;; Pre-defined :view function to use with advanced queries.
|
||||
:query/views
|
||||
{:pprint
|
||||
(fn [r] [:pre.code (pprint r)])}
|
||||
|
||||
;; Advanced queries `:result-transform` function.
|
||||
;; Transform the query result before displaying it.
|
||||
:query/result-transforms
|
||||
{:sort-by-priority
|
||||
(fn [result] (sort-by (fn [h] (get h :block/priority "Z")) result))}
|
||||
|
||||
;; The following queries will be displayed at the bottom of today's journal page.
|
||||
;; The "NOW" query returns tasks with "NOW" or "DOING" status.
|
||||
;; The "NEXT" query returns tasks with "NOW", "LATER", or "TODO" status.
|
||||
:default-queries
|
||||
{:journals
|
||||
[{:title "🔨 NOW"
|
||||
:query [:find (pull ?h [*])
|
||||
:in $ ?start ?today
|
||||
:where
|
||||
[?h :block/marker ?marker]
|
||||
[(contains? #{"NOW" "DOING"} ?marker)]
|
||||
[?h :block/page ?p]
|
||||
[?p :block/journal-day ?d]
|
||||
[(>= ?d ?start)]
|
||||
[(<= ?d ?today)]]
|
||||
:inputs [:14d :today]
|
||||
:result-transform (fn [result]
|
||||
(sort-by (fn [h]
|
||||
(get h :block/priority "Z")) result))
|
||||
:group-by-page? false
|
||||
:collapsed? false}
|
||||
{:title "📅 NEXT"
|
||||
:query [:find (pull ?h [*])
|
||||
:in $ ?start ?next
|
||||
:where
|
||||
[?h :block/marker ?marker]
|
||||
[(contains? #{"NOW" "LATER" "TODO"} ?marker)]
|
||||
[?h :block/page ?p]
|
||||
[?p :block/journal-day ?d]
|
||||
[(> ?d ?start)]
|
||||
[(< ?d ?next)]]
|
||||
:inputs [:today :7d-after]
|
||||
:group-by-page? false
|
||||
:collapsed? false}]}
|
||||
|
||||
;; Add custom commands to the command palette
|
||||
;; Example usage:
|
||||
;; :commands
|
||||
;; [
|
||||
;; ["js" "Javascript"]
|
||||
;; ["md" "Markdown"]
|
||||
;; ]
|
||||
:commands []
|
||||
|
||||
;; Enable collapsing blocks with titles but no children.
|
||||
;; By default, only blocks with children can be collapsed.
|
||||
;; Setting `:outliner/block-title-collapse-enabled?` to true allows collapsing
|
||||
;; blocks with titles (multiple lines) and content. For example:
|
||||
;; - block title
|
||||
;; block content
|
||||
;; Default value: false
|
||||
:outliner/block-title-collapse-enabled? false
|
||||
|
||||
;; Macros replace texts and will make you more productive.
|
||||
;; Example usage:
|
||||
;; Change the :macros value below to:
|
||||
;; {"poem" "Rose is $1, violet's $2. Life's ordered: Org assists you."}
|
||||
;; input "{{poem red,blue}}"
|
||||
;; becomes
|
||||
;; Rose is red, violet's blue. Life's ordered: Org assists you.
|
||||
:macros
|
||||
{"docs-base-url" "https://docs.logseq.com/#/page/$1"}
|
||||
|
||||
;; Configure the default expansion level for linked references.
|
||||
;; For example, consider the following block hierarchy:
|
||||
;; - a [[page]] (level 1)
|
||||
;; - b (level 2)
|
||||
;; - c (level 3)
|
||||
;; - d (level 4)
|
||||
;;
|
||||
;; With the default value of level 2, block b will be collapsed.
|
||||
;; If the level's value is set to 3, block c will be collapsed.
|
||||
;; Default value: 2
|
||||
:ref/default-open-blocks-level 2
|
||||
|
||||
;; Graph view configuration.
|
||||
;; Example usage:
|
||||
;; :graph/settings
|
||||
;; {:orphan-pages? true ; Default value: true
|
||||
;; :builtin-pages? false ; Default value: false
|
||||
;; :excluded-pages? false ; Default value: false
|
||||
;; :journal? false} ; Default value: false
|
||||
|
||||
;; Favorites to list on the left sidebar
|
||||
:favorites ["Interstellar" "some page" "[[new page]]" "n1/x/y"]
|
||||
|
||||
;; Set flashcards interval.
|
||||
;; Expected value:
|
||||
;; - Float between 0 and 1
|
||||
;; higher values result in faster changes to the next review interval.
|
||||
;; Default value: 0.5
|
||||
;; :srs/learning-fraction 0.5
|
||||
|
||||
;; Set the initial interval after the first successful review of a card.
|
||||
;; Default value: 4
|
||||
;; :srs/initial-interval 4
|
||||
|
||||
;; Hide specific block properties.
|
||||
;; Example usage:
|
||||
;; :block-hidden-properties #{:public :icon}
|
||||
|
||||
;; Create a page for all properties.
|
||||
;; Default value: true
|
||||
:property-pages/enabled? true
|
||||
|
||||
;; Properties to exclude from having property pages
|
||||
;; Example usage:
|
||||
;; :property-pages/excludelist #{:duration :author}
|
||||
|
||||
;; By default, property value separated by commas will not be treated as
|
||||
;; page references. You can add properties to enable it.
|
||||
;; Example usage:
|
||||
;; :property/separated-by-commas #{:alias :tags}
|
||||
|
||||
;; Properties that are ignored when parsing property values for references
|
||||
;; Example usage:
|
||||
;; :ignored-page-references-keywords #{:author :website}
|
||||
|
||||
;; logbook configuration.
|
||||
;; :logbook/settings
|
||||
;; {:with-second-support? false ;limit logbook to minutes, seconds will be eliminated
|
||||
;; :enabled-in-all-blocks true ;display logbook in all blocks after timetracking
|
||||
;; :enabled-in-timestamped-blocks false ;don't display logbook at all
|
||||
;; }
|
||||
|
||||
;; Mobile photo upload configuration.
|
||||
;; :mobile/photo
|
||||
;; {:allow-editing? true
|
||||
;; :quality 80}
|
||||
|
||||
;; Mobile features options
|
||||
;; Gestures
|
||||
;; Example usage:
|
||||
;; :mobile
|
||||
;; {:gestures/disabled-in-block-with-tags ["kanban"]}
|
||||
|
||||
;; Extra CodeMirror options
|
||||
;; See https://codemirror.net/5/doc/manual.html#config for possible options
|
||||
;; Example usage:
|
||||
;; :editor/extra-codemirror-options
|
||||
;; {:lineWrapping false ; Default value: false
|
||||
;; :lineNumbers true ; Default value: true
|
||||
;; :readOnly false} ; Default value: false
|
||||
|
||||
;; Enable logical outdenting
|
||||
;; Default value: false
|
||||
;; :editor/logical-outdenting? false
|
||||
|
||||
;; Prefer pasting the file when text and a file are in the clipboard.
|
||||
;; Default value: false
|
||||
;; :editor/preferred-pasting-file? false
|
||||
|
||||
;; Quick capture templates for receiving content from other apps.
|
||||
;; Each template contains three elements {time}, {text} and {url}, which can be auto-expanded
|
||||
;; by receiving content from other apps. Note: the {} cannot be omitted.
|
||||
;; - {time}: capture time
|
||||
;; - {date}: capture date using current date format, use `[[{date}]]` to get a page reference
|
||||
;; - {text}: text that users selected before sharing.
|
||||
;; - {url}: URL or assets path for media files stored in Logseq.
|
||||
;; You can also reorder them or use only one or two of them in the template.
|
||||
;; You can also insert or format any text in the template, as shown in the following examples.
|
||||
;; :quick-capture-templates
|
||||
;; {:text "[[quick capture]] **{time}**: {text} from {url}"
|
||||
;; :media "[[quick capture]] **{time}**: {url}"}
|
||||
|
||||
;; Quick capture options.
|
||||
;; - insert-today? Insert the capture at the end of today's journal page (boolean).
|
||||
;; - redirect-page? Redirect to the quick capture page after capturing (boolean).
|
||||
;; - default-page The default page to capture to if insert-today? is false (string).
|
||||
;; - prettify-url? Whether urls to YouTube or X should be wrapped with {{video ...}} or {{twitter ...}}
|
||||
;; :quick-capture-options
|
||||
;; {:insert-today? false ;; Default value: true
|
||||
;; :redirect-page? false ;; Default value: false
|
||||
;; :default-page "quick capture" ;; Default page: "quick capture"
|
||||
;; :prettify-url? true} ;; Default value: true
|
||||
|
||||
|
||||
;; File sync options
|
||||
;; Ignore these files when syncing, regexp is supported.
|
||||
;; :file-sync/ignore-files []
|
||||
|
||||
;; Configure the Enter key behavior for
|
||||
;; context-aware editing with DWIM (Do What I Mean).
|
||||
;; context-aware Enter key behavior implies that pressing Enter will
|
||||
;; have different outcomes based on the context.
|
||||
;; For instance, pressing Enter within a list generates a new list item,
|
||||
;; whereas pressing Enter in a block reference opens the referenced block.
|
||||
;; :dwim/settings
|
||||
;; {:admonition&src? true ;; Default value: true
|
||||
;; :markup? false ;; Default value: false
|
||||
;; :block-ref? true ;; Default value: true
|
||||
;; :page-ref? true ;; Default value: true
|
||||
;; :properties? true ;; Default value: true
|
||||
;; :list? false} ;; Default value: false
|
||||
|
||||
;; Configure the escaping method for special characters in page titles.
|
||||
;; Warning:
|
||||
;; This is a dangerous operation. To modify the setting,
|
||||
;; access the 'Filename format' setting and follow the instructions.
|
||||
;; Otherwise, You may need to manually rename all affected files and
|
||||
;; re-index them on all clients after synchronization.
|
||||
;; Incorrect handling may result in messy page titles.
|
||||
;; Available options:
|
||||
;; - :triple-lowbar (default)
|
||||
;; ;use triple underscore `___` for slash `/` in page title
|
||||
;; ;use Percent-encoding for other invalid characters
|
||||
|
||||
;; use relative path here only for ci test, won't work on the Electron client
|
||||
:zotero/settings-v2 {"default" {:type-id "1234567", :prefer-citekey? false, :attachments-block-text "Attachments", :page-insert-prefix "", :extra-tags "", :zotero-linked-attachment-base-directory "../book", :zotero-data-directory "../zotero"}}
|
||||
:file/name-format :triple-lowbar}
|
||||
@@ -0,0 +1 @@
|
||||
.foo {}
|
||||
@@ -0,0 +1 @@
|
||||
logseq.api.show_msg('hello good sir!');
|
||||
@@ -0,0 +1 @@
|
||||
{0 {2.5 3.45}}
|
||||
@@ -0,0 +1,4 @@
|
||||
parent:: [[Thing]]
|
||||
|
||||
- block with date property value that doesn't have the same format as the current date format
|
||||
misconfigured-date:: [[2021_12_06]]
|
||||
@@ -0,0 +1,3 @@
|
||||
tags:: Movie
|
||||
|
||||
-
|
||||
@@ -0,0 +1 @@
|
||||
type:: [[Class]]
|
||||
@@ -0,0 +1 @@
|
||||
parent:: [[CreativeWork]]
|
||||
@@ -0,0 +1,2 @@
|
||||
parent:: [[HumanConcept]]
|
||||
- this page triggers bug with a class created via :parent that is then used by :type
|
||||
@@ -0,0 +1 @@
|
||||
parent:: [[Thing]]
|
||||
@@ -0,0 +1 @@
|
||||
- Notes not about new Task class
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
- Attachments
|
||||
- [Understanding EXPLAIN.pdf](zotero://select/library/items/QDM8H6EH) {{zotero-linked-file "it/Understanding EXPLAIN.pdf"}}
|
||||
- Notes
|
||||
- ((697874ba-26e9-4e8a-a55d-0639d337dcc6)) definition
|
||||
- ((69787518-9eb8-4fd0-ad3b-b394e28bb547)) select
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
type:: [[Tool]]
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
alias:: Whiteboard tool, Tool, Tools
|
||||
type:: [[Class]]
|
||||
parent:: [[Feature]]
|
||||
description:: Tools on the [[Whiteboard/Toolbar]]
|
||||
@@ -0,0 +1,6 @@
|
||||
filters:: {"oct 9th, 2024" true, "ref2" false}
|
||||
type:: [[LargeLanguageModel]]
|
||||
tags:: ai, #fun, [[LargeLanguageModel]]
|
||||
alias:: gpt
|
||||
|
||||
- some text
|
||||
@@ -0,0 +1 @@
|
||||
-
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
file:: [Sina_de_Capoeria_Batizado_2025_-_Program_Itinerary_1752179325104_0.pdf](../assets/Sina_de_Capoeria_Batizado_2025_-_Program_Itinerary_1752179325104_0.pdf)
|
||||
file-path:: ../assets/Sina_de_Capoeria_Batizado_2025_-_Program_Itinerary_1752179325104_0.pdf
|
||||
|
||||
- id:: 687022ae-dac1-42a6-9d4c-39a0dba05918
|
||||
ls-type:: annotation
|
||||
hl-page:: 1
|
||||
hl-color:: yellow
|
||||
hl-type:: area
|
||||
hl-stamp:: 1752179374600
|
||||
- Duke School - modified
|
||||
hl-page:: 8
|
||||
ls-type:: annotation
|
||||
id:: 68702394-3613-4bac-85a7-28643d58237f
|
||||
hl-color:: blue
|
||||
- note about duke
|
||||
- sub note
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
file:: [Understanding EXPLAIN.pdf](../../book/it/Understanding EXPLAIN.pdf)
|
||||
file-path:: ../../book/it/Understanding EXPLAIN.pdf
|
||||
|
||||
- EXPLAIN is a really nice command that gives you lots of information but it's often easy to not know what to do with all this
|
||||
ls-type:: annotation
|
||||
hl-page:: 6
|
||||
hl-color:: yellow
|
||||
id:: 697874ba-26e9-4e8a-a55d-0639d337dcc6
|
||||
- [:span]
|
||||
ls-type:: annotation
|
||||
hl-page:: 8
|
||||
hl-color:: green
|
||||
id:: 69787518-9eb8-4fd0-ad3b-b394e28bb547
|
||||
hl-type:: area
|
||||
hl-stamp:: 1769501975346
|
||||
- Conclusion
|
||||
ls-type:: annotation
|
||||
hl-page:: 42
|
||||
hl-color:: blue
|
||||
id:: 69787540-7a52-40af-a70a-cedd315934cf
|
||||
@@ -0,0 +1,15 @@
|
||||
file:: [zlib.pdf](../../zotero/RX5JS7SY/zlib.pdf)
|
||||
file-path:: ../../zotero/storage/RX5JS7SY/zlib.pdf
|
||||
|
||||
- The zlib library is a general purpose data compression library.
|
||||
ls-type:: annotation
|
||||
hl-page:: 1
|
||||
hl-color:: red
|
||||
id:: 69787399-f51c-45a2-8971-78dc6c66a0ec
|
||||
- [:span]
|
||||
ls-type:: annotation
|
||||
hl-page:: 1
|
||||
hl-color:: blue
|
||||
id:: 697873d7-5953-4753-897e-62ac47348634
|
||||
hl-type:: area
|
||||
hl-stamp:: 1769501651181
|
||||
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
type:: [[Priority]]
|
||||
@@ -0,0 +1,4 @@
|
||||
alias:: y
|
||||
description:: page property triggers aliased namespace bug
|
||||
|
||||
- some content
|
||||
@@ -0,0 +1,4 @@
|
||||
prop-num2:: 10
|
||||
|
||||
- test if pre-block child causes issue
|
||||
- grandchild test
|
||||
@@ -0,0 +1 @@
|
||||
- HA
|
||||
@@ -0,0 +1,6 @@
|
||||
prop-string:: yeehaw
|
||||
prop-num:: 5
|
||||
prop-bool:: true
|
||||
tags:: [[Some / Namespace ]]
|
||||
|
||||
- has some content
|
||||
@@ -0,0 +1 @@
|
||||
url:: http://www.w3.org/1999/02/22-rdf-syntax-ns#type
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
- This is a highlights page that doesn't start with 'hls__' and isn't linked to a specific asset file
|
||||
- blarg blarg
|
||||
ls-type:: annotation
|
||||
hl-page:: 110
|
||||
hl-color:: purple
|
||||
id:: 654bafc6-f7e8-4633-b6a6-810dc41cc559
|
||||
@@ -0,0 +1,4 @@
|
||||
type:: [[Property]]
|
||||
url:: {{docs-base-url url}}
|
||||
sameAs:: https://schema.org/url
|
||||
rangeIncludes:: [[Property]]
|
||||
Loaded 100 of 2016 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user