-
-
Notifications
You must be signed in to change notification settings - Fork 117
Handle quote having no rendered children #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughIntroduces a nullish-coalescing default for formattedContent in src/notion-to-md.ts to ensure it is a string before splitting, preventing runtime errors when both mdstr.parent and mdstr[pageIdentifier] are undefined. Quote formatting behavior remains the same. No public APIs changed. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
We have a block like
```json
{
"type": "quote",
"blockId": "<snip>",
"parent": "> <u>Table of Contents</u>",
"children": [
{
"type": "table_of_contents",
"blockId": "<snip>",
"parent": "",
"children": []
}
]
}
```
where `mdstr` ends up being `{}`, which without this causes a crash
f3cc281 to
cef9cd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/notion-to-md.ts (1)
153-159: Avoid stray blank line and de-duplicate conditionsWhen there’s no rendered child, the code still appends a newline (Line 159), which can produce an extra blank line. Also, the two branches append the same
formattedContent. Merge the conditions and only append the newline when content is actually appended.Apply this diff:
- if (pageIdentifier !== "parent" && mdstr["parent"]) { - mdOutput[pageIdentifier] += formattedContent; - } else if (mdstr[pageIdentifier]) { - mdOutput[pageIdentifier] += formattedContent; - } - - mdOutput[pageIdentifier] += "\n"; + const hasRenderableChild = + (pageIdentifier !== "parent" && !!mdstr["parent"]) || + !!mdstr[pageIdentifier]; + + if (hasRenderableChild) { + mdOutput[pageIdentifier] += formattedContent + "\n"; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notion-to-md.ts(1 hunks)
🔇 Additional comments (1)
src/notion-to-md.ts (1)
145-150: Defensive default prevents quote crash — LGTMUsing a nullish-coalescing fallback to an empty string ensures
.split("\n")is always called on a string. This addresses the crash when a quote’s child (e.g., an empty table_of_contents) yields no rendered content without altering behavior for non-empty cases.
Hey!
We have a block like
{ "type": "quote", "blockId": "<snip>", "parent": "> <u>Table of Contents</u>", "children": [ { "type": "table_of_contents", "blockId": "<snip>", "parent": "", "children": [] } ] }where
mdstrends up being{}, which without this causes a crashSummary by CodeRabbit