Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pdl-live-react/src/view/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export default function Result({
term = "Result",
limitHeight = false,
}: Props) {
const isCode = !!lang && lang !== "plaintext" && !!result
const isCode =
!!lang &&
lang !== "plaintext" &&
!!result &&
typeof result !== "number" &&
typeof result !== "boolean"

const innerContent = isCode ? (
<Code block={result} language={lang} />
Expand Down
4 changes: 2 additions & 2 deletions pdl-live-react/src/view/Value.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Code from "./code/Code"
import Markdown from "./Markdown"

type Props = { children: number | string | unknown }
type Props = { children: boolean | number | string | unknown }

function isJson(s: string) {
try {
Expand All @@ -14,7 +14,7 @@ function isJson(s: string) {

export default function Value({ children: s }: Props) {
return typeof s === "number" ? (
s
<div className="pdl-markdown">{s}</div>
) : typeof s === "string" ? (
isJson(s) ? (
<Code block={s} language="json" />
Expand Down
2 changes: 1 addition & 1 deletion pdl-live-react/src/view/masonry/Tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Tile = {
timezone?: string

lang?: import("../code/Code").SupportedLanguage
content: string
content: string | number | boolean

footer1Key?: string
footer1Value?: string | number | boolean
Expand Down
8 changes: 6 additions & 2 deletions pdl-live-react/src/view/masonry/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export default function computeModel(block: import("../../pdl_ast").PdlBlock) {
resultForDisplay:
typeof block.pdl__result === "object"
? stringify(block.pdl__result)
: String(block.pdl__result),
: typeof block.pdl__result === "string" ||
typeof block.pdl__result === "number" ||
typeof block.pdl__result === "boolean"
? block.pdl__result
: String(block.pdl__result),
meta: undefined,
lang:
typeof block.pdl__result === "object"
Expand Down Expand Up @@ -153,7 +157,7 @@ function withDefs(block: NonScalarPdlBlock, tiles: Tile[]) {
? "json"
: (v.parser as Tile["lang"])
: undefined,
content: hasScalarResult(v) ? String(v.pdl__result) : "",
content: hasScalarResult(v) ? v.pdl__result : "",
},
)),
...tiles,
Expand Down