feat(publish): render jianshu html images as markdown
Jianshu's HTML editor strips uploaded <img> tags during save, so previously uploaded images vanished from the rendered article. After image upload, convert each <img> (and surrounding <p> wrappers) to a markdown image block in both the desktop and extension publish paths so the references survive. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { StoredPlatformState } from "../platforms";
|
||||
import { renderJianshuHtmlImagesAsMarkdown } from "../../../../packages/publisher-platforms/src/jianshu";
|
||||
|
||||
import {
|
||||
articleMarkdown,
|
||||
@@ -146,6 +147,7 @@ async function publishJianshu(context: AdapterContext): Promise<PlatformPublishR
|
||||
const htmlProcessed = useMarkdownMode
|
||||
? null
|
||||
: await uploadHtmlImages(normalizeArticleHtml(context.article), async (sourceUrl) => uploadImage(noteId, sourceUrl));
|
||||
const htmlContent = htmlProcessed ? renderJianshuHtmlImagesAsMarkdown(htmlProcessed.html) : "";
|
||||
|
||||
await fetchJson(`https://www.jianshu.com/author/notes/${noteId}`, {
|
||||
method: "PUT",
|
||||
@@ -154,7 +156,7 @@ async function publishJianshu(context: AdapterContext): Promise<PlatformPublishR
|
||||
id: noteId,
|
||||
autosave_control: 1,
|
||||
title: context.article.title,
|
||||
content: useMarkdownMode ? (markdownProcessed?.markdown ?? rawMarkdown) : (htmlProcessed?.html ?? ""),
|
||||
content: useMarkdownMode ? (markdownProcessed?.markdown ?? rawMarkdown) : htmlContent,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user