# Bold

> Mark selected text or the next typed characters as bold.

Bold adds the `bold` mark. Use it for text you want readers to spot, such as a new term or the key phrase in a release note.

## Try it

[Try the bold editor example](https://gpdoc.dev/docs/plugins/formatting/bold/#bold-example)

## Install

```sh
cargo add gpdoc-plugin-bold
```

## Example

Register the bold formatter in the [Quickstart editor configuration](/docs/quickstart/#configure-the-editor). `bold()` uses this formatter by default.

```rust
use gpdoc::{EditorConfig, PluginViewExt};
use gpdoc_plugin_bold::{bold, bold_format};
use gpdoc_plugin_paragraph::paragraph;


let config = EditorConfig::builder()
    .plugin(paragraph())
    .plugin(bold().with_view(bold_format))
    .build()
    .expect("configure editor");
```

Type `**release notes**` in a paragraph. The editor removes the asterisks and displays **release notes** in bold.

## Commands

These commands take no arguments. Select text to change its formatting, or place the caret where you want to start typing. `editor.run` returns `Result<CommandOutcome, Error>`. A handled command returns `Applied(AppliedChange)`. Set and toggle return `NotApplicable` if no text can take the mark.

### `setBold`

Apply bold to the selection or to the next characters typed at the caret.

```rust
editor.run(gpdoc_plugin_bold::Set)?;
```

### `toggleBold`

Switch bold off when the whole eligible selection has the mark. On a mixed selection, apply it throughout.

```rust
editor.run(gpdoc_plugin_bold::Toggle)?;
```

### `unsetBold`

Clear bold from the selection or turn it off for subsequent typing.

```rust
editor.run(gpdoc_plugin_bold::Unset)?;
```

## Keyboard shortcuts

Toggle bold with **Command + B** on macOS or **Ctrl + B** on Windows and Linux.

Typing `**release notes**` or `__release notes__` applies bold.