Skip to content

Commit

Permalink
docs: preserve empty line rendering in code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalbdivad committed Jan 4, 2025
1 parent d2ce054 commit 8909026
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ark/docs/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ div.twoslash-popup-container {
white-space: pre;
}

/** avoid empty lines being rendered with 0 height */
.twoslash .line {
min-height: 20px;
}

.completions-block code {
padding-bottom: 3rem;
}
Expand Down
10 changes: 9 additions & 1 deletion ark/docs/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { propwiseXor } from "@ark/util"
import { throwInternalError, type propwiseXor } from "@ark/util"
import type { HighlightOptions } from "fumadocs-core/server"
import { Popup, PopupContent, PopupTrigger } from "fumadocs-twoslash/ui"
import { cn } from "fumadocs-ui/components/api"
Expand Down Expand Up @@ -55,6 +55,14 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
}) => {
children ??= snippetContentsById[fromFile!]

if (!children) {
throwInternalError(
fromFile ?
`Specified snippet '${fromFile}' does not have a corresponding file`
: `CodeBlock requires either a fromFile prop or a string child representing its text contents`
)
}

const highlighted = highlight(lang, children)

return (
Expand Down

0 comments on commit 8909026

Please sign in to comment.