# Create an inline format {#mark}

Source: [Create an inline format | Create custom extensions for the React editor · Yurich](https://leeyujoo.com/yurich/extensions/mark/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

Use `mark()` to add a format to part of a line. Select **Yurich** and click **Highlight**. The selected word is wrapped in `<mark>`.

```tsx
import { mark, EditorContent, EditorProvider, useEditor, useIsActive } from 'yurich';

const Highlight = mark({ name: 'highlight', tag: 'mark', shortcut: 'Mod+Shift+H' });

export function HighlightEditor() {
  const editor = useEditor({
    extensions: [Highlight],
    initialValue: "<p>Yurich deserves a little emphasis.</p>",
  });
  const active = useIsActive(editor, 'toggleHighlight');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleHighlight')}
      >
        Highlight
      </button>
      <EditorContent ariaLabel="Editor" />
    </EditorProvider>
  );
}
```

## Result {#result}

In the HTML returned by `editor.getHTML()`, only **Yurich** is wrapped in `<mark>`.

```html
<p><mark>Yurich</mark> deserves a little emphasis.</p>
```

Below is the text node for **Yurich** in the document tree returned by `editor.getJSON()`. Its `marks` array contains `highlight`, the format name registered with `mark()`.

```json
{
  "type": "text",
  "text": "Yurich",
  "marks": [{ "type": "highlight" }]
}
```

Use lowercase tag names. The mark factory accepts an `aliases` list for equivalent input tags.

[Verify an extension](https://leeyujoo.com/yurich/extensions/verify/)
