diff --git a/pdl-live-react/src/view/Result.tsx b/pdl-live-react/src/view/Result.tsx index 53fa7bb02..126b139d4 100644 --- a/pdl-live-react/src/view/Result.tsx +++ b/pdl-live-react/src/view/Result.tsx @@ -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 ? ( diff --git a/pdl-live-react/src/view/Value.tsx b/pdl-live-react/src/view/Value.tsx index 9a3ea176e..9efe82f71 100644 --- a/pdl-live-react/src/view/Value.tsx +++ b/pdl-live-react/src/view/Value.tsx @@ -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 { @@ -14,7 +14,7 @@ function isJson(s: string) { export default function Value({ children: s }: Props) { return typeof s === "number" ? ( - s +
{s}
) : typeof s === "string" ? ( isJson(s) ? ( diff --git a/pdl-live-react/src/view/masonry/Tile.ts b/pdl-live-react/src/view/masonry/Tile.ts index 12a2369de..91e61d0b5 100644 --- a/pdl-live-react/src/view/masonry/Tile.ts +++ b/pdl-live-react/src/view/masonry/Tile.ts @@ -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 diff --git a/pdl-live-react/src/view/masonry/model.ts b/pdl-live-react/src/view/masonry/model.ts index cfcc5a30a..54212891b 100644 --- a/pdl-live-react/src/view/masonry/model.ts +++ b/pdl-live-react/src/view/masonry/model.ts @@ -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" @@ -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,