Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs): Correct all occurrences of toml code blocks #3713

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/developer/advanced/custom-indexer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ executor.run(

Code for the cargo.toml manifest file for the custom indexer.

```.toml file=<rootDir>/examples/custom-indexer/rust/Cargo.toml
```toml file=<rootDir>/examples/custom-indexer/rust/Cargo.toml
```

## Source Code
Expand Down
4 changes: 2 additions & 2 deletions docs/content/developer/getting-started/create-a-package.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ for the dependencies.
<Tabs groupId="toml-style">
<TabItem label="Inline" value="inline">

```move
```toml
[dependencies]
iota = { override = true, git = "", subdir = "crates/iota-framework/packages/iota-framework", rev = "testnet" }
MyPackage = { local = "../my-package" }
```

</TabItem>
<TabItem label="Multiline" value="multiline">
```move
```toml
[dependencies.iota]
override = true
git = "https://github.com/iotaledger/iota.git"
Expand Down
2 changes: 1 addition & 1 deletion docs/site/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const config = {
prism: {
theme: themes.vsLight,
darkTheme: themes.vsDark,
additionalLanguages: ["rust", "typescript", "toml", "solidity"],
additionalLanguages: ["rust", "typescript", "solidity"],
},
}),
};
Expand Down
16 changes: 9 additions & 7 deletions docs/site/src/theme/prism-include-languages.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
}
56 changes: 56 additions & 0 deletions docs/site/src/theme/prism-toml.js
Original file line number Diff line number Diff line change
@@ -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));
Loading