LaTeX support #208
Replies: 5 comments 7 replies
-
Hi @rjacquinot, I'm sorry, but I don't have any plans to support LaTeX right now. However, I welcome suggestions for integrating a third-party library that provides LaTeX rendering in SwiftUI. |
Beta Was this translation helpful? Give feedback.
-
Has there been any further developments on this front? I'm interested in integrating the functionalities of https://github.com/colinc86/LaTeXSwiftUI and this library. Any advice on how I might go about doing that? |
Beta Was this translation helpful? Give feedback.
-
Hi, Is there any progress on LaTex support right now, I'm interested in this, it would be great if LaTex presentations were supported in this library. Thanks |
Beta Was this translation helpful? Give feedback.
-
Hi @gonzalezreal, Could I possibly offer a payout to add LaTeX support to this project? I've tried other alternatives, but they are not as smooth and functional as Markdown UI, and they lack support for other important features. I would greatly appreciate an answer. If you have any questions, please feel free to contact me at [email protected]. Thank you! |
Beta Was this translation helpful? Give feedback.
-
I was able to use it as images from https://latex.codecogs.com/ I use png because iOS does not support SVG out of the box and SVG works just fine. You can adjust the DPI to your needs. struct ThemeAwareImageProvider: ImageProvider {
let scaleFactor: CGFloat
public func makeImage(url: URL?) -> some View {
NetworkImage(url: url) { state in
switch state {
case .failure, .empty:
Color.clear
.frame(width: 0, height: 0)
case let .success(image, idealSize):
image
.renderingMode(.template)
.resizable()
.aspectRatio(contentMode: .fit)
.padding(.leading, .x1)
.frame(
idealWidth: idealSize.width * scaleFactor / 2,
idealHeight: idealSize.height * scaleFactor / 2
)
}
}
}
}
struct ThemeAwareInlineImageProvider: InlineImageProvider {
let scaleFactor: CGFloat
public func image(with url: URL, label: String) async throws -> Image {
let image = try await Image(
DefaultNetworkImageLoader.shared.image(from: url),
scale: 2 / scaleFactor,
label: Text(label)
)
return image.renderingMode(.template).resizable()
}
} Here's the code to transform the extension String {
func withLatexImage(dpi: Int = 200) -> String {
let regexp = try? Regex("<latex>\\s*(.+?)\\s*</latex>")
guard let regexp else { return self }
let transformed = self.replacing(regexp, with: { match in
guard let latexContent = match.output[1].substring else {
return ""
}
let queryParameter = latexContent.replacing(" ", with: "&space;")
return "![](https://latex.codecogs.com/png.latex?\\dpi{\(dpi)}\(queryParameter))"
})
return transformed
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi,
LaTeX doesn't appear to be supported yet. It would be great to see it added.
Do you have any future plans to support it?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions