Skip to content

Commit 65ccf23

Browse files
committed
Update README sections.
1 parent 84c686c commit 65ccf23

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

README.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@ A SwiftUI view that renders LaTeX.
66

77
<center><img src="./assets/images/device.png" width="362" height="707"></center>
88

9-
## Installation
9+
## 📖 Contents
10+
11+
- [Installation](#📦-installation)
12+
- [Usage](#⌨️-usage)
13+
- [Modifiers](#⚙️-modifiers)
14+
- [Parsing Mode](#🔤-parsing-mode)
15+
- [Image Rendering Mode](#🌄-image-rendering-mode)
16+
- [Error Mode](#🚨-error-mode)
17+
- [Block Rendering Mode](#🧱-block-rendering-mode)
18+
- [Unencode HTML](#🔗-unencode-html)
19+
- [TeX Options](#♾️-tex-options)
20+
- [Caching](#🗄️-caching)
21+
- [Preloading](#🏃‍♀️-preloading)
22+
23+
## 📦 Installation
1024

1125
Add the dependency to your package manifest file.
1226

1327
```swift
1428
.package(url: "https://github.com/colinc86/LaTeXSwiftUI", branch: "main")
1529
```
1630

17-
## Usage
31+
## ⌨️ Usage
1832

1933
Import the package and use the view.
2034

@@ -32,7 +46,7 @@ struct MyView: View {
3246

3347
> <img src="./assets/images/hello.png" width="85" height="21.5">
3448
35-
### Modifiers
49+
### ⚙️ Modifiers
3650

3751
The `LaTeX` view's body is built up of `Text` views so feel free to use any of the supported modifiers.
3852

@@ -46,7 +60,17 @@ LaTeX("Hello, $\\LaTeX$!")
4660
4761
Along with supporting the built-in SwiftUI modifies, `LaTeXSwiftUI` defines more to let you configure the view.
4862

49-
#### Parsing Mode
63+
#### 🔤 Parsing Mode
64+
65+
`LaTexSwiftUI` can parse and render equations (aside from the entire input string) defined with the following terminators.
66+
67+
| Terminators |
68+
|-------------|
69+
| `$...$` |
70+
| `$$...$$` |
71+
| `\[...\]` |
72+
| `\begin{equation}...\end{equation}` |
73+
| `\begin{equation*}...\end{equation*}` |
5074

5175
Text input can either be completely rendered, or `LaTeXSwiftUI` can search for top-level equations. The default behavior is to only render equations. Use the `parsingMode` modifier to change the default behavior.
5276

@@ -62,19 +86,7 @@ LaTeX("e^{i\\pi}+1=0")
6286

6387
> <img src="./assets/images/euler.png" width="75" height="19.5">
6488
65-
##### Equations
66-
67-
`LaTexSwiftUI` can parse and render equations (aside from the entire input string) defined with the following terminators.
68-
69-
| Terminators |
70-
|-------------|
71-
| `$...$` |
72-
| `$$...$$` |
73-
| `\[...\]` |
74-
| `\begin{equation}...\end{equation}` |
75-
| `\begin{equation*}...\end{equation*}` |
76-
77-
#### Image Rendering Mode
89+
#### 🌄 Image Rendering Mode
7890

7991
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.
8092

@@ -90,7 +102,7 @@ LaTeX("Hello, ${\\color{red} \\LaTeX}$!")
90102

91103
> <img src="./assets/images/rendering_mode.png" width="84.5" height="43">
92104
93-
#### Error Mode
105+
#### 🚨 Error Mode
94106

95107
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`.
96108

@@ -110,7 +122,7 @@ LaTeX("$\\asdf$")
110122

111123
> <img src="./assets/images/errors.png" width="199.5" height="55">
112124
113-
#### Block Rendering Mode
125+
#### 🧱 Block Rendering Mode
114126

115127
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.
116128

@@ -136,7 +148,7 @@ LaTeX("The quadratic formula is $$x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$$ and it h
136148

137149
> <img src="./assets/images/blocks.png" width="430" height="350">
138150
139-
#### Unencode HTML
151+
#### 🔗 Unencode HTML
140152

141153
Input may contain HTML entities such as `&lt;` which will not be parsed by LaTeX as anything meaningful. In this case, you may use the `unencoded` modifier.
142154

@@ -151,7 +163,7 @@ LaTeX("$x^2&lt;1$")
151163

152164
> <img src="./assets/images/unencoded.png" width="72.5" height="34">
153165
154-
#### TeX Options
166+
#### ♾️ TeX Options
155167

156168
For more control over the MathJax rendering, you can pass a `TeXInputProcessorOptions` object to the view.
157169

@@ -160,7 +172,7 @@ LaTeX("Hello, $\\LaTeX$!")
160172
.texOptions(TeXInputProcessorOptions(loadPackages: [TeXInputProcessorOptions.Packages.base]))
161173
```
162174

163-
### Caching
175+
### 🗄️ Caching
164176

165177
`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 `cache` property.
166178

@@ -176,9 +188,9 @@ LaTeX.imageCache.removeAll()
176188

177189
`LaTeXSwiftUI` uses the [caching](https://github.com/kean/Nuke/tree/master/Sources/Nuke/Caching) components of the [Nuke](https://github.com/kean/Nuke) package.
178190

179-
### Preloading
191+
### 🏃‍♀️ Preloading
180192

181-
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 no lag when the view appears.
193+
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.
182194

183195
```swift
184196
VStack {

0 commit comments

Comments
 (0)