colinc86 / latexswiftui Goto Github PK
View Code? Open in Web Editor NEWA SwiftUI view that renders LaTeX.
License: MIT License
A SwiftUI view that renders LaTeX.
License: MIT License
Whenever a math block is delimited with $$
but there is a line break around it, the library doesn't parse this correctly, as in the example below.
See how the code below renders:
A function $f(z)$ is said to be holomorphic in an open region $\Omega$ if it is complex differentiable at every point $z$ in $\Omega$. In other words, the derivative $f'(z)$ exists in the given region.
On the other hand, a function $f(z)$ is said to be analytic if it can be locally represented by a convergent power series. Specifically, for any point $z_0$ in the function's domain, there is a power series which converges to $f(z)$ in a neighborhood of $z_0$. The power series can be expressed as:
$$
f(z) = \sum_{n=0}^{\infty} a_n (z - z_0)^n
$$
Where $a_n$ are coefficients, and the power series converges for all $z$ in a neighborhood of $z_0$.
This is correctly handled my mathjax in the browser. This issue is also significant because subsequent math blocks (inline or not) are not correctly detected when they would have been without this issue.
FYI
Hi, thank you for amazing library. Is it possible to downgrade the required iOS version to 15? Thanks
I'm not sure of the proper terminology (it's either the View or the State not updating, something like that), but here's a simple example of what doesn't appear to be working properly (this was also occurring for version 1.2.3).
The following correctly changes the View when the Button is pressed:
`struct ContentView: View {
@State var eqToggle: Bool = false
var body: some View {
VStack {
Button("Toggle", action: {
eqToggle.toggle()
})
Text("")
eqToggle ? Text("$ 2x + \\sqrt{x} = 3 $ is the primary equation") : Text("The primary equation, $ -x^{2} + y_{0} > 12 \\text{,} $ is unknown.")
}
}
}
`
The following does not:
`
struct ContentView: View {
@State var eqToggle: Bool = false // 1st LaTeX call remains in place (true) or 2nd LaTeX call remains in place (false)
var body: some View {
VStack {
Button("Toggle", action: {
eqToggle.toggle()
})
Text("")
eqToggle ? LaTeX("$ 2x + \\sqrt{x} = 3 $ is the primary equation") : LaTeX("The primary equation, $ -x^{2} + y_{0} > 12 \\text{,} $ is unknown.")
}
}
}
`
What's preventing the view from updating?
When making an array, for example:
"\begin{array}{|c|c|c|} a & b & c \\ d & e & f \\ \end{array}"
only the outer two vertical lines will render
Further,
if a horizontal line is placed on top:
"\begin{array}{|c|c|c|} \hline a & b & c \\ d & e & f \\ \end{array}"
the top line renders fine.
when another is added anywhere else:
"\begin{array}{|c|c|c|} \hline a & b & c \\ d & e & f \\ \hline \end{array}"
the whole section becomes a black box.
Further, any lines placed between rows are not rendered.
Accessing Environment<Optional>'s value outside of being installed on a View. This will always read the default value and will not update.
After adding the package to a Playgrounds App, the app no longer refreshes.
Also, none of the required packages (MathJaxSwift, etc.) are loaded. They can obviously be loaded individually by finding the addresses in the package manifest, but I'm not sure if that's a Playgrounds issue or an issue with this package.
Great package. Like the title, any chance you can add support for macOS 12?
Or can you give some pointers on which part of the codebase I should change to support macOS 12.
Thanks
Title is self explanatory. Take this code for example:
import SwiftUI
import LaTeXSwiftUI
struct TestView: View {
@State var varLatex = "$a$"
var body: some View {
VStack {
Text(varLatex)
LaTeX(varLatex)
Button("Switch") {
varLatex = "$b$"
}
}
}
}
#Preview {
TestView()
}
When the button is clicked, varLatex
is updated and so is the Text
view. But the LaTeX
view is not updated... I have tried on multiple examples: whenever the input is updated, the view does not. And there is no workaround...
It feels like the LaTeX
only works with constant strings, since iterating with ForEach
over a constant list of strings works perfectly.
My knowledge in Swift is too little for me to open a PR... I hope this can be fixed soon!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.