mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2026-03-24 12:56:59 +00:00
[GH-ISSUE #7949] [Bug] Latex rendering error #3474
Labels
No labels
2024
2025
2026
acct mgmt
AI
automation
bug
calendar
ci
CJK
cloud
code-block
collaboration
copy-paste
database
data migration
data sync
deploy
desktop
develop
develop
documentation
duplicate
editor
editor-plugin
emoji
export
files
flutter-only
follow-up
formula
good first issue for devs
good first issue for experienced devs
grid
hacktoberfest
HACKTOBERFEST-ACCEPTED
help wanted
i18n
icons
images
importer
improvements
infra
install
integrations
IR
kanban board
login
look and joy
mentorship
mobile
mobile
needs design
new feature
new feature
non-coding
notes
notifications
onboarding
organization
P0+
permission
platform-linux
platform-mac
platform-windows
plugins
program
pull-request
Q1 25
Q1 26
Q2 24
Q2 25
Q3 24
Q3 25
Q4 24
Q4 25
react
regression
rust
rust
Rust-only
Rust-only
Rust-starter
Rust-starter
self-hosted
shortcuts
side panel
slash-menu
sync v2
table
tablet
task
tauri
templates
tests
themes
translation
v0.5.6
v0.5.8
v0.5.9
v0.6.0
v0.6.1
v0.6.4
v0.6.7
v0.6.8
v0.7.1
v0.7.4
v0.7.4
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.8.0
v0.8.4
v0.8.5
v0.8.9
web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AppFlowy-IO/AppFlowy#3474
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stepisptr-t on GitHub (May 19, 2025).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/7949
Bug Description
After importing from Notion, one latex block fails to render. This is the output:
Build Exception: Unsanitized build exception detected: Unsupported operation: Temporary node CrNode encountered..Please report this error with correponding input.How to Reproduce
Putting this in a latex block
Expected Behavior
render the latex
Operating System
Windows
AppFlowy Version(s)
0.9.2
Screenshots
No response
Additional Context
No response
@M-T-Arden commented on GitHub (May 20, 2025):
Hi @stepisptr-t ,
I've successfully reproduced this bug and identified the root cause. Here's a temporary solution for users like you (Part 3).
Summary of the root cause and suggested fix:
1. Problem
Bug behavior: When inputting LaTeX equations that contain a raw
\\, the following build exception is thrown:Root cause:
The LaTeX parser used by AppFlowy (suspected to be
flutter_math) does not properly handle raw\\line breaks outside of environments likealigned. This causes the parser to generate a temporaryCrNode, which leads to the crash. However, the same line break works fine inside those environments.2. Reproduction
\\\\,\newline, or\crdoes not resolve the issue.aligneddoes prevent the exception.💡3. Proposed Fixes
For users:
Wrap the LaTeX content with
\begin{aligned}and\end{aligned}as shown below:As a contributor :
Implement a pre-processing step to automatically wrap raw content with
alignedif it contains a standalone\\:Alternatively, check whether this issue is caused by an outdated version of
flutter_mathand consider upgrading the dependency.I would like to work on fixing this issue and I will start working on a PR shortly. Please let me know if there's any preferred direction (e.g., pre-processing vs parser-level fix).
@stepisptr-t commented on GitHub (May 20, 2025):
Is this LLM generated?
@M-T-Arden commented on GitHub (May 20, 2025):
Not actually, I have done this work by myself. I only use AI to summary and polish this content because my mother language is not English and I am new to open source project. I thought AI could make it more clear and accurate.
@LucasXu0 commented on GitHub (May 21, 2025):
I can confirm that wrapping with
\begin{aligned}and\end{aligned}works.I'll make a quick fix later.@M-T-Arden I prefer the preprocessing without modifying the math library.
@stepisptr-t commented on GitHub (May 21, 2025):
It might be better to show an error message, which indicates that the Tex should contain the alignment. The user (me) should've known that while being in the equation environment, one should use the aligned environment together with "\". Default behavior (using xelatex to compile) shows overflowing text and ignores the "\" which is what I would expect the Web Tex rendering engine to do as well.
Using the aligned environment from package
amsmathresults in the same result as you provided, which is expected:@M-T-Arden commented on GitHub (May 21, 2025):
@LucasXu0 Got it. I've implemented a pre-processing logic inside
_buildMathEquation(inmath_equation_block_component.dart) without modifying the math rendering library, as suggested.I've submitted a PR as this fix: #7961
Also, as users pointed out, wrapping the LaTeX in an
alignedenvironment avoids the crash, but causes the equation to lose center alignment. If possible, I’d like to continue working on improving that rendering behavior as a follow-up. I wonder whether this is okay.