diff --git a/astro.config.ts b/astro.config.ts index c88575946..0283ba67a 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -2,6 +2,7 @@ import starlight from "@astrojs/starlight"; import svelte from "@astrojs/svelte"; import d2 from "astro-d2"; import { defineConfig } from "astro/config"; +import { extendedTableHandlers, remarkExtendedTable } from "remark-extended-table"; import starlightLinksValidator from "starlight-links-validator"; import starlightSidebarTopics from "starlight-sidebar-topics"; import codeConstantsPlugin from "./src/utils/remark/code_const"; @@ -545,7 +546,13 @@ export default defineConfig({ domains: ["assets.papermc.io"], }, markdown: { + remarkRehype: { + handlers: { + ...extendedTableHandlers, + }, + }, remarkPlugins: [ + remarkExtendedTable, [ javadocPlugin, { diff --git a/package.json b/package.json index be63a359d..9c756e14e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "astro": "^6.0.8", "astro-contributors": "^0.8.0", "astro-d2": "^0.10.0", + "remark-extended-table": "^2.0.3", "sharp": "^0.34.5", "starlight-links-validator": "^0.20.1", "starlight-sidebar-topics": "^0.7.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6086b9c4a..00ab83205 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,6 +43,9 @@ importers: astro-d2: specifier: ^0.10.0 version: 0.10.0(astro@6.0.8(@types/node@25.5.0)(rollup@4.60.0)(typescript@5.9.3)(yaml@2.8.3)) + remark-extended-table: + specifier: ^2.0.3 + version: 2.0.3(mdast-util-gfm-table@2.0.0)(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2)(remark-gfm@4.0.1)(remark-parse@11.0.0)(unified@11.0.5) sharp: specifier: ^0.34.5 version: 0.34.5 @@ -1355,6 +1358,11 @@ packages: mdast-util-directive@3.1.0: resolution: {integrity: sha512-I3fNFt+DHmpWCYAT7quoM6lHf9wuqtI+oCOfvILnoicNIqjh5E3dEJWiXuYME2gNe8vl1iMQwyUHa7bgFmak6Q==} + mdast-util-extended-table@2.0.3: + resolution: {integrity: sha512-0iI/BQt2EhzBDmg1NBxA/PfQVIej//csZVbHlrQzZkIpf0acaMzafKhkYcL0jSkkzT0456dxFKs4mo6w6s6lhg==} + peerDependencies: + mdast-util-gfm-table: ^2.0.0 + mdast-util-find-and-replace@3.0.2: resolution: {integrity: sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==} @@ -1415,6 +1423,12 @@ packages: micromark-extension-directive@3.0.2: resolution: {integrity: sha512-wjcXHgk+PPdmvR58Le9d7zQYWy+vKEU9Se44p2CrCDPiLr2FMyiT4Fyb5UFKFC66wGB3kPlgD7q3TnoqPS7SZA==} + micromark-extension-extended-table@2.0.3: + resolution: {integrity: sha512-EiY5KVzlamDZ+7rYJIOHiBLJdPLi0RYz7/EF26EYr9IGFVkQQIDNZVfIdwiDqRsUnac3lElg3JvjMTsluP69tQ==} + peerDependencies: + micromark: ^4.0.0 + micromark-extension-gfm-table: ^2.0.0 + micromark-extension-gfm-autolink-literal@2.1.0: resolution: {integrity: sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==} @@ -1714,6 +1728,13 @@ packages: remark-directive@3.0.1: resolution: {integrity: sha512-gwglrEQEZcZYgVyG1tQuA+h58EZfq5CSULw7J90AFuCTyib1thgHPoqQ+h9iFvU6R+vnZ5oNFQR5QKgGpk741A==} + remark-extended-table@2.0.3: + resolution: {integrity: sha512-XjdccSpz/SmKLkrNi4KD8Nl20mfMk9KwUiD2m5HLjkS8bowxxS+Vq1mz5J9V/ZnHCtUiJ0pHr/gEC2HUopcI1A==} + peerDependencies: + remark-gfm: ^4.0.0 + remark-parse: ^11.0.0 + unified: ^11.0.0 + remark-gfm@4.0.1: resolution: {integrity: sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==} @@ -1931,6 +1952,9 @@ packages: unifont@0.7.4: resolution: {integrity: sha512-oHeis4/xl42HUIeHuNZRGEvxj5AaIKR+bHPNegRq5LV1gdc3jundpONbjglKpihmJf+dswygdMJn3eftGIMemg==} + unist-builder@4.0.0: + resolution: {integrity: sha512-wmRFnH+BLpZnTKpc5L7O67Kac89s9HMrtELpnNaE6TAobq5DTZZs5YaTQfAZBA9bFPECx2uVAPO31c+GVug8mg==} + unist-util-find-after@5.0.0: resolution: {integrity: sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==} @@ -3528,6 +3552,24 @@ snapshots: transitivePeerDependencies: - supports-color + mdast-util-extended-table@2.0.3(mdast-util-gfm-table@2.0.0)(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2): + dependencies: + '@types/hast': 3.0.4 + '@types/mdast': 4.0.4 + '@types/unist': 3.0.3 + mdast-util-from-markdown: 2.0.3 + mdast-util-gfm-table: 2.0.0 + mdast-util-to-hast: 13.2.1 + mdast-util-to-markdown: 2.1.2 + micromark-extension-extended-table: 2.0.3(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2) + unist-builder: 4.0.0 + unist-util-position: 5.0.0 + unist-util-visit: 5.1.0 + transitivePeerDependencies: + - micromark + - micromark-extension-gfm-table + - supports-color + mdast-util-find-and-replace@3.0.2: dependencies: '@types/mdast': 4.0.4 @@ -3724,6 +3766,14 @@ snapshots: micromark-util-types: 2.0.2 parse-entities: 4.0.2 + micromark-extension-extended-table@2.0.3(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2): + dependencies: + micromark: 4.0.2 + micromark-extension-gfm-table: 2.1.1 + micromark-util-chunked: 2.0.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.2 + micromark-extension-gfm-autolink-literal@2.1.0: dependencies: micromark-util-character: 2.1.1 @@ -4198,6 +4248,19 @@ snapshots: transitivePeerDependencies: - supports-color + remark-extended-table@2.0.3(mdast-util-gfm-table@2.0.0)(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2)(remark-gfm@4.0.1)(remark-parse@11.0.0)(unified@11.0.5): + dependencies: + mdast-util-extended-table: 2.0.3(mdast-util-gfm-table@2.0.0)(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2) + micromark-extension-extended-table: 2.0.3(micromark-extension-gfm-table@2.1.1)(micromark@4.0.2) + remark-gfm: 4.0.1 + remark-parse: 11.0.0 + unified: 11.0.5 + transitivePeerDependencies: + - mdast-util-gfm-table + - micromark + - micromark-extension-gfm-table + - supports-color + remark-gfm@4.0.1: dependencies: '@types/mdast': 4.0.4 @@ -4533,6 +4596,10 @@ snapshots: ofetch: 1.5.1 ohash: 2.0.11 + unist-builder@4.0.0: + dependencies: + '@types/unist': 3.0.3 + unist-util-find-after@5.0.0: dependencies: '@types/unist': 3.0.3 diff --git a/src/content/docs/adventure/minimessage/assets/hover_2.png b/src/content/docs/adventure/minimessage/assets/hover_2.png new file mode 100644 index 000000000..d80fd4c41 Binary files /dev/null and b/src/content/docs/adventure/minimessage/assets/hover_2.png differ diff --git a/src/content/docs/adventure/minimessage/format.mdx b/src/content/docs/adventure/minimessage/format.mdx index a272db9d0..1e6063dd1 100644 --- a/src/content/docs/adventure/minimessage/format.mdx +++ b/src/content/docs/adventure/minimessage/format.mdx @@ -5,6 +5,7 @@ description: The MiniMessage format documentation. --- import { Image } from "astro:assets"; +import { Badge } from "@astrojs/starlight/components"; import Shadow1 from "./assets/shadow_1.png"; import Shadow2 from "./assets/shadow_2.png"; import Shadow3 from "./assets/shadow_3.png"; @@ -16,6 +17,7 @@ import Decoration1 from "./assets/decoration_1.png"; import Reset1 from "./assets/reset_1.png"; import Click1 from "./assets/click_1.png"; import Hover1 from "./assets/hover_1.png"; +import Hover2 from "./assets/hover_2.png"; import Key1 from "./assets/key_1.png"; import Translatable1 from "./assets/translatable_1.png"; 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 Allows doing multiple things when hovering on the component. Tag - * `` + * `` Arguments * `_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) - * `_value..._`, arguments specific to each event action: + * `_value_`, argument(s) specific to each event action: -| Action | Value | -|---------------|---------------------------------------------------------------------------------------------------------------------------| -| `show_text` | `_text_` (a MiniMessage string) | -| `show_item` | `_type_[:_count_[:tag]]` (a `Key` for the item's type, optionally followed by count (an integer) and tag (a SNBT string)) | -| `show_entity` | `_type_:_uuid_[:_name_]` (a `Key` ID of the entity type, the entity's UUID, and an optional custom name) | +[//]: # (FIXME: Starlight's padding doesn't apply for a spanned cell, so a manual padding is added) +| Action | Value | Description | +|---------------|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `show_text` | `_text_` | a MiniMessage string | +| `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 | +| ^ | `_type_[:_count_[:tag]]` | 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) | +| `show_entity` | `_type_:_uuid_[:_name_]` | a `Key` ID of the entity type, the entity's UUID, and an optional custom name | + +:::caution +The `_type_[:_count_[:tag]]` value format for the `show_item` action is considered legacy and support for it may eventually be removed. +The recommended format is `_type_[:_count_[(:_componentKey_:_componentValue_)...]]`. +::: Examples ```mm test'>TEST ``` -
The result of parsing `<hover:show_text:'<red>test'>TEST`, shown in-game in the Minecraft client's chat window +```mm +Very sharp sword! +``` +
+<hover:show_item:diamond_sword:1:enchantments:'{sharpness:3,knockback:2}'>Very sharp sword!</hover> + ### Keybind Allows displaying the configured key for actions