From 71ed67148bdb5c56ad6dbbf3bafc0f20c6db84fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ra=C4=8D=C3=A1k?= Date: Fri, 3 Jan 2025 18:23:37 +0100 Subject: [PATCH] Fix missing link to grapher in image caption --- db/model/Gdoc/GdocBase.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/model/Gdoc/GdocBase.ts b/db/model/Gdoc/GdocBase.ts index 69fe5c4961..754471c247 100644 --- a/db/model/Gdoc/GdocBase.ts +++ b/db/model/Gdoc/GdocBase.ts @@ -312,6 +312,17 @@ export class GdocBase implements OwidGdocBaseInterface { block: OwidEnrichedGdocBlock ): DbInsertPostGdocLink[] | void { const links: DbInsertPostGdocLink[] = match(block) + .with({ type: "image" }, (block) => { + const links: DbInsertPostGdocLink[] = [] + if (!block.caption) return links + for (const span of block.caption) { + traverseEnrichedSpan(span, (span) => { + const link = this.extractLinkFromSpan(span) + if (link) links.push(link) + }) + } + return links + }) .with({ type: "person" }, (block) => { if (!block.url) return [] return [ @@ -563,7 +574,6 @@ export class GdocBase implements OwidGdocBaseInterface { "heading", "horizontal-rule", "html", - "image", "key-indicator-collection", "list", "missing-data",