Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LaTeX ? #70

Open
phucynwa opened this issue Dec 11, 2021 · 10 comments
Open

Support LaTeX ? #70

phucynwa opened this issue Dec 11, 2021 · 10 comments

Comments

@phucynwa
Copy link

I've just found this awesome library. I love your attempt.

I hope that compose-richtext will support LaTeX soon.

@halilozercan
Copy link
Owner

Rendering LaTeX would be an almost impossible task for any Android library alone. I don't think we will have that kind of ambitious goal anytime soon. If we are talking about a small subset of LaTeX like math equations, that'd be something we can look into. I mean not the parsing of a math syntax but providing necessary builders to write a generic math function.

buildFormula {
  pow(a, 2) + pow(b, 2) eq pow(c,2)
}

would render something like

image

@phucynwa
Copy link
Author

@halilozercan Yes. I wish richtext-commonmark will support LaTeX syntax like Markwon library.
I hope I can use this function soon. Thank you.

@leon2017
Copy link

请问现在支持LaTex了吗

@zayass
Copy link

zayass commented Jun 17, 2024

I am not sure about quality but here some existing libraries for parsing/rendering LaTeX on android

https://github.com/NanoMichael/AndroidLaTeXMath
https://github.com/noties/jlatexmath-android

@halilozercan what do you think about some kind of plugins to parse/render embedded things.

I think it is better than inventing yet another math markup language. Because it is a pretty common and widely used scenario to embed LaTeX into markdown:

f{\left( a \right )} = \frac{1}{2 \pi i} \oint_{\gamma} \frac{f{\left( z \right )}}{z - a} dz

$$f{\left( a \right )} = \frac{1}{2 \pi i} \oint_{\gamma} \frac{f{\left( z \right )}}{z - a} dz$$

@sakibanda
Copy link

Hi, Can anyone please update on this? I need Latex support into markdown.

@phucynwa
Copy link
Author

phucynwa commented Dec 3, 2024

@sakibanda I spent a night making it possible 😄

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven("https://jitpack.io") <-- add this line
    }
}
implementation("com.github.phucynwa.compose-richtext:richtext-commonmark:support_latex-SNAPSHOT")
implementation("com.github.phucynwa.compose-richtext:richtext-ui:support_latex-SNAPSHOT")
implementation("com.github.phucynwa.compose-richtext:richtext-ui-material3:support_latex-SNAPSHOT")

You can check my branch and modify it as you want. https://github.com/phucynwa/compose-richtext/tree/support_latex

I copied the compose code from https://github.com/yicu23/LaTeX.kt
I used https://github.com/noties/jlatexmath-android for rendering LaTeX since it support more syntaxes.

@sakibanda
Copy link

Sorry couldn't reply earlier. Thanks a lot @phucynwa, I appreciate it 👍

I will implement and let you know how it goes.

@sakibanda
Copy link

When i switch to your branch & try android build without making any changes I get these errors:

Unresolved reference: com.halilibo.richtext.ui.RichTextThemeIntegration
Unresolved reference: com.halilibo.richtext.ui.material3.Material3RichText
Unresolved reference: com.halilibo.richtext.markdown.Markdown

@sakibanda
Copy link

sakibanda commented Dec 22, 2024

Never mind. followed the documention here :
https://halilibo.com/compose-richtext/richtext-ui-material3/

Then, build worked but Latex functions are not rendering, I am trying everything but don't know why its not working, please find below code & screenshot.

Here is my code:

RichText(
    modifier = Modifier.padding(horizontal = 0.dp, vertical = 0.dp),
    style = RichTextStyle( codeBlockStyle = CodeBlockStyle()) {
    Markdown(
        content = message.content.trimIndent()
            .replace("\n- ", "\n    - ")
    )
}

Screenshot_2024-12-22-11-31-53-945_app amazeai android

Please help.

@sakibanda
Copy link

sakibanda commented Dec 30, 2024

Hello,

Any update on this? Tried the code from your sample, but still its not rendering LaTex code.

Please help.

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

No branches or pull requests

5 participants