[PR #8304] [CLOSED] Support LaTeX paste #8343

Closed
opened 2026-03-23 23:23:45 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/8304
Author: @Yazaven
Created: 10/22/2025
Status: Closed

Base: mainHead: fixes-#8177


📝 Commits (2)

  • 24e0b51 Added LaTeX Paste Support to Editor
  • 06a943b Refactored the code and fixed issue #8111

📊 Changes

4 files changed (+570 additions, -46 deletions)

View changed files

📝 frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart (+104 -30)
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_latex_utils.dart (+345 -0)
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_math_equation_parser.dart (+77 -0)
📝 frontend/appflowy_flutter/lib/shared/markdown_to_document.dart (+44 -16)

📄 Description

Feature Preview

This adds LaTeX paste support to AppFlowy, allowing users to paste mathematical equations from ChatGPT and other sources directly into documents with proper rendering.

Fixes #8177

Summary

This PR implements comprehensive LaTeX equation parsing when pasting mathematical content into AppFlowy documents. Users can now copy LaTeX equations from ChatGPT, Gemini, or any other source and paste them directly into AppFlowy with correct rendering.

What this PR adds:

  • Automatic detection and parsing of LaTeX equations in pasted content
  • Support for piecewise functions with \begin{cases} environments
  • Support for aligned equations with \begin{aligned} environments
  • Proper handling of integrals, limits, series, and differential equations

Before:

https://github.com/user-attachments/assets/dd8f6644-8dc8-4220-95cd-8a08327bad04

After:

https://github.com/user-attachments/assets/bfdce96d-bf96-44b2-927a-e5cfd72c2baa

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Enable users to paste LaTeX equations directly into the editor by parsing and rendering mathematical content in both markdown and HTML paste flows.

New Features:

  • Add LaTeX paste support with a custom MarkdownMathEquationParser and preprocessing to detect and convert math blocks (including custom brackets) into rendered equations, handling cases, aligned, array environments, spacing normalization, and line breaks
  • Extend HTML paste workflow to detect mathematical and list content and route such content through markdown conversion for accurate structure and LaTeX rendering

Summary by Sourcery

Enable direct LaTeX equation pasting in AppFlowy documents by routing pasted HTML through a custom markdown path with LaTeX preprocessing and a new equation parser, while preserving list and table structure and optimizing performance with a fallback to native HTML parsing.

New Features:

  • Support automatic detection, parsing, and rendering of LaTeX equations from pasted content, including piecewise (cases), aligned, and array environments
  • Add custom MarkdownMathEquationParser and preprocessing utilities to fix LaTeX line breaks and spacing for proper math rendering

Enhancements:

  • Introduce a decision tree in the HTML paste workflow to choose between direct HTML parsing and HTML→Markdown→document conversion based on content type (Google Docs, lists, math, Apple Notes)
  • Preprocess bracketed LaTeX blocks to normalize math delimiters and ensure consistent handling of multiline equations and differential notation

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/8304 **Author:** [@Yazaven](https://github.com/Yazaven) **Created:** 10/22/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fixes-#8177` --- ### 📝 Commits (2) - [`24e0b51`](https://github.com/AppFlowy-IO/AppFlowy/commit/24e0b51bde42029377742ee02cf03cdfc66bfdf9) ✨ Added LaTeX Paste Support to Editor - [`06a943b`](https://github.com/AppFlowy-IO/AppFlowy/commit/06a943bd7e2f1214f56cd9b7077200e199388197) Refactored the code and fixed issue #8111 ### 📊 Changes **4 files changed** (+570 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/paste_from_html.dart` (+104 -30) ➕ `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_latex_utils.dart` (+345 -0) ➕ `frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/parsers/markdown_math_equation_parser.dart` (+77 -0) 📝 `frontend/appflowy_flutter/lib/shared/markdown_to_document.dart` (+44 -16) </details> ### 📄 Description <!--- Thank you for submitting a pull request to AppFlowy. The team will dedicate their best efforts to reviewing and approving your pull request. If you have any questions about the project or feedback for us, please join our [Discord](https://discord.gg/wdjWUXXhtw). --> ## Feature Preview This adds LaTeX paste support to AppFlowy, allowing users to paste mathematical equations from ChatGPT and other sources directly into documents with proper rendering. Fixes #8177 ## Summary This PR implements comprehensive LaTeX equation parsing when pasting mathematical content into AppFlowy documents. Users can now copy LaTeX equations from ChatGPT, Gemini, or any other source and paste them directly into AppFlowy with correct rendering. **What this PR adds:** - Automatic detection and parsing of LaTeX equations in pasted content - Support for piecewise functions with `\begin{cases}` environments - Support for aligned equations with `\begin{aligned}` environments - Proper handling of integrals, limits, series, and differential equations Before: https://github.com/user-attachments/assets/dd8f6644-8dc8-4220-95cd-8a08327bad04 After: https://github.com/user-attachments/assets/bfdce96d-bf96-44b2-927a-e5cfd72c2baa #### PR Checklist - [x] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [x] I've listed at least one issue that this PR fixes in the description above. - [x] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [x] All existing tests are passing. ## Summary by Sourcery Enable users to paste LaTeX equations directly into the editor by parsing and rendering mathematical content in both markdown and HTML paste flows. New Features: - Add LaTeX paste support with a custom MarkdownMathEquationParser and preprocessing to detect and convert math blocks (including custom brackets) into rendered equations, handling cases, aligned, array environments, spacing normalization, and line breaks - Extend HTML paste workflow to detect mathematical and list content and route such content through markdown conversion for accurate structure and LaTeX rendering ## Summary by Sourcery Enable direct LaTeX equation pasting in AppFlowy documents by routing pasted HTML through a custom markdown path with LaTeX preprocessing and a new equation parser, while preserving list and table structure and optimizing performance with a fallback to native HTML parsing. New Features: - Support automatic detection, parsing, and rendering of LaTeX equations from pasted content, including piecewise (cases), aligned, and array environments - Add custom MarkdownMathEquationParser and preprocessing utilities to fix LaTeX line breaks and spacing for proper math rendering Enhancements: - Introduce a decision tree in the HTML paste workflow to choose between direct HTML parsing and HTML→Markdown→document conversion based on content type (Google Docs, lists, math, Apple Notes) - Preprocess bracketed LaTeX blocks to normalize math delimiters and ensure consistent handling of multiline equations and differential notation --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:23:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#8343
No description provided.