feat: embed any standalone http(s) URL as an external-article card (#262)#266
Open
katanumahotori wants to merge 1 commit into
Open
feat: embed any standalone http(s) URL as an external-article card (#262)#266katanumahotori wants to merge 1 commit into
katanumahotori wants to merge 1 commit into
Conversation
Standalone URLs that match no specific embed pattern previously stayed as plain unlinked text in the published article. note.com's own editor turns any pasted URL into a link card, so mirror that behavior: - get_embed_service() falls back to 'external-article' for any other http(s) URL (specific patterns still take precedence). Non-http(s) strings keep returning None. - resolve_embed_keys() now degrades a figure to a visible link paragraph when key registration fails, instead of leaving an unregistered placeholder key that note.com's frontend renders as nothing (silent content loss). - _convert_standalone_embed_urls() unescapes HTML entities before matching, so query strings containing '&' (e.g. Amazon affiliate URLs) are not double-escaped. Update unit tests for the new semantics and add coverage for the fallback, the link degradation, and the '&' handling.
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.
Closes #262
Problem
Standalone URLs outside the embed allowlist end up as plain unlinked text in the published article (
<p>https://example.com</p>), while note.com's own editor turns any pasted URL into a link card.Changes
get_embed_service(): falls back to'external-article'for any http(s) URL that matches no specific pattern. Specific patterns keep precedence; non-http(s) strings still returnNone. This reuses the exact mechanism already in place for Zenn / Qiita / connpass (/v2/embed_by_external_apiwithservice=external-article).resolve_embed_keys(): when key registration fails, the figure is degraded to a visible<a>link paragraph instead of keeping an unregistered placeholder key (which note.com's frontend renders as nothing → silent content loss, see Issue feat: 埋め込みURL (YouTube, Twitter, note.com) のAPI化 #116)._convert_standalone_embed_urls(): unescape HTML entities before matching, so query strings containing&(e.g. Amazon affiliate URLs, escaped to&by markdown-it) are neither mis-matched nor double-escaped.Tests
&round-trip for query-string URLs.uv run pytest tests/unit tests/integration: all pass (except 2 pre-existingtest_auth_browserfailures unrelated to this change).ruff check/mypy: clean.Verified E2E
Confirmed on a real note.com article (2026-06-10): 10 standalone URLs (personal site pages, an LP with query string, and 3 Amazon product URLs with affiliate parameters) were all registered via
/v2/embed_by_external_apiand render as proper link cards on the live page.🤖 Generated with Claude Code