Skip to content

Commit 36bb4f5

Browse files
feat(minimessage): Update hover tag format (#756)
* Add example of using data component key value pairs for hover:show_item tag format * Replace Markdown table with HTML table for hover tag format documentation and add documentation for data component key value pairs * Add badge and aside for legacy format warning * Remove unused import * Replace <code> tags with backticks * chore: add markdown extension for table spanning --------- Co-authored-by: Matouš Kučera <mk@kcra.me>
1 parent 49b377c commit 36bb4f5

5 files changed

Lines changed: 97 additions & 8 deletions

File tree

astro.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import starlight from "@astrojs/starlight";
22
import svelte from "@astrojs/svelte";
33
import d2 from "astro-d2";
44
import { defineConfig } from "astro/config";
5+
import { extendedTableHandlers, remarkExtendedTable } from "remark-extended-table";
56
import starlightLinksValidator from "starlight-links-validator";
67
import starlightSidebarTopics from "starlight-sidebar-topics";
78
import codeConstantsPlugin from "./src/utils/remark/code_const";
@@ -552,7 +553,13 @@ export default defineConfig({
552553
domains: ["assets.papermc.io"],
553554
},
554555
markdown: {
556+
remarkRehype: {
557+
handlers: {
558+
...extendedTableHandlers,
559+
},
560+
},
555561
remarkPlugins: [
562+
remarkExtendedTable,
556563
[
557564
javadocPlugin,
558565
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"astro": "^6.1.3",
2323
"astro-contributors": "^0.8.0",
2424
"astro-d2": "^0.10.0",
25+
"remark-extended-table": "^2.0.3",
2526
"sharp": "^0.34.5",
2627
"starlight-links-validator": "^0.20.1",
2728
"starlight-sidebar-topics": "^0.7.1",

pnpm-lock.yaml

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
61.8 KB
Loading

src/content/docs/adventure/minimessage/format.mdx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: The MiniMessage format documentation.
55
---
66

77
import { Image } from "astro:assets";
8+
import { Badge } from "@astrojs/starlight/components";
89
import Shadow1 from "./assets/shadow_1.png";
910
import Shadow2 from "./assets/shadow_2.png";
1011
import Shadow3 from "./assets/shadow_3.png";
@@ -16,6 +17,7 @@ import Decoration1 from "./assets/decoration_1.png";
1617
import Reset1 from "./assets/reset_1.png";
1718
import Click1 from "./assets/click_1.png";
1819
import Hover1 from "./assets/hover_1.png";
20+
import Hover2 from "./assets/hover_2.png";
1921
import Key1 from "./assets/key_1.png";
2022
import Translatable1 from "./assets/translatable_1.png";
2123
import Translatable2 from "./assets/translatable_2.png";
@@ -229,26 +231,38 @@ like the `/say` or `/tell` command to prevent the server from sending signed mes
229231
Allows doing multiple things when hovering on the component.
230232

231233
Tag
232-
* `<hover:_action_:_value..._>`
234+
* `<hover:_action_:_value_>`
233235

234236
Arguments
235237
* `_action_`, the type of hover event, one of this [list](https://jd.advntr.dev/api/latest/net/kyori/adventure/text/event/HoverEvent.Action.html#field.summary)
236-
* `_value..._`, arguments specific to each event action:
238+
* `_value_`, argument(s) specific to each event action:
237239

238-
| Action | Value |
239-
|---------------|---------------------------------------------------------------------------------------------------------------------------|
240-
| `show_text` | `_text_` (a MiniMessage string) |
241-
| `show_item` | `_type_[:_count_[:tag]]` (a `Key` for the item's type, optionally followed by count (an integer) and tag (a SNBT string)) |
242-
| `show_entity` | `_type_:_uuid_[:_name_]` (a `Key` ID of the entity type, the entity's UUID, and an optional custom name) |
240+
[//]: # (FIXME: Starlight's padding doesn't apply for a spanned cell, so a manual padding is added)
241+
| Action | Value | Description |
242+
|---------------|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
243+
| `show_text` | `_text_` | a MiniMessage string |
244+
| `show_item` | `_type_[:_count_[(:_componentKey_:_componentValue_)...]]` | a `Key` for the item's type, optionally followed by count (an integer) and a list of [data component](https://minecraft.wiki/w/Data_component_format) key value pairs |
245+
| ^ | <span style="padding-left: 1rem"><Badge variant="caution" text="Legacy" /> `_type_[:_count_[:tag]]`</span> | a `Key` for the item's type, optionally followed by count (an integer) and tag (a [SNBT](https://minecraft.wiki/w/NBT_format#SNBT_format) string) |
246+
| `show_entity` | `_type_:_uuid_[:_name_]` | a `Key` ID of the entity type, the entity's UUID, and an optional custom name |
247+
248+
:::caution
249+
The `_type_[:_count_[:tag]]` value format for the `show_item` action is considered legacy and support for it may eventually be removed.
250+
The recommended format is `_type_[:_count_[(:_componentKey_:_componentValue_)...]]`.
251+
:::
243252

244253
Examples
245254
```mm
246255
<hover:show_text:'<red>test'>TEST
247256
```
248-
249257
<br/>
250258
<Image class="img-inline" alt="The result of parsing `<hover:show_text:'<red>test'>TEST`, shown in-game in the Minecraft client's chat window" src={Hover1} />
251259

260+
```mm
261+
<hover:show_item:diamond_sword:1:enchantments:'{sharpness:3,knockback:2}'>Very sharp sword!</hover>
262+
```
263+
<br/>
264+
<Image class="img-inline" alt="<hover:show_item:diamond_sword:1:enchantments:'{sharpness:3,knockback:2}'>Very sharp sword!</hover>" src={Hover2} />
265+
252266
### Keybind
253267

254268
Allows displaying the configured key for actions

0 commit comments

Comments
 (0)