Repository navigation
feat(mirror): write block refs, embeds and block node values by block id - #13740
Closed
yuxi-liu-wired wants to merge 3 commits into
Closed
yuxi-liu-wired wants to merge 3 commits into
yuxi-liu-wired wants to merge 3 commits into
Conversation
A block that something points at gets an id:: line; block refs are written as ((uuid)), block embeds as {{embed ((uuid))}}, node property values that are blocks as ((uuid)). The mirror files then resolve in any reader of Logseq Markdown, including the Markdown importer. Writing an embed as a reference also ends the endless recursion on a block that embeds its own ancestor.
An embedded or referenced code block got no id line (it would be inside the fence), so the embed did not resolve. The id goes after the closing fence, as file graphs write it.
The embed macro replaced the block's rendered line, heading marker included. The line matcher also takes an empty block's heading marker (###) for the empty block (the same change as in logseq#13742).
yuxi-liu-wired
force-pushed
the
fix/mirror-block-ids
branch
from
October 16, 2026 18:36
f29c5dd to
4e24362
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
Contributor
Author
|
Combined with the other PRs that change the same files into #13784. |
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 17, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 19, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 19, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 20, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 21, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 21, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 22, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 22, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 23, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 24, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 24, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 25, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 25, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 26, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 29, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 29, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 30, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 30, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 31, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 31, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 1, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 2, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 3, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 3, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 4, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 11, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 11, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 12, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 12, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 13, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 14, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 15, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 17, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 17, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 18, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 19, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal: the Markdown mirror writes block references, block embeds and node property values that are blocks by block id, and gives the block they point at an
id:: <uuid>line. With that, the mirror files resolve in any reader of Logseq Markdown, including Logseq's own Markdown importer.Why
The mirror refers to blocks by uuid but never writes the uuid where a reader can find it:
[[uuid]], and the target block has noid::line. No reader of the files can resolve it; Logseq's Markdown importer drops the ref.RangeError: Maximum call stack size exceeded, and that page is not mirrored.)[[block title]], which reads back as a link to a page with that title.These came from fuzzing the loop mirror → Markdown importer: random pages mirrored, the files imported as a file graph into a fresh DB graph, blocks compared.
ADR 0016 says the mirror is not a backup format with guaranteed import fidelity, and that is unchanged. But the mirror is meant to be read by external tools, and a reference that points at nothing is a hole in what they read.
id:: <uuid>under the target block is the existing Logseq Markdown syntax for block identity (file graphs use it, the importer reads it), so this needs no new syntax.Change
logseq.common.export.file: new context option:export-block-refs-as-uuid-refs?. With it, a[[uuid]]whose target is a block (not a page) is written as((uuid)), in titles and in property value blocks, and a:nodeproperty value that is a block is written as((uuid)). Other exports do not set it and are unchanged.frontend.worker.markdown-mirror::block/_refsor:block/_link) getsid:: <uuid>after its line; a code block gets it after its closing fence, as file graphs write it (inside the fence it would be code);{{embed ((uuid))}}instead of a copy of the target (this also removes the recursion);:block/refsor:block/linkalso re-mirrors the target's page, so itsid::line appears and disappears with the references.docs/adr/0016-markdown-mirror.md(Markdown Content 7, new 8) anddocs/logseq-markdown-syntax.md(References) describe the new output.Example:
Blocks nothing points at look exactly as before.
Test
page-mirror-writes-block-refs-embeds-and-node-values-by-block-id-testinfrontend.worker.markdown-mirror-test: mirrors a target block, a block ref, a block embed and a node property value, checks both files, then imports the files with the file-graph importer (logseq.graph-parser.exporter/export-file-graph) and checks the target keeps its uuid, the ref points at it and the embed links it. It fails on master and passes with the change.page-mirror-writes-a-code-block-id-after-its-fence-testchecks an embedded code block.page-mirror-renders-embedded-node-content-and-tags-test(which expected the embed copy) is renamed and now expects the embed macro. The other mirror and export tests pass.A code block whose properties come after its fence imports as text on master; #13757 fixes that in the importer, so with both the code block also comes back as a code block.
The text loops' remaining cases are logseq/db-test#1442.