Skip to content

feat(converter): add linkStyle auto for site-aware link rendering - #267

Merged
pchuri merged 2 commits into
mainfrom
feat/link-style-auto
Oct 3, 2026
Merged

pchuri merged 2 commits into
mainfrom
feat/link-style-auto

Conversation

@pchuri

@pchuri pchuri commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Problem

linkStyle is one global switch. On Confluence Cloud, a page that mixes links to other Confluence pages with links to external sites cannot be rendered correctly by any single value: smart turns external links into cards that drop the author's link text, while plain loses the card for internal links.

Changes

  • New linkStyle value auto: links into the configured Confluence site render as smart links (data-card-appearance="inline"), every other link renders as a plain <a href>.
  • Set it like the existing values, through the profile's linkStyle or CONFLUENCE_LINK_STYLE=auto.
  • createInternalLinkMatcher() in lib/link-style.js decides what is internal. It builds the site base from buildUrl(webUrlPrefix || '/') and compares the parsed origin plus a path-segment boundary, so look-alike hosts (example.atlassian.net.evil.test, ...@evil.test) and paths (/wikiother, /wiki/../jira) stay plain.
  • MacroConverter passes the matcher to htmlToStorage only when the style is auto; convertLink() picks smart or plain per link.
  • README and the plugin SKILL.md document the new value.

Behavior notes

  • #anchor links are unchanged (they already short-circuit linkStyle).
  • Relative links render plain.
  • Without a configured site (a converter built without buildUrl), every link renders plain.
  • Existing values and the Cloud/Server defaults are unchanged.
  • read --format markdown returns the same [text](href) under every style, so a page uploaded with auto reads back identically.
  • confluence convert does not pass linkStyle today, so it is unaffected.

Testing

  • New tests/link-style.test.js covers internal/external classification (host case, default port, userinfo tricks, path boundaries, relative paths, non-http schemes, no-site fallbacks).
  • Added converter, client, config and htmlToStorage tests, including the example from the issue and the storage → markdown round trip.
  • npm test (40 suites, 1517 tests) and eslint pass.

Closes #259

pchuri added 2 commits October 4, 2026 02:08
linkStyle was a single global switch, so a page mixing links to other
Confluence pages with links to external sites could not render both
correctly on Cloud: smart cards drop the author's link text for
external links, while plain links lose the card for internal ones.

The new `auto` value renders links into the configured site as smart
links and every other link as a plain link. A link is internal when its
parsed origin matches the site and its path is inside the context path,
so look-alike hosts stay plain. Relative links, and conversions without
a configured site, render plain. Existing values and defaults are
unchanged.

Closes #259
- Reword the invalid linkStyle warning, which said "auto-detection"
  now that auto is itself a valid value.
- Document the Server/Data Center and scoped-token gateway caveats.
- Add tests for context-path sites, unusual hrefs, createLocalConverter
  and the gateway fallback.
@pchuri
pchuri merged commit 5fcbabd into main Oct 3, 2026
6 checks passed
@pchuri
pchuri deleted the feat/link-style-auto branch October 3, 2026 22:55
github-actions Bot pushed a commit that referenced this pull request Oct 3, 2026
# [2.26.0](v2.25.11...v2.26.0) (2026-10-03)

### Features

* **converter:** add linkStyle auto for site-aware link rendering ([#267](#267)) ([5fcbabd](5fcbabd)), closes [#259](#259)
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] linkStyle mode that renders internal links as smart cards and external links as plain links

1 participant