Skip to content

Commit 4385e3f

Browse files
committed
feat: replace some mathjax with mermaid
1 parent a60373f commit 4385e3f

File tree

10 files changed

+90
-82
lines changed

10 files changed

+90
-82
lines changed

docs/.vitepress/config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from "fs";
99
import {exampleAutoAnchorPreprocessor} from "./theme/anchor/exampleAutoAnchorPreprocessor";
1010
import {mathjaxContainerPreprocessor} from "./theme/mathjax/mathjaxContainerPreprocessor";
1111
import {withMermaid} from "vitepress-plugin-mermaid";
12+
import {mermaidSpaceConverter} from "./theme/mermaid/mermaidSpaceConverter";
1213

1314
const defaultLocale: string = 'en';
1415
const supportLocales: string[] = [
@@ -106,6 +107,7 @@ const vitepressOptions: UserConfig = {
106107
},
107108
config: (md) => {
108109
tabsPlugin(md);
110+
mermaidSpaceConverter(md);
109111
exampleAutoAnchorPreprocessor(md);
110112
mathjaxContainerPreprocessor(md);
111113
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import MarkdownIt from "markdown-it";
2+
import slugify from "@sindresorhus/slugify";
3+
4+
export const mermaidSpaceConverter = (md: MarkdownIt) => {
5+
md.core.ruler.before('normalize', 'mermaid-space-converter', (state) => {
6+
if(!state.src.includes("```mermaid")) {
7+
return;
8+
}
9+
const blocks = state.src.split("```mermaid");
10+
state.src = blocks.map((block) => {
11+
const split = block.split("```");
12+
split[0] = split[0].replace(/(\[.*?]|\{.*?}|\(.*?\))/g, (match) => {
13+
return match.replace(/ /g, ' ');
14+
});
15+
return split.join("```");
16+
}).join("```mermaid");
17+
});
18+
}
19+

docs/en/create-commands/arguments/types/list-arguments.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ List arguments allows users to provide a list of values. This argument can take
1919

2020
Unlike other arguments, because this argument can be interpreted in various different ways, this argument can only be created using a `ListArgumentBuilder`, instead of directly accessing the `ListArgument` constructor. The `ListArgumentBuilder` loosely follows the following format:
2121

22-
$$
23-
\begin{align}
24-
&\quad\texttt{Create a ListArgumentBuilder} \\\\
25-
\rightarrow&\quad\texttt{(Provide the list delimiter)} \\\\
26-
\rightarrow&\quad\texttt{Provide the list to pull suggestions from} \\\\
27-
\rightarrow&\quad\texttt{Provide the mapper of the list items to a string} \\\\
28-
\rightarrow&\quad\texttt{Build the ListArgument}
29-
\end{align}
30-
$$
22+
```mermaid
23+
graph TD
24+
A(Create a ListArgumentBuilder) --> B("(Provide the list delimiter)")
25+
B --> C(Provide the list to pull suggestions from)
26+
C --> D(Provide the mapper of the list items to a string)
27+
D --> E(Build the ListArgument)
28+
```
3129

3230
### Construction
3331

docs/en/create-commands/arguments/types/map-arguments.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ It returns a `LinkedHashMap` object.
1515

1616
Similar to the `ListArgument`, this argument also uses a builder class to construct it.
1717

18-
$$\begin{align}
19-
&\quad\texttt{Create a MapArgumentBuilder and possibly provide the delimiter or separator} \\\\
20-
\rightarrow&\quad\texttt{Provide the mapper from a string to an object of the provided key type} \\\\
21-
\rightarrow&\quad\texttt{Provide the mapper from a string to an object of the provided value type} \\\\
22-
\rightarrow&\quad\texttt{Provide the list with keys to pull suggestions from} \\\\
23-
\rightarrow&\quad\texttt{Provide the list with values to pull suggestions from} \\\\
24-
\rightarrow&\quad\texttt{Build the MapArgument}
25-
\end{align}$$
18+
```mermaid
19+
graph TD
20+
A(Create a MapArgumentBuilder<br/>possibly provide the delimiter or separator) --> B(Provide the mapper from a string to an object of the provided key type)
21+
B --> C(Provide the mapper from a string to an object of the provided value type)
22+
C --> D(Provide the list with keys to pull suggestions from)
23+
D --> E(Provide the list with values to pull suggestions from)
24+
E --> F(Build the MapArgument)
25+
```
2626

2727
### Building a `MapArgument`
2828

docs/en/create-commands/arguments/types/misc/angle-arguments.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ authors:
99
The angle argument is used to represent the _yaw_ (horizontal) angle in degrees. The value returned from this argument range from -180.0 (inclusive) to 180 (exclusive), with -180.0 being due north:
1010

1111
$$
12-
\begin{align}
13-
-1&80.0 \\\\
14-
&\hspace{0.1em}N \\\\
15-
&\uparrow \\\\
16-
90.0\ W \leftarrow &\hspace{0.75em}\rightarrow E\ -90.0 \\\\
17-
&\downarrow \\\\
18-
&\hspace{0.2em}S \\\\
19-
&0.0 \\\\
20-
\end{align}
12+
\begin{array}{c}
13+
& N (-180°) & \\
14+
& \uparrow & \\
15+
& & \\
16+
& & \\
17+
W (90°) \leftarrow\hspace{0.4em} & \bullet & \hspace{0.4em}\rightarrow E (-90°) \\
18+
& & \\
19+
& & \\
20+
& \downarrow & \\
21+
& S (0°) & \\
22+
\end{array}
2123
$$
2224

25+
2326
The `~` notation can be used to specify a rotation relative to the executor's yaw angle.

docs/en/create-commands/executors/normal-executors.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,15 @@ This saves having to use `instanceof` multiple times to check the type of the `C
104104

105105
The different command sender priority is the following (from the highest priority to the lowest priority):
106106

107-
$$
108-
\begin{align}
109-
&\quad\texttt{.executesNative()} && \texttt{(Always chosen if used)}\\\\
110-
&\quad\texttt{.executesPlayer()} \\\\
111-
&\quad\texttt{.executesEntity()} \\\\
112-
&\quad\texttt{.executesConsole()} \\\\
113-
&\quad\texttt{.executesCommandBlock()} \\\\
114-
&\quad\texttt{.executesProxy()} \\\\
115-
&\quad\texttt{.executes()}
116-
\end{align}
117-
$$
107+
```mermaid
108+
graph TD
109+
A(".executesNative() (Always chosen if used)") --> B(".executesPlayer()")
110+
B --> C(".executesEntity()")
111+
C --> D(".executesConsole()")
112+
D --> E(".executesCommandBlock()")
113+
E --> F(".executesProxy()")
114+
F --> G(".executes()")
115+
```
118116

119117
## Multiple command executors with the same implementation
120118

docs/en/faq.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,11 @@ No. That message is handled client-side and isn't controlled by the CommandAPI.
4242

4343
```java
4444
new CommandAPICommand("mycommand")
45-
.withPermission("some.permission")
45+
.withPermission("some.permission") // [!code --]
4646
.executes((sender, args) -> {
47-
sender.sendMessage("Hello!");
48-
})
49-
.register();
50-
```
51-
52-
$$\downarrow$$
53-
54-
```java
55-
new CommandAPICommand("mycommand")
56-
.executes((sender, args) -> {
57-
if(!sender.hasPermission("some.permission")) {
58-
throw CommandAPI.failWithString("You don't have permission to run /mycommand!");
59-
}
47+
if(!sender.hasPermission("some.permission")) { // [!code ++]
48+
throw CommandAPI.failWithString("You don't have permission to run /mycommand!"); // [!code ++]
49+
} // [!code ++]
6050
sender.sendMessage("Hello!");
6151
})
6252
.register();
@@ -73,11 +63,7 @@ Arguments with suggestions provided using `ArgumentSuggestions.strings(String...
7363
The easiest way to do this is to add `info ->` at the start of your array:
7464

7565
```java
76-
ArgumentSuggestions.strings(SomeClass.someArray);
77-
```
78-
79-
$$\downarrow$$
66+
ArgumentSuggestions.strings(SomeClass.someArray); // [!code --]
8067

81-
```java
82-
ArgumentSuggestions.strings(info -> SomeClass.someArray);
68+
ArgumentSuggestions.strings(info -> SomeClass.someArray); // [!code ++]
8369
```

docs/en/incompatible-versions.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,34 @@ Running functions generated via the `FunctionArgument` on Minecraft version **1.
2525

2626
In Minecraft version **1.16**, the way datapacks were loaded changed in such a way that the CommandAPI had to put in additional countermeasures to provide full support to it. To illustrate this, this was the previous loading sequence for Bukkit servers in Minecraft 1.15:
2727

28-
$\texttt{Server loads}\rightarrow\texttt{Plugins load}\rightarrow\texttt{Datapacks load}\rightarrow\texttt{Server finishes loading}$
29-
30-
Instead however, Minecraft 1.16 changed the loading sequence to the following:
31-
32-
$\texttt{Server loads}\rightarrow\texttt{Datapacks load}\rightarrow\texttt{Plugins load}\rightarrow\texttt{Server finishes loading}$
28+
```mermaid
29+
graph LR
30+
A(Start loads) --> B(Plugins load)
31+
B --> C(DataPacks load)
32+
C --> D(Server finishes loading)
33+
```
34+
35+
However, Minecraft 1.16 changed the loading sequence to the following:
36+
37+
```mermaid
38+
graph LR
39+
A(Start loads) --> B(DataPacks load)
40+
B --> C(Plugins load)
41+
C --> D(Server finishes loading)
42+
```
3343

3444
Because the CommandAPI used to register vanilla Minecraft commands _before_ datapacks (and thus, custom Minecraft functions), it was possible to register custom commands that can be used in functions. With this new loading sequence change in Minecraft 1.16, this meant that datapacks load first before the CommandAPI does, so custom commands are not registered and functions with custom commands would fail to load.
3545

3646
To resolve this, the CommandAPI reloads datapacks _and recipes_ at the end:
3747

38-
$$\begin{align}
39-
&\quad\texttt{Server loads} \\\\
40-
\rightarrow&\quad\texttt{Datapacks load} \\\\
41-
\rightarrow&\quad\texttt{Plugins load} \\\\
42-
\rightarrow&\quad\texttt{Server finishes loading} \\\\
43-
\rightarrow&\quad\texttt{Datapacks are reloaded} && \texttt{(by the CommandAPI)} \\\\
44-
\rightarrow&\quad\texttt{Recipes are reloaded} && \texttt{(by the CommandAPI)}
45-
\end{align}$$
48+
```mermaid
49+
graph TD
50+
A(Server loads) --> B(DataPacks load)
51+
B --> C(Plugins load)
52+
C --> D(Server finishes loading)
53+
D --> E("DataPacks are reloaded (by the CommandAPI)")
54+
E --> F("Recipes are reloaded (by the CommandAPI)")
55+
```
4656

4757
By doing this, this means:
4858

docs/en/internal/brigadier-plus-commandapi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ In this scenario, if we ran this command, we would expect "Hello!" to appear in
7474
```mermaid
7575
graph TD
7676
A(execute) --> B(if)
77-
B --> C("randomchance&nbsp;&lt;numerator&gt;&nbsp;&lt;denominator&gt;")
77+
B --> C("randomchance &lt;numerator&gt; &lt;denominator&gt;")
7878
```
7979

8080
- After entering our predicate, we want to route back to `execute` (because the argument after `execute` is `run`, which is used in our example command above):
8181

8282
```mermaid
8383
graph TD
8484
A(execute) --> B(if)
85-
B --> C("randomchance&nbsp;&lt;numerator&gt;&nbsp;&lt;denominator&gt;")
85+
B --> C("randomchance &lt;numerator&gt; &lt;denominator&gt;")
8686
C --> D(execute)
8787
```
8888

docs/en/troubleshooting.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,8 @@ This is most likely caused by using a constant array instead of using a lambda t
2020
```java
2121
new StringArgument("players")
2222
.replaceSuggestions(ArgumentSuggestions.strings(
23-
Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new)
24-
));
25-
```
26-
27-
$$\downarrow$$
28-
29-
```java
30-
new StringArgument("players")
31-
.replaceSuggestions(ArgumentSuggestions.strings(
32-
info -> Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new)
23+
Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new) // [!code --]
24+
info -> Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new) // [!code ++]
3325
));
3426
```
3527

0 commit comments

Comments
 (0)