DB: text export expands a deprecated {{embed [[page]]}} macro into the page's content

Open
#1,445 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
clojure
Domain
frontend

Research direction

The expansion happens in replace-block&page-embeds in frontend.handler.export.common-impl, and the three assertions to revisit are in frontend.handler.export-test (export-blocks-as-markdown-without-properties, export-blocks-as-markdown-newline-after-block, export-blocks-as-markdown-level<N>). Before changing code, a maintainer needs to decide whether DB graphs should keep expansion (B) or write the macro as text (A); the issue has no decision yet. If A is chosen, done means export and paste round-trip a block with an embed macro unchanged.

Written by the indexing model from the issue text.

Description

In a DB graph, a block whose text contains the file-graph embed macro, e.g.

Groceries {{embed [[Shopping]]}}

is shown as "Groceries" and the deprecated-macro warning (frontend.components.block, :block.macro/embed-deprecated); the Shopping page's blocks are not shown. DB embeds are :block/link blocks made with the embed command.

Exporting that block as text (Copy as / Export as Markdown) writes the Shopping page's blocks in place of the macro:

- Groceries
- milk
- eggs

So the export contains content the block does not show, and pasting the export back gives three blocks instead of the one block. If the embedded page is empty, the macro disappears from the export without a trace (- Groceries).

The expansion is done by replace-block&page-embeds in frontend.handler.export.common-impl (code from file graphs, where the macro did show the page). Three tests in frontend.handler.export-test assert it for the text export: export-blocks-as-markdown-without-properties, export-blocks-as-markdown-newline-after-block, export-blocks-as-markdown-level<N.

Which is intended for DB graphs?

  • A. The text export writes the macro as text (- Groceries {{embed [[Shopping]]}}), the way the block shows it; export and paste give back the same block. Those three tests change.
  • B. The text export keeps expanding the macro, as now.

Found by fuzzing export as text → paste. Happy to send the PR for A with tests.

Dominant language
No language data
Stars
29
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from logseq/db-test

All issues in logseq/db-test

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.