From 707405b9402ba1951e6d6cd27f0dc9efe18e4446 Mon Sep 17 00:00:00 2001 From: Andrew Yim Date: Mon, 27 Apr 2026 11:37:07 +0900 Subject: [PATCH] docs(notion-writer): document mention pattern ordering and UUID format invariant Code review flagged two implicit invariants worth pinning with comments: - 'mention' must precede 'link' in INLINE_PATTERNS so the @[X](Y) prefix takes priority over plain link parsing - format_id_with_dashes is required because the Notion mention API expects a dashed UUID while extract_notion_id returns dashless 32/32 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- custom-skills/32-notion-writer/code/scripts/notion_writer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom-skills/32-notion-writer/code/scripts/notion_writer.py b/custom-skills/32-notion-writer/code/scripts/notion_writer.py index d87c4d6..ae63820 100644 --- a/custom-skills/32-notion-writer/code/scripts/notion_writer.py +++ b/custom-skills/32-notion-writer/code/scripts/notion_writer.py @@ -277,7 +277,7 @@ def _parse_lines(lines: List[str]) -> List[Dict[str, Any]]: INLINE_PATTERNS = [ ('code', re.compile(r'`([^`\n]+)`')), - ('mention', re.compile(r'@\[([^\]]+)\]\(([^)\s]+)\)')), + ('mention', re.compile(r'@\[([^\]]+)\]\(([^)\s]+)\)')), # must precede 'link' so @ takes priority ('link', re.compile(r'\[([^\]]+)\]\(([^)\s]+)\)')), ('bold_star', re.compile(r'\*\*([^*\n]+)\*\*')), ('bold_under', re.compile(r'__([^_\n]+)__')), @@ -352,6 +352,7 @@ def parse_rich_text(text: str) -> List[Dict[str, Any]]: mention_title, mention_target = m.group(1), m.group(2) page_id = extract_notion_id(mention_target) if page_id: + # Notion mention API requires dashed UUID; extract_notion_id returns dashless. spans.append({ "type": "mention", "mention": {