Skip to content

Mute a link's revealed target - #156

Merged
luca-chen198 merged 1 commit into
mainfrom
fix/mute-revealed-link-target
Aug 17, 2026
Merged

Mute a link's revealed target#156
luca-chen198 merged 1 commit into
mainfrom
fix/mute-revealed-link-target

Conversation

@luca-chen198

Copy link
Copy Markdown
Member

With the caret inside [text](url), the four brackets are tinted mutedText while the target between two of them keeps body colour. So the loudest ink in the document lands on the one run that is machine-readable rather than prose — and that disappears again the moment the caret leaves.

Every other construct mutes its syntax when it reveals it: the # of a heading, the > of a quote, the list markers, and — in this very function — the brackets themselves. The target was the exception.

for marker in markers { attrs.append((marker, [.foregroundColor: ctx.theme.mutedText])) }
+ // The target is syntax, revealed with its brackets and muted like them —
+ // at body color it is louder than the label it belongs to.
+ if isActive { attrs.append((urlRange, [.foregroundColor: ctx.theme.mutedText])) }

mutedText is secondaryLabelColor, so the target stays readable for editing — recessed, not hidden. The label keeps the faded link ink, and as before carries no .link attribute while active, so nothing inside an active link is followable.

Inactive links are untouched: the target is still collapsed to the hidden-marker font and cleared.

Tests — 345 pass. The new one is mutation-proved: removing the added line makes activeLinkTargetIsMuted fail.

This mirrors a change made in the iOS port (nodes-app/Nodes-Mobile), so both editors reveal a link the same way.

🤖 Generated with Claude Code

With the caret inside `[text](url)`, the four brackets are tinted
`mutedText` but the target between two of them keeps body color — the
loudest ink in the document, on the one run that is machine-readable
rather than prose, and that disappears again the moment the caret leaves.

Every other construct here mutes its syntax when it reveals it: the `#` of
a heading, the `>` of a quote, the list markers, and — in this very
function — the brackets themselves. The target was the exception.

`mutedText` is `secondaryLabelColor`, so it stays readable for editing; the
label keeps the faded link ink and, as before, no `.link` attribute while
active.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@luca-chen198
luca-chen198 merged commit 2dc7554 into main Aug 17, 2026
1 check passed
luca-chen198 added a commit to wildthink/swift-markdown-engine that referenced this pull request Aug 17, 2026
nodes-app#120 landed as a squash, so its content reached main under a new sha while
this branch still carries the original commits. The shared merge-base is
therefore still f6137df and git saw the directive files as added on both
sides.

Resolution, all three mechanical:
- MarkdownDirective.swift (add/add): took this branch's version, which is a
  strict superset of main's -- 78 lines added, none removed.
- ARCHITECTURE.md, CHANGELOG.md: main contributed nothing at the conflict
  point (its directive text arrived with the squash, above the marker), so
  this branch's styling paragraphs stand as written.

MarkdownASTStyler.swift auto-merged: main's link-target muting from nodes-app#156 sits
in styleLink and the directive branch sits in styleInlines, on disjoint
ranges.
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.

1 participant