diff --git a/db/model/Gdoc/enrichedToMarkdown.ts b/db/model/Gdoc/enrichedToMarkdown.ts index a186f85930..2556f74ef2 100644 --- a/db/model/Gdoc/enrichedToMarkdown.ts +++ b/db/model/Gdoc/enrichedToMarkdown.ts @@ -129,7 +129,9 @@ ${items} ) .with({ type: "code" }, (b): string | undefined => { return ( - "```\n" + b.text.map((text) => text.value).join("\n") + "\n```" + "```\n" + + b.text.map((text) => text.value.text).join("\n") + + "\n```" ) }) .with({ type: "donors" }, (_): string | undefined => diff --git a/db/model/Gdoc/enrichedToRaw.ts b/db/model/Gdoc/enrichedToRaw.ts index 5227f4263b..bc27e3356e 100644 --- a/db/model/Gdoc/enrichedToRaw.ts +++ b/db/model/Gdoc/enrichedToRaw.ts @@ -127,7 +127,10 @@ export function enrichedBlockToRawBlock( { type: "code" }, (b): RawBlockCode => ({ type: b.type, - value: b.text, + value: b.text.map((text) => ({ + type: "text", + value: text.value.text, + })), }) ) .with( diff --git a/db/model/Gdoc/exampleEnrichedBlocks.ts b/db/model/Gdoc/exampleEnrichedBlocks.ts index ebef8ce768..7e37a16bc2 100644 --- a/db/model/Gdoc/exampleEnrichedBlocks.ts +++ b/db/model/Gdoc/exampleEnrichedBlocks.ts @@ -125,8 +125,12 @@ export const enrichedBlockExamples: Record< type: "code", text: [ { - type: "text", - value: '', + type: "simple-text", + value: { + spanType: "span-simple-text", + text: '', + }, + parseErrors: [], }, ], parseErrors: [], diff --git a/db/model/Gdoc/rawToEnriched.ts b/db/model/Gdoc/rawToEnriched.ts index dd7dd7990f..a60bd1f4e7 100644 --- a/db/model/Gdoc/rawToEnriched.ts +++ b/db/model/Gdoc/rawToEnriched.ts @@ -500,8 +500,12 @@ const parseCode = (raw: RawBlockCode): EnrichedBlockCode => { return { type: "code", text: raw.value.map((text) => ({ - type: "text", - value: toAsciiQuotes(text.value), + type: "simple-text", + value: { + spanType: "span-simple-text", + text: toAsciiQuotes(text.value), + }, + parseErrors: [], })), parseErrors: [], } diff --git a/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts b/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts index d1a89ff651..cbb50d10c5 100644 --- a/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts +++ b/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts @@ -93,7 +93,7 @@ export type RawBlockCode = { export type EnrichedBlockCode = { type: "code" - text: RawBlockText[] + text: EnrichedBlockSimpleText[] } & EnrichedBlockWithParseErrors export type RawBlockDonorList = { @@ -368,6 +368,7 @@ export type EnrichedBlockSimpleText = { type: "simple-text" value: SpanSimpleText } & EnrichedBlockWithParseErrors + export type RawBlockHtml = { type: "html" value: string diff --git a/site/gdocs/components/ArticleBlock.tsx b/site/gdocs/components/ArticleBlock.tsx index 6f3b20da71..b499861802 100644 --- a/site/gdocs/components/ArticleBlock.tsx +++ b/site/gdocs/components/ArticleBlock.tsx @@ -249,7 +249,7 @@ export default function ArticleBlock({ .with({ type: "code" }, (block) => ( text.value).join("\n")} + code={block.text.map((text) => text.value.text).join("\n")} /> )) .with({ type: "donors" }, (_block) => (