Are you an LLM? You can read better optimized documentation at /pt\guide\usage\formatter\embedded-formatting.md for this page in Markdown format
Formatação embutida
Formata trechos embutidos em JS/TS (CSS em template literals, GraphQL em template literals, JS/TS/CSS etc. em Markdown).
Configuração
json
{
"embeddedLanguageFormatting": "auto"
}ts
import { defineConfig } from "oxfmt";
export default defineConfig({
embeddedLanguageFormatting: "auto",
});Valores
"auto"— (padrão) formatar seções embutidas"off"— não formatar embutido
Exemplos
CSS em template literal:
js
const styles = css`
.container {
background: blue;
color: ${theme.color};
}
`;styled-components:
js
const Button = styled.button`
background: ${(props) => props.primary};
color: white;
`;Styled JSX:
jsx
<style jsx>{`
.container {
background: blue;
color: red;
}
`}</style>GraphQL em template literal:
js
const query = gql`
query {
user {
id
name
}
}
`;
const query2 = graphql(`
query {
user {
id
name
}
}
${fragments.all}
`);HTML em template literal:
js
const template = html`
<div class="container">
<h1>Hello</h1>
<p>${world}</p>
</div>
`;Blocos JavaScript em Markdown:
md
Exemplo com bloco JS:
```js
const x = 1; // formatado se embutido estiver ativo.
```
Fim.JS e CSS em Vue:
vue
<script setup>
import { ref } from "vue";
import MyComponent from "./MyComponent.vue";
</script>
<style>
.container {
background: blue;
color: red;
}
</style>