Skip to main content

Code

ToastWrite supports fenced code blocks and inline code spans.

Inline code

Wrap text in single backticks:

Use the `Editor` class to create an instance.

Fenced code blocks

Use triple backticks with an optional language identifier for syntax highlighting in the editor:

```ts
import { Editor, Viewer } from '@toastwrite/editor';
import '@toastwrite/editor/style.css';

const editor = new Editor({
el: document.querySelector('#editor-root')!,
previewStyle: 'vertical',
});
```

Supported language tags depend on the bundled highlighter; common values include ts, js, json, html, css, and bash.

Indented code blocks

CommonMark indented blocks (four spaces) are also supported, though fenced blocks are recommended:

const x = 1;
console.log(x);

Toolbar

TypeToolbarShortcut
Inline codeCodeMod-e
Code blockCode blockMod-Shift-c

Tips

  • Use fenced blocks for multi-line code; inline code is for short fragments inside prose.
  • The editor applies syntax highlighting classes in the Markdown pane; preview rendering shows the formatted code block.