Skip to content

Preserve rendered formulas when syncing Toutiao - #259

Open
sean0407 wants to merge 1 commit into
doocs:mainfrom
sean0407:codex/fix-toutiao-latex-formula-sync
Open

sean0407 wants to merge 1 commit into
doocs:mainfrom
sean0407:codex/fix-toutiao-latex-formula-sync

Conversation

@sean0407

Copy link
Copy Markdown

Summary / 概述

Fixes Toutiao sync dropping LaTeX formula markup by using the editor's rendered HTML clipboard content when it is available. The existing body/Markdown fallback remains in place.

Related Issue / 关联 Issue

Closes #254

Type of Change / 更改类型

  • Bug fix / 修复 Bug

Changes Made / 更改内容

  • Include Toutiao in the existing rich-HTML clipboard capture path.
  • Pass the rendered HTML into the Toutiao sync handler and insert it into the ProseMirror editor.
  • Keep the current line-based fallback for cases without clipboard HTML.

Implementation Details / 实现细节

The Toutiao handler previously rebuilt the body from newline-separated text, which bypassed the rendered formula markup. It now prefers the same rendered HTML clipboard content already used by other platform handlers.

Testing / 测试

  • npm test — passed (8 tests).
  • npx --yes prettier@3.9.10 --check apps/extension/src/inject.js packages/core/src/platforms/toutiao.js tests/toutiao.test.mjs — passed.
  • The new regression tests fail against the original handler because it inserts the raw $$x = y$$ text and does not forward clipboard HTML.

Testing Checklist / 测試清單

  • I have tested this code locally / 我已在本地測試此程式碼
  • All existing tests pass / 所有現有測試通過
  • I have added tests for new functionality / 我已為新功能新增測試
  • I have tested on the affected platform(s) / 我已在受影響的平台測試
  • I have verified the changes work in the target browser(s) / 我已驗證更改在目標瀏覽器有效

Manual Testing Steps / 手動測試步驟

  1. Prepare an article containing inline and block LaTeX formulas in the Markdown editor.
  2. Select 今日头条 as a sync destination and start publishing.
  3. Confirm the Toutiao draft retains the rendered formulas.

Merge Danger

The change uses rendered clipboard HTML when present; the existing body/Markdown fallback remains available otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 今日头条latex公式丢失,无法解析

1 participant