From 5747a948a63784e32b777104010953e1c2cc264e Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 15 Jul 2025 16:28:16 +0900 Subject: [PATCH 1/6] Add global link references --- astro.config.mjs | 4 + package-lock.json | 15 +++ package.json | 1 + src/content/references/global.md | 2 + src/plugins/remarkGlobalReferences.ts | 129 ++++++++++++++++++++++++++ 5 files changed, 151 insertions(+) create mode 100644 src/content/references/global.md create mode 100644 src/plugins/remarkGlobalReferences.ts diff --git a/astro.config.mjs b/astro.config.mjs index 15d13d9..c02cc5d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -6,6 +6,7 @@ import starlight from '@astrojs/starlight' import tailwindcss from '@tailwindcss/vite' import { defineConfig } from 'astro/config' import starlightOpenAPI, { openAPISidebarGroups } from 'starlight-openapi' +import { remarkGlobalReferences } from './src/plugins/remarkGlobalReferences' // https://astro.build/config export default defineConfig({ @@ -311,6 +312,9 @@ export default defineConfig({ }), mdx(), ], + markdown: { + remarkPlugins: [remarkGlobalReferences], + }, vite: { plugins: [tailwindcss()], }, diff --git a/package-lock.json b/package-lock.json index ed62d35..9d11427 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "astro": "^5.10.1", "react": "^19.1.0", "react-dom": "^19.1.0", + "remark-reference-links": "^7.0.0", "starlight-openapi": "^0.19.1", "tailwindcss": "^4.1.11", "vanilla-cookieconsent": "^3.1.0" @@ -6421,6 +6422,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-reference-links": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-7.0.0.tgz", + "integrity": "sha512-OMACEps7CkpBio5nutUToCcXFJr9QkkoHdku41iIholMdFZ0jdRxgFmPm2B7R+DSvW83ZShdA3ubWTH+C3M6Eg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/remark-rehype": { "version": "11.1.2", "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.2.tgz", diff --git a/package.json b/package.json index 46b62eb..977fb3f 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "astro": "^5.10.1", "react": "^19.1.0", "react-dom": "^19.1.0", + "remark-reference-links": "^7.0.0", "starlight-openapi": "^0.19.1", "tailwindcss": "^4.1.11", "vanilla-cookieconsent": "^3.1.0" diff --git a/src/content/references/global.md b/src/content/references/global.md new file mode 100644 index 0000000..3dd391a --- /dev/null +++ b/src/content/references/global.md @@ -0,0 +1,2 @@ + +[Internal Type]: /docs/protocol-reference/binary-format diff --git a/src/plugins/remarkGlobalReferences.ts b/src/plugins/remarkGlobalReferences.ts new file mode 100644 index 0000000..4f41235 --- /dev/null +++ b/src/plugins/remarkGlobalReferences.ts @@ -0,0 +1,129 @@ +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import { visit } from 'unist-util-visit' + +/** + * Remark plugin to resolve reference-style links from global.md + */ +export function remarkGlobalReferences() { + let globalRefs: Record | null = null + + function loadGlobalReferences() { + if (globalRefs !== null) return globalRefs + + try { + const globalMdPath = join( + process.cwd(), + 'src/content/references/global.md', + ) + const content = readFileSync(globalMdPath, 'utf-8') + + globalRefs = {} + + // Parse reference-style link definitions: [label]: url + const lines = content.split('\n') + for (const line of lines) { + const match = line.match(/^\[([^\]]+)\]:\s*(.+)$/) + if (match) { + const [, label, url] = match + globalRefs[label] = url.trim() + } + } + + console.log('Loaded global references:', globalRefs) + return globalRefs + } catch (error: any) { + console.warn('Could not load global.md references:', error.message) + globalRefs = {} + return globalRefs + } + } + + return function transformer(tree: any) { + const refs = loadGlobalReferences() + + // Find all reference-style links in the format [text][] + visit(tree, 'linkReference', (node) => { + if ( + node.referenceType === 'shortcut' || + node.referenceType === 'collapsed' + ) { + const label = node.label || node.children?.[0]?.value + + if (label && refs[label]) { + // Convert linkReference to a regular link + node.type = 'link' + node.url = refs[label] + delete node.referenceType + delete node.identifier + delete node.label + + console.log(`Resolved reference [${label}][] to ${refs[label]}`) + } + } + }) + + // Also look for escaped reference-style links in text nodes: \[label]\[] + visit(tree, 'text', (node, index, parent) => { + if (!node.value) return + + // Find escaped reference-style links: \[label]\[] + const pattern = /\\?\[([^\]]+)\\?\]\\?\[\]/g + const replacements = [] + let match: RegExpExecArray | null = null + + match = pattern.exec(node.value) + while (match !== null) { + const [fullMatch, label] = match + if (refs[label]) { + replacements.push({ + start: match.index, + end: match.index + fullMatch.length, + label, + url: refs[label], + }) + console.log(`Found escaped reference ${fullMatch} -> ${refs[label]}`) + } + match = pattern.exec(node.value) + } + + // Apply replacements from right to left to maintain indices + if (replacements.length > 0) { + const newNodes = [] + let lastIndex = 0 + + for (const replacement of replacements) { + // Add text before the replacement + if (replacement.start > lastIndex) { + newNodes.push({ + type: 'text', + value: node.value.slice(lastIndex, replacement.start), + }) + } + + // Add the link + newNodes.push({ + type: 'link', + url: replacement.url, + children: [{ type: 'text', value: replacement.label }], + }) + + lastIndex = replacement.end + } + + // Add remaining text + if (lastIndex < node.value.length) { + newNodes.push({ + type: 'text', + value: node.value.slice(lastIndex), + }) + } + + // Replace the current node with the new nodes + if (parent && typeof index === 'number') { + parent.children.splice(index, 1, ...newNodes) + } + } + }) + } +} From 2a73058eab803fc55429c3ddd4ea117dacd80d45 Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 15 Jul 2025 17:03:17 +0900 Subject: [PATCH 2/6] add references --- src/content/references/global.md | 7 ++ src/content/references/pseudo-transactions.md | 5 ++ src/content/references/transactions.md | 38 ++++++++++ src/plugins/remarkGlobalReferences.ts | 74 +++++++++++++++---- 4 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 src/content/references/pseudo-transactions.md create mode 100644 src/content/references/transactions.md diff --git a/src/content/references/global.md b/src/content/references/global.md index 3dd391a..d4e8870 100644 --- a/src/content/references/global.md +++ b/src/content/references/global.md @@ -1,2 +1,9 @@ [Internal Type]: /docs/protocol-reference/binary-format +[Sequence Number]: /docs/protocol-reference/data-types/#account-sequence +[Index Number]: /docs/protocol-reference/data-types/#index-number +[SHA-512Half]: /docs/protocol-reference/data-types/#hashes +[Specifying Time]: /docs/protocol-reference/data-types/#specifying-time +[seconds since the Ripple Epoch]: /docs/protocol-reference/data-types/#specifying-time +[Ledger Index]: /docs/protocol-reference/data-types/#ledger-index +[ledger index]: /docs/protocol-reference/data-types/#ledger-index diff --git a/src/content/references/pseudo-transactions.md b/src/content/references/pseudo-transactions.md new file mode 100644 index 0000000..fb9acd0 --- /dev/null +++ b/src/content/references/pseudo-transactions.md @@ -0,0 +1,5 @@ +EnableAmendment +EmitFailure +SetFee +UNLModify +UNLReport diff --git a/src/content/references/transactions.md b/src/content/references/transactions.md new file mode 100644 index 0000000..901145f --- /dev/null +++ b/src/content/references/transactions.md @@ -0,0 +1,38 @@ +AccountDelete +AccountSet +CheckCancel +CheckCash +CheckCreate +ClaimReward +Clawback +DepositPreauth +EscrowCancel +EscrowCreate +EscrowFinish +GenesisMint +Import +Invoke +NFTokenAcceptOffer +NFTokenBurn +NFTokenCancelOffer +NFTokenCreateOffer +NFTokenMint +OfferCancel +OfferCreate +Payment +PaymentChannelClaim +PaymentChannelCreate +PaymentChannelFund +Remit +SetHook +SetRegularKey +SetRemarks +SignerListSet +SpinalTap +TicketCreate +TrustSet +URITokenBurn +URITokenBuy +URITokenCancelSellOffer +URITokenCreateSellOffer +URITokenMint diff --git a/src/plugins/remarkGlobalReferences.ts b/src/plugins/remarkGlobalReferences.ts index 4f41235..66d1d18 100644 --- a/src/plugins/remarkGlobalReferences.ts +++ b/src/plugins/remarkGlobalReferences.ts @@ -1,7 +1,59 @@ import { readFileSync } from 'node:fs' -import { join } from 'node:path' import { visit } from 'unist-util-visit' +const parseRules: { + path: string + parse: (content: string) => { label: string; url: string }[] +}[] = [ + { + path: 'src/content/references/global.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + const match = line.match(/^\[([^\]]+)\]:\s*(.+)$/) + if (match) { + const [, label, url] = match + result.push({ label, url: url.trim() }) + } + } + return result + }, + }, + { + path: 'src/content/references/transactions.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + if (line.length > 0) { + const url = `/docs/protocol-reference/transactions/transaction-types/${line.toLowerCase()}` + result.push({ label: `${line}`, url }) + result.push({ label: `${line} transaction`, url }) + result.push({ label: `${line} transactions`, url }) + } + } + return result + }, + }, + { + path: 'src/content/references/pseudo-transactions.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + if (line.length > 0) { + const url = `/docs/protocol-reference/transactions/pseudo-transaction-types/${line.toLowerCase()}` + result.push({ label: `${line}`, url }) + result.push({ label: `${line} transaction`, url }) + result.push({ label: `${line} transactions`, url }) + } + } + return result + }, + }, + ] + /** * Remark plugin to resolve reference-style links from global.md */ @@ -12,25 +64,15 @@ export function remarkGlobalReferences() { if (globalRefs !== null) return globalRefs try { - const globalMdPath = join( - process.cwd(), - 'src/content/references/global.md', - ) - const content = readFileSync(globalMdPath, 'utf-8') - globalRefs = {} - - // Parse reference-style link definitions: [label]: url - const lines = content.split('\n') - for (const line of lines) { - const match = line.match(/^\[([^\]]+)\]:\s*(.+)$/) - if (match) { - const [, label, url] = match - globalRefs[label] = url.trim() + for (const rule of parseRules) { + const content = readFileSync(rule.path, 'utf-8') + const refs = rule.parse(content) + for (const ref of refs) { + globalRefs[ref.label] = ref.url } } - console.log('Loaded global references:', globalRefs) return globalRefs } catch (error: any) { console.warn('Could not load global.md references:', error.message) From cdd2f5058c40819933902e60859a684cb9afce8e Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 15 Jul 2025 17:12:46 +0900 Subject: [PATCH 3/6] remove log --- src/plugins/remarkGlobalReferences.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/remarkGlobalReferences.ts b/src/plugins/remarkGlobalReferences.ts index 66d1d18..f24bfcc 100644 --- a/src/plugins/remarkGlobalReferences.ts +++ b/src/plugins/remarkGlobalReferences.ts @@ -99,8 +99,6 @@ export function remarkGlobalReferences() { delete node.referenceType delete node.identifier delete node.label - - console.log(`Resolved reference [${label}][] to ${refs[label]}`) } } }) @@ -124,7 +122,6 @@ export function remarkGlobalReferences() { label, url: refs[label], }) - console.log(`Found escaped reference ${fullMatch} -> ${refs[label]}`) } match = pattern.exec(node.value) } From 7d4eebdfb4d6791979d33bf25991fa299d8fc1c7 Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 15 Jul 2025 17:27:25 +0900 Subject: [PATCH 4/6] update global.md --- src/content/references/global.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/content/references/global.md b/src/content/references/global.md index d4e8870..d29a686 100644 --- a/src/content/references/global.md +++ b/src/content/references/global.md @@ -7,3 +7,7 @@ [seconds since the Ripple Epoch]: /docs/protocol-reference/data-types/#specifying-time [Ledger Index]: /docs/protocol-reference/data-types/#ledger-index [ledger index]: /docs/protocol-reference/data-types/#ledger-index +[Hash]: /docs/protocol-reference/data-types/#hashes +[Address]: /docs/protocol-reference/data-types/#addresses +[Currency Amount]: /docs/protocol-reference/data-types/#specifying-currency-amounts +[drops of XAH]: /docs/protocol-reference/data-types/#specifying-currency-amounts From 3c8cfe206ffa5087f7291852cbce2fd49dd27e4d Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 15 Jul 2025 17:35:00 +0900 Subject: [PATCH 5/6] format --- src/plugins/remarkGlobalReferences.ts | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/plugins/remarkGlobalReferences.ts b/src/plugins/remarkGlobalReferences.ts index f24bfcc..0d5f4c8 100644 --- a/src/plugins/remarkGlobalReferences.ts +++ b/src/plugins/remarkGlobalReferences.ts @@ -5,54 +5,54 @@ const parseRules: { path: string parse: (content: string) => { label: string; url: string }[] }[] = [ - { - path: 'src/content/references/global.md', - parse: (content: string) => { - const lines = content.split('\n') - const result: { label: string; url: string }[] = [] - for (const line of lines) { - const match = line.match(/^\[([^\]]+)\]:\s*(.+)$/) - if (match) { - const [, label, url] = match - result.push({ label, url: url.trim() }) - } + { + path: 'src/content/references/global.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + const match = line.match(/^\[([^\]]+)\]:\s*(.+)$/) + if (match) { + const [, label, url] = match + result.push({ label, url: url.trim() }) } - return result - }, + } + return result }, - { - path: 'src/content/references/transactions.md', - parse: (content: string) => { - const lines = content.split('\n') - const result: { label: string; url: string }[] = [] - for (const line of lines) { - if (line.length > 0) { - const url = `/docs/protocol-reference/transactions/transaction-types/${line.toLowerCase()}` - result.push({ label: `${line}`, url }) - result.push({ label: `${line} transaction`, url }) - result.push({ label: `${line} transactions`, url }) - } + }, + { + path: 'src/content/references/transactions.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + if (line.length > 0) { + const url = `/docs/protocol-reference/transactions/transaction-types/${line.toLowerCase()}` + result.push({ label: `${line}`, url }) + result.push({ label: `${line} transaction`, url }) + result.push({ label: `${line} transactions`, url }) } - return result - }, + } + return result }, - { - path: 'src/content/references/pseudo-transactions.md', - parse: (content: string) => { - const lines = content.split('\n') - const result: { label: string; url: string }[] = [] - for (const line of lines) { - if (line.length > 0) { - const url = `/docs/protocol-reference/transactions/pseudo-transaction-types/${line.toLowerCase()}` - result.push({ label: `${line}`, url }) - result.push({ label: `${line} transaction`, url }) - result.push({ label: `${line} transactions`, url }) - } + }, + { + path: 'src/content/references/pseudo-transactions.md', + parse: (content: string) => { + const lines = content.split('\n') + const result: { label: string; url: string }[] = [] + for (const line of lines) { + if (line.length > 0) { + const url = `/docs/protocol-reference/transactions/pseudo-transaction-types/${line.toLowerCase()}` + result.push({ label: `${line}`, url }) + result.push({ label: `${line} transaction`, url }) + result.push({ label: `${line} transactions`, url }) } - return result - }, + } + return result }, - ] + }, +] /** * Remark plugin to resolve reference-style links from global.md From b2ade5a57641d58cc6b0b9695835181deeb09985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ekiserrep=C3=A9?= <126416117+Ekiserrepe@users.noreply.github.com> Date: Thu, 24 Jul 2025 08:34:09 +0200 Subject: [PATCH 6/6] Update about.mdx --- src/pages/about.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/about.mdx b/src/pages/about.mdx index 97669f8..246b825 100644 --- a/src/pages/about.mdx +++ b/src/pages/about.mdx @@ -40,7 +40,7 @@ Because of Hooks, the burn-rate of XAH is higher compared to that of XRPL. For p ## What key events have there been for Xahau? Xahau was launched on October 30, 2023 by the Xahau Launch Alliance, an interim alliance formed by long-term, non-Ripple, XRPL developers, organisations and infrastructure providers: XRPL Labs, GateHub Limited, Titanium OU, Evernode Labs Ltd, and Digital Governing OU. -In the first year Xahau has received many updates, such as a new native feature, Remit, in March 2023, performance improvements, memory only nodes and JavaScript hook support. +In the first year Xahau has received many updates, such as a new native feature, Remit, in March 2024, performance improvements, memory only nodes and JavaScript hook support. Within the first year, the first cross-border remittance service was launched in collaboration between The Inclusive Financial Technologies Foundation (InFTF) and the Cooperative Bank of Oromia (COOP), one of Ethiopia's largest banks with more than 13 million account holders. The inward remittance solution helps the African Diaspora, many of whom work as blue-collar workers throughout the Middle East, US, and Europe, send money back to their friends and family in Ethiopia. With the service, initially launched for inward remittances using EUR, anyone can buy digital EUR, send it via blockchain for little to no cost, and have it settle in the bank account of a family member or friend in the local currency, ETB, within seconds.