Formats the code in the playground editors using Prettier. By default, code in all editors (markup, style, and script) is formatted. To format only the active editor, passDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/live-codes/livecodes/llms.txt
Use this file to discover all available pages before exploring further.
false as an argument.
Signature
Parameters
If
true (default), formats code in all three editors. If false, formats only the currently active editor.Returns
A promise that resolves when the code formatting is complete.
Usage
Format All Editors
Format Active Editor Only
Format with Custom Settings
The formatter respects the configuration settings for code style:Formatter Configuration
The following configuration properties affect code formatting:useTabs- Use tabs instead of spaces (default:false)tabSize- Number of spaces per indentation level (default:2)semicolons- Use semicolons in JavaScript/TypeScript (default:true)singleQuote- Use single quotes instead of double quotes (default:false)trailingComma- Use trailing commas (default:true)
Notes
- Not all languages support formatting. The formatter uses Prettier which supports HTML, CSS, JavaScript, TypeScript, JSON, Markdown, and many other languages.
- Formatting is performed client-side in the browser.
- If the playground is not yet loaded, calling this method will load it first.
Related Methods
getConfig()- Get current configuration including formatter settingssetConfig()- Update formatter configuration