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) <noreply@anthropic.com>
This commit is contained in:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user