fix: encode block highlight in Text/OPML/HTML export by dannyinit · Pull Request #13174 · logseq/logseq · GitHub
Skip to content

fix: encode block highlight in Text/OPML/HTML export - #13174

Open
dannyinit wants to merge 1 commit into
logseq:masterfrom
dannyinit:fix/8663-highlight-export
Open

fix: encode block highlight in Text/OPML/HTML export#13174
dannyinit wants to merge 1 commit into
logseq:masterfrom
dannyinit:fix/8663-highlight-export

Conversation

@dannyinit

Copy link
Copy Markdown
Contributor

Fixes #8663

Problem

Highlighting a block (right-click bullet → pick a color) is completely dropped when exporting a page as Text, OPML, or HTML. The highlight is stored as the :logseq.property/background-color block property, but that property is marked :hide? true (so it doesn't clutter the properties UI), and export code filters out all :hide? true properties, dropping the highlight along with it.

Fix

When generating export content, wrap a highlighted block's text in ^^...^^ (Logseq's existing inline highlight markup) if the block has background-color set. This is gated behind a new :encode-highlight-as-mark? option only passed by the actual "Export page" feature, so it does not affect markdown-mirror generation (which shares the same underlying file.cljs code). Text and OPML export then just preserve ^^...^^ as-is (already handled), and HTML export already turns ^^...^^ into a real <mark> tag, so the block renders as visibly highlighted.

Note: this preserves that a block was highlighted, not which of the 7 colors was picked, since ^^text^^ has no color parameter. Capturing the exact color would need a new syntax extension, which felt like a separate, larger discussion.

Testing

Reproduced and verified manually against a fresh DB graph, including two highlighted blocks in a parent/child structure:

  • Before fix: none of the 3 export formats showed any trace of the highlight.
  • After fix: Text/OPML preserve ^^text^^, HTML renders <mark>text</mark> for both blocks at both nesting levels.
  • Added a unit test confirming the markdown-mirror feature is unaffected (it shares the same underlying code but should never encode highlights, since it isn't the "Export page" feature).
  • bb dev:lint-and-test: 0 lint errors/warnings, full unit test suite passes (0 failures/errors).

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.

Text highlighting/color background is excluded from export

1 participant