diff --git a/docs/content/developer/advanced/custom-indexer.mdx b/docs/content/developer/advanced/custom-indexer.mdx index f1fbf422cd9..d833a92eb9c 100644 --- a/docs/content/developer/advanced/custom-indexer.mdx +++ b/docs/content/developer/advanced/custom-indexer.mdx @@ -122,7 +122,7 @@ executor.run( Code for the cargo.toml manifest file for the custom indexer. -```.toml file=/examples/custom-indexer/rust/Cargo.toml +```toml file=/examples/custom-indexer/rust/Cargo.toml ``` ## Source Code diff --git a/docs/content/developer/getting-started/create-a-package.mdx b/docs/content/developer/getting-started/create-a-package.mdx index b2953a600fb..06466cf453e 100644 --- a/docs/content/developer/getting-started/create-a-package.mdx +++ b/docs/content/developer/getting-started/create-a-package.mdx @@ -101,7 +101,7 @@ for the dependencies. -```move +```toml [dependencies] iota = { override = true, git = "", subdir = "crates/iota-framework/packages/iota-framework", rev = "testnet" } MyPackage = { local = "../my-package" } @@ -109,7 +109,7 @@ MyPackage = { local = "../my-package" } -```move +```toml [dependencies.iota] override = true git = "https://github.com/iotaledger/iota.git" diff --git a/docs/site/docusaurus.config.js b/docs/site/docusaurus.config.js index 0432db446f7..ff0affda9ff 100644 --- a/docs/site/docusaurus.config.js +++ b/docs/site/docusaurus.config.js @@ -270,7 +270,7 @@ const config = { prism: { theme: themes.vsLight, darkTheme: themes.vsDark, - additionalLanguages: ["rust", "typescript", "toml", "solidity"], + additionalLanguages: ["rust", "typescript", "solidity"], }, }), }; diff --git a/docs/site/src/theme/prism-include-languages.js b/docs/site/src/theme/prism-include-languages.js index e4ef5e78f9d..2c398aa6609 100644 --- a/docs/site/src/theme/prism-include-languages.js +++ b/docs/site/src/theme/prism-include-languages.js @@ -1,12 +1,9 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 -import siteConfig from "@generated/docusaurus.config"; +import siteConfig from '@generated/docusaurus.config'; export default function prismIncludeLanguages(PrismObject) { const { - themeConfig: { prism }, + themeConfig: {prism}, } = siteConfig; - const { additionalLanguages } = prism; + const {additionalLanguages} = prism; // Prism components work on the Prism instance on the window, while prism- // react-renderer uses its own Prism instance. We temporarily mount the // instance onto window, import components to enhance it, then remove it to @@ -15,9 +12,14 @@ export default function prismIncludeLanguages(PrismObject) { // long as you don't re-assign it globalThis.Prism = PrismObject; additionalLanguages.forEach((lang) => { + if (lang === 'php') { + // eslint-disable-next-line global-require + require('prismjs/components/prism-markup-templating.js'); + } + // custom style for toml files + require('./prism-toml'); // eslint-disable-next-line global-require, import/no-dynamic-require require(`prismjs/components/prism-${lang}`); }); - require("./prism-move"); delete globalThis.Prism; } diff --git a/docs/site/src/theme/prism-toml.js b/docs/site/src/theme/prism-toml.js new file mode 100644 index 00000000000..bec461eac51 --- /dev/null +++ b/docs/site/src/theme/prism-toml.js @@ -0,0 +1,56 @@ +(function (Prism) { + + // Matches keys in TOML (e.g., `key`, `"quoted key"`, `key.subkey`) + var key = /(?:[A-Za-z0-9_-]+|"[^"\r\n]*")(?=\s*=)/; + + // Matches section headers like [package] + var sectionHeader = /\[[^\]\r\n]+\]/; + + // Matches dates in TOML (e.g., `1979-05-27T07:32:00Z`, `1979-05-27 07:32:00`, `1979-05-27`) + var date = /\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[-+]\d{2}:\d{2})?)?/; + + // Matches strings (basic and literal) + var string = /"(?:[^"\\\r\n]|\\.)*"|'[^'\r\n]*'/; + + // Matches booleans + var boolean = /\b(?:true|false)\b/; + + // Matches numbers, including hex, binary, octal, and floats + var number = /[+-]?(?:0x[\da-fA-F]+|0b[01]+|0o[0-7]+|\d+(\.\d+)?([eE][+-]?\d+)?)/; + + // Matches inline comments starting with `#` + var comment = /#.*/; + + Prism.languages.toml = { + 'section-header': { + pattern: sectionHeader, + alias: 'keyword' // Apply a distinct color for section headers by using the "keyword" alias + }, + 'comment': { + pattern: comment, + greedy: true + }, + 'key': { + pattern: key, + alias: 'attr-name' + }, + 'date': { + pattern: date, + alias: 'number' + }, + 'string': { + pattern: string, + greedy: true + }, + 'boolean': { + pattern: boolean, + alias: 'important' + }, + 'number': { + pattern: number, + alias: 'number' + }, + 'punctuation': /[=[\]{}.,]/ // Matches punctuation characters + }; + +}(Prism));