Repository navigation
fix(export): block embeds, block ids in the mirror, and quotes holding lists - #13784
yuxi-liu-wired wants to merge 7 commits into
Conversation
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
| the `((uuid))` that points at it." | ||
| [block] | ||
| (and (not (ldb/page? block)) | ||
| (boolean (or (seq (:block/_refs block)) |
There was a problem hiding this comment.
referenced-block? is documented as true for a block ref, an embed, or a node-property value, but it only looks at :block/_refs and :block/_link.
A node property is stored on its own attribute. rebuild-block-refs adds that value to :block/refs only when page-or-object? is true (a page, or a block that has tags). An untagged block therefore gets source:: ((uuid)) from block-node-ref and no id:: line. affected-page-ids has the same gap: it refreshes the target page only for :block/refs and :block/link, so a property-only change on another page never rewrites the target file.
page-mirror-writes-block-refs-embeds-and-node-values-by-block-id-test also transacts :block/refs and :block/link onto the target, so it does not catch this. Treat a non-page block as referenced when a :node property datom points at it, and include that target's page in affected-page-ids.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
e5a8dd5 to
78776e8
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
78776e8 to
b4b8cee
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
b4b8cee to
1b0d215
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
1b0d215 to
3db45da
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
3db45da to
b9ec138
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
b9ec138 to
e0c7ad7
Compare
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
A block embed is a block linking to the embedded block (:block/link); the text export wrote the linking block's empty title, so the embed exported as an empty bullet.
…tions The Markdown mirror shares tree->file-content-aux and writes one line per block; the inlining is now turned on by :inline-block-embeds? in the text export's content config. The embedded block gets the export's open-blocks-only and include-properties options, the embedding block's own children are not written (the embed shows the embedded block's), and an embed cycle (a block embedding itself, or A embeds B embeds A) is written as the block itself.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
block->content-context-test compared the whole options map, so any key added to it broke the test: it now checks only its own keys. The nested embed test pinned the inline embed text logseq#13784 changes; dropped.
This PR combines #13718, #13740, #13771, which change the same files, into one branch on current master so they no longer conflict with each other. Each part is unchanged except where two of them touched the same lines.
#13718: fix(export): export a block embed as the embedded block
Exporting blocks as text writes a block embed as an empty bullet: the embedded block and its children are missing from the export.
Cause
In a DB graph a block embed is a block whose
:block/linkis the embedded block; its own title is empty.tree->file-content-auxinlogseq.common.export.filewrites each block's own title, so it writes-for the embed. (The export only resolves embeds written as{{embed ((uuid))}}text.)Fix
In the text export, a block with
:block/linkis written as the embedded block and its children, at the embed's level, as the embed shows them::inline-block-embeds?in the text export's content config, so the Markdown mirror, which sharestree->file-content-auxand matches one rendered line to one block, writes one line per block as before;open-blocks-onlyandinclude-propertiesoptions (block->contentkeeps:open-blocks-only?in the options it passes down);Test
In
frontend.handler.export-test:export-blocks-as-markdown-block-embed(a block that embeds a block with one child exports as- embeddedand\t- embedded child; a block embedding itself exports as-) andexport-blocks-as-markdown-block-embed-cycle-and-options(A embeds B embeds A; an embed block with a child of its own; an embed of a collapsed block with open-blocks-only). They fail on master and pass with the fix; the other export tests and the Markdown mirror tests (includingpage-mirror-renders-embedded-node-content-and-tags-test) still pass.#13740: feat(mirror): write block refs, embeds and block node values by block id
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.
#13771: fix(export): a quote holding a list does not fail the HTML export
HTML export of a block whose quote holds a list (
> * x,> 1. x, or* xinside#+BEGIN_QUOTE) fails with the string "Insert at top".block-quoteinfrontend/handler/export/html.cljsbuilt the quote's content in a zipper rooted at a bare[:blockquote]. The zipper's branches are:ulnodes, so that root has no children to move to. A paragraph inside the quote works, because it only edits the root node. A list callsadd-next-level-ul-at-righton the root, andclojure.zip/insert-rightat the root throws "Insert at top".The fix builds the quote's content in a zipper rooted like the page's (
[:ul [:placeholder]]), and puts the placeholder's items and the nodes after it into[:blockquote ...]. A quote holding paragraphs exports as before.export-helperis split intoexport-hiccup, which builds the hiccup, and the rendering. The tests check the hiccup, because the rendering's pretty-print step uses the browser'sDOMParser, which Node does not have.Found by a fuzzer that exports random Markdown as text, HTML and OPML.