Skip to content

fix(import): a code block's properties after its closing fence - #13757

Merged
tiensonqin merged 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/import-properties-after-fence
Oct 16, 2026
Merged

tiensonqin merged 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/import-properties-after-fence

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor

Importing a file graph turns a code block that has properties into a plain text block. File graphs write a code block's properties after its closing fence, e.g. the id:: every referenced or embedded code block gets:

- ```clojure
  (x 1)

id:: 11111111-1111-4111-8111-111111111112
rating:: 5


imports as a block whose title is the whole text including `id:: ...` and `rating:: 5`, with no code display type and no language. (The uuid is read, so refs and embeds still find the block, but they show the raw text.) Found by fuzzing the Markdown mirror through the importer.

## Cause

`remove-properties` in `logseq.graph-parser.property` removes Markdown property lines only right after a block's first line. For a block that starts with a fence, the property lines come after the closing fence, so they stay in the title, and `handle-code-blocks` then sees text after the fence and does not make a code block.

## Fix

For a block whose first line opens a code (```` ``` ````) or math (`$$`) fence, the property lines right after the closing fence are removed from the title, like the ones after the first line of any other block.

## Test

`import-code-block-with-properties-after-its-fence` in `logseq.graph-parser.exporter-test`: the block's title is `(x 1)`, it is a code block with language `clojure`, and it has the `rating` property. On master 3 of the 4 assertions fail; with the fix they pass. The graph-parser property, block, extract, text and mldoc tests and the other importer tests pass.

The text loops' remaining cases are logseq/db-test#1442.

yuxi-liu-wired and others added 4 commits October 16, 2026 12:29
…ing fence

File graphs write a code block's properties (its id:: for a ref or embed, any user property) after the closing fence. remove-properties only removed property lines right after the first line, so they stayed in the title and the block was imported as text instead of a code block.
…gs; TODO $$ is a math block

handle-code-blocks and handle-math replaced the block's tags with the Code or Math tag, dropping Task and user tags. The math check ran before the task marker was removed, so a TODO math block imported as text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants