From 36984657a80c7cc003d4a4f5c1dc2a1eb38ef199 Mon Sep 17 00:00:00 2001 From: ChemaVX Date: Fri, 8 May 2026 10:44:38 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20Ghost=205.x=20=E2=80=94=20usar=20mobiled?= =?UTF-8?q?oc+HTML=20card=20en=20lugar=20del=20campo=20html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El campo "html" en Ghost Admin API v5 (Lexical editor) es de solo lectura. El contenido se debe enviar via mobiledoc con HTML card, que Ghost acepta en todas las versiones de v5 y renderiza sin conversión. Añadidos logs de diagnóstico y validación de HTML vacío. Co-Authored-By: Claude Sonnet 4.6 --- src/generator/generator.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/generator/generator.py b/src/generator/generator.py index e41c772..51acf31 100644 --- a/src/generator/generator.py +++ b/src/generator/generator.py @@ -260,13 +260,32 @@ class GhostPublisher: tags: list[str] | None = None) -> dict: import aiohttp as _aio import markdown as _md + clean = _strip_researchowl_header(markdown_content) html = _md.markdown(clean, extensions=["extra"]) + + logger.info("Ghost publish_draft", html_length=len(html), + html_preview=html[:200]) + + if not html.strip(): + raise ValueError("Ghost: HTML vacío tras conversión markdown — contenido no enviado") + + # Ghost 5.x (Lexical editor): el campo "html" es solo de lectura en la API. + # La forma fiable de enviar HTML arbitrario es via mobiledoc con HTML card, + # que Ghost acepta en todas las versiones de v5 y renderiza sin conversión. + mobiledoc = json.dumps({ + "version": "0.3.1", + "atoms": [], + "cards": [["html", {"html": html}]], + "markups": [], + "sections": [[10, 0]], + }) + token = self._make_token() body = { "posts": [{ "title": title, - "html": html, + "mobiledoc": mobiledoc, "status": "draft", "tags": [{"name": t} for t in (tags or ["investigacion"])], }]