Skip to content

Conversation

@megayu
Copy link
Collaborator

@megayu megayu commented Jan 26, 2026

  • fix multiline block containing attributes will be truncated and lose data, content like "1\nbackground-color:: red\n2"
  • fix block attribute name contains "/" will broke, now change "/" to "-", like "key/value:: 1\n1"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issues in the file-graph → DB import pipeline where (1) multi-line block content could be truncated when properties are present, and (2) property names containing / could break during import.

Changes:

  • Add a regression fixture + assertions to ensure multi-line blocks with properties preserve non-property lines in :block/title.
  • Normalize file relative paths before filtering logseq/ and assets/ directories during import.
  • Sanitize property names by converting / to - during property extraction.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
deps/graph-parser/test/resources/exporter-test-graph/journals/2024_08_07.md Adds a multi-line block containing a property line to reproduce the truncation scenario.
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs Extends importer integration tests to assert the fixed multi-line block title behavior.
deps/graph-parser/src/logseq/graph_parser/exporter.cljs Normalizes relative paths before checking logseq/ and assets/ prefixes.
deps/graph-parser/src/logseq/graph_parser/block.cljs Updates property key normalization (/-) and adjusts title handling for blocks with properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 228 to 231
k (-> (string/lower-case k)
(string/replace "/" "-")
(string/replace " " "-")
(string/replace "_" "-"))]
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new property-name normalization replaces "/" with "-", but there’s no test covering this behavior. Please add a unit test (e.g., in logseq.graph-parser.block-test/test-extract-properties) asserting that an input property like "key/value" is parsed as :key-value (and ideally that refs/page-refs behave as expected).

Copilot uses AI. Check for mistakes.
Comment on lines 779 to +783
options' (assoc options
:remove-properties?
(and export-to-db-graph?
(and (gp-property/properties-ast? (first (get all-blocks (dec block-idx))))
(= "Custom" (ffirst (get all-blocks (- block-idx 2)))))))
(or prev-block-custom-query?
(and prev-block-properties? (not prev-block-custom-query?)))))
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :remove-properties? predicate can be simplified: (or prev-block-custom-query? (and prev-block-properties? (not prev-block-custom-query?))) is equivalent to just prev-block-properties? (since prev-block-custom-query? implies prev-block-properties?). Simplifying this would also let you drop the prev-block-custom-query? local, and update the nearby comment accordingly (it currently mentions only custom queries).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants