You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can specify the rendering mode of the rendered equations so that they either take on the style of the surrounding text or display the style rendered by MathJax. The default behavior is to use the `template` rendering mode so that images match surrounding text.
When an error occurs while parsing the input the view will display the original LaTeX. You can change this behavior by modifying the view's `errorMode`.
The typical "LaTeX-ish" way to render the input is with `blockViews`. This mode renders text as usual, and block equations as... blocks; on their own line and centered. MathJax 3 does not support line breaking, so the view places block equations in horizontal scroll views in case the width of the equation is more than the width of the view.
154
156
@@ -174,7 +176,7 @@ LaTeX("The quadratic formula is $$x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$$ and it h
Input may contain HTML entities such as `<` which will not be parsed by LaTeX as anything meaningful. In this case, you may use the `unencoded` modifier.
The `LaTeX` view will render the following markdown synatax.
234
+
235
+
| Syntax | Description |
236
+
|-------------|-------------|
237
+
|`*...*`| Italic |
238
+
|`**...**`| Bold |
239
+
|`***...***`| Bold & Italic |
240
+
|`~~...~~`| Strikethrough |
241
+
|`` `...` ``| Monospaced |
242
+
|`[...](...)`| Links |
243
+
244
+
If you don't want markdown rendered, then you may use the `ignoreStringFormatting` modifier.
245
+
246
+
```swift
247
+
LaTeX(input)
248
+
.ignoreStringFormatting()
249
+
```
250
+
251
+
##### Escaped Characters
252
+
253
+
The characeters `&`, `%`, `$`, `#`, `_`, `{`, `}`, `~`, `^`, and `\` are reserved characters in LaTeX and may appear in a document with an escape characeter preceeding them.
254
+
255
+
The view will look for these characters preceeded by an escape, and replace them with the non-escaped version. If you would like to prevent this replacement, then you may use the `ignoreStringFormatting` modifier.
256
+
257
+
#### Rendering Style
230
258
231
259
The view has four rendering styles. The `wait` style is the default style, and loads the view synchronously on the main queue. To get better performance and move SVG rendering off of the main queue, use any of the other three styles.
|`empty`| Yes | The view remains empty until its finished rendering. |
236
-
|`original`| Yes | The view displays the input text until its finished rendering. |
237
-
|`progress`| Yes | The view displays a progress view until its finished rendering. |
238
-
|`wait`| No |*(default)* The view blocks the main queue until its finished rendering. |
263
+
|`empty`| Yes | The view remains empty until it's finished rendering. |
264
+
|`original`| Yes | The view displays the input text until it's finished rendering. |
265
+
|`redactedOriginal`| Yes | The view displays a redacted version of the view until it's finished rendering |
266
+
|`progress`| Yes | The view displays a progress view until it's finished rendering. |
267
+
|`wait`| No |*(default)* The view blocks the main queue until it's finished rendering. |
239
268
240
269
241
-
#### 🪩 Rendering Animation
270
+
#### Rendering Animation
242
271
243
272
When using the asynchronous rendering styles `empty`, `original`, or `progress`, use this modifier to determine the animation applied to the transition between views. The default value is `none`.
244
273
@@ -250,7 +279,7 @@ LaTeX(input)
250
279
251
280
> In the above example, the input text will be displayed until the SVGs have been rendered at which point the rendered views will animate in to view.
252
281
253
-
### 🪮 Styles
282
+
### Styles
254
283
255
284
You can use the provided view styles or create your own.
256
285
@@ -288,7 +317,7 @@ public struct TitleLaTeXStyle: LaTeXStyle {
288
317
}
289
318
```
290
319
291
-
### 🗄️ Caching
320
+
### Caching
292
321
293
322
`LaTeXSwiftUI` caches its SVG responses from MathJax and the images rendered as a result of the view's environment. If you want to control the cache, then you can access the static `dataCache` and `imageCache` properties.
SVGs and images are rendered and cached on demand, but there may be situations where you want to preload the data so that there is minimal lag when the view appears.
0 commit comments