feat(converter): add linkStyle auto for site-aware link rendering - #267
Merged
Merged
Conversation
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.
|
🎉 This PR is included in version 2.26.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
linkStyleis 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:smartturns external links into cards that drop the author's link text, whileplainloses the card for internal links.Changes
linkStylevalueauto: links into the configured Confluence site render as smart links (data-card-appearance="inline"), every other link renders as a plain<a href>.linkStyleorCONFLUENCE_LINK_STYLE=auto.createInternalLinkMatcher()inlib/link-style.jsdecides what is internal. It builds the site base frombuildUrl(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.MacroConverterpasses the matcher tohtmlToStorageonly when the style isauto;convertLink()pickssmartorplainper link.SKILL.mddocument the new value.Behavior notes
#anchorlinks are unchanged (they already short-circuitlinkStyle).buildUrl), every link renders plain.read --format markdownreturns the same[text](href)under every style, so a page uploaded withautoreads back identically.confluence convertdoes not passlinkStyletoday, so it is unaffected.Testing
tests/link-style.test.jscovers internal/external classification (host case, default port, userinfo tricks, path boundaries, relative paths, non-http schemes, no-site fallbacks).htmlToStoragetests, including the example from the issue and the storage → markdown round trip.npm test(40 suites, 1517 tests) andeslintpass.Closes #259