fix: render latex-only block refs instead of empty chips - #13157
fix: render latex-only block refs instead of empty chips#13157tiensonqin wants to merge 2 commits into
Conversation
DB page-ref chips only map heading ast-title, so a $$...$$ block (or a Math-block display-type) drew empty [[]]. Show the formula inline in the chip and keep mixed-title latex titles unchanged. Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new page-ref math extraction currently walks the entire AST via tree-seq on the render path, which is avoidable and may regress performance when many page-ref chips render blocks with empty titles but large bodies (e.g. code blocks).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes DB-mode block-reference page-ref chips rendering as empty [[ ]] when the referenced block’s title is entirely display LaTeX (or a converted Math-block), by rendering the formula inline instead of relying solely on ast-title.
Changes:
- Add
displayed-math-formulahelper to extract formulas from standalone$$…$$titles. - Update block-title/page-ref rendering to show inline KaTeX for latex-only titles and
:mathdisplay-type blocks. - Add targeted CLJS tests plus page-ref-specific CSS tweaks to ensure inline rendering behaves correctly.
File summaries
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Trim Displayed_Math body text in parse assertions and use referred format.block helpers so kondo stays clean. Co-authored-by: Tienson Qin <tiensonqin@gmail.com>

Fixes empty
[[ ]]chips when a DB graph references a block whose entire content is display LaTeX.Related: logseq/db-test#1137
Same failure class as the closed stale db-test#687; this does not merge into #687.
What changed
A DB
[[uuid]]page-ref chip rendersblock-titlefrom headingast-titleonly. Standalone$$…$$parses asDisplayed_Mathinast-body, so the chip had no title while:block/titlewas still non-blank — brackets rendered around nothing. Converted Math-blocks hit the same chip via[:div.math-block]inside inlinea.page-ref.The chip now renders the formula inline for:
$$ x^2 + y^2 = z^2 $$)Mixed-title blocks such as
Pythagoras: $$ x^2 + y^2 = z^2 $$still use the heading title.Tests
frontend.format.block-test— latex-only vs mixed-titleparse-title-and-body/ formula extractionfrontend.components.block.page-ref-math-test— page-ref chips for latex-only, Math-block, and mixed-title controlfrontend.handler.db-based.editor-test,frontend.components.block.breadcrumb-model-test,frontend.handler.paste-testPage-ref chips now include the formula
To show artifacts inline, enable in settings.