Repository navigation
fix(docs): unify tab and accordion rendering - #16
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64a926b866
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| function NestedMarkdown({ item }: { item: Record<string, unknown> }): JSX.Element { | ||
| return ( | ||
| <MarkdownContent |
There was a problem hiding this comment.
Preserve block options in nested Markdown rendering
Pass the original DocsBlockOptions through this nested render instead of invoking MarkdownContent with defaults. When renderMarkdown disables a feature used inside a tab or accordion—for example, inlineMath: false for $x$ or nodes: false for a nested <Nodes> component—the outer parse honors the option, but this second parse silently re-enables the feature, so host-configured block opt-outs do not apply inside grouped content.
Useful? React with 👍 / 👎.
| stringifyDocBody( | ||
| Array.isArray(item.content) ? (item.content as unknown as DocBody) : undefined, | ||
| ) || (typeof item.markdown === 'string' ? item.markdown : '') |
There was a problem hiding this comment.
Escape literal Portable Text before reparsing it
Preserve unmarked Portable Text as literal text when converting structured item content to Markdown. stringifyDocBody emits span text without escaping Markdown metacharacters, and the new second parse therefore changes its meaning: for example, a normal span containing **not bold**, [label](url), or a leading # is now rendered as formatting, a link, or a heading, whereas the previous PortableTextBlockView rendered those characters literally. This affects existing structured tabs and accordions created or imported through the editor.
Useful? React with 👍 / 👎.
| */ | ||
| function Sections({ block }: { block: SectionsBlock }): React.JSX.Element { | ||
| return block._type === 'tabs' ? <TabsBlock block={block} /> : <AccordionBlock block={block} />; | ||
| return <MarkdownContent markdown={stringifyDocBody([block as unknown as ContentData[number]])} />; |
There was a problem hiding this comment.
Keep bracketed section titles renderable
Escape or otherwise avoid serializing section titles through the grouped Markdown delimiter syntax. An editor title containing ] is valid and previously rendered directly, but stringifyDocBody emits it as |||[title]with bracket] or ===[...]; markdownToDocsValue only recognizes titles matching [^\]\n]+, so the read-only editor preview no longer produces a tabs or accordion control for that block.
Useful? React with 👍 / 👎.
| stringifyDocBody( | ||
| Array.isArray(item.content) ? (item.content as unknown as DocBody) : undefined, | ||
| ) || (typeof item.markdown === 'string' ? item.markdown : '') |
There was a problem hiding this comment.
Preserve nested quiz blocks during serialization
Avoid dropping structured quiz blocks when rendering tab or accordion items. quiz is a supported Docs block and the previous NestedContent path rendered it with DocsQuizBlock, but stringifyDocBody has no quiz case, so an item whose content contains a quiz and has no cached markdown serializes to an empty string and renders nothing; in mixed content, the quiz is silently omitted while the other blocks remain.
Useful? React with 👍 / 👎.
| <MarkdownContent | ||
| markdown={ | ||
| stringifyDocBody( | ||
| Array.isArray(item.content) ? (item.content as unknown as DocBody) : undefined, | ||
| ) || (typeof item.markdown === 'string' ? item.markdown : '') | ||
| } | ||
| /> |
There was a problem hiding this comment.
Keep nested raw blocks displayed as source
Preserve the semantics of supported raw blocks instead of feeding their source back through the Markdown parser. Previously a nested raw block such as { _type: 'raw', markdown: '# Terra source' } rendered as source in a <pre>/CodeBlock; stringifyDocBody now returns that Markdown verbatim and this nested MarkdownContent interprets it as a heading. Canonical component text such as <Embed ... /> can likewise become an active rich block rather than remaining displayed source.
Useful? React with 👍 / 👎.
Summary
Validation
pnpm run quality— passed.pnpm run check— passed.pnpm run test:unit— 67 passed.pnpm run test:browser— passed; load budgets 27/27.pnpm run docs— built 15 pages.