# 인라인 서식 만들기 {#mark}

Source: [인라인 서식 만들기 | React 에디터에 커스텀 확장 만들기 · Yurich](https://leeyujoo.com/yurich/ko/extensions/mark/)

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

Package version: `0.1.2`

`mark()`로 문장 일부에 적용할 서식을 만듭니다. **Yurich**를 선택하고 **강조 표시**를 누르면 그 단어에 `<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를 조금 강조해 봅시다.</p>",
  });
  const active = useIsActive(editor, 'toggleHighlight');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleHighlight')}
      >
        강조 표시
      </button>
      <EditorContent ariaLabel="편집기" />
    </EditorProvider>
  );
}
```

## 결과 확인 {#result}

`editor.getHTML()`로 읽으면 **Yurich**만 `<mark>` 태그로 감싸져 있습니다.

```html
<p>오늘은 <mark>Yurich</mark>를 조금 강조해 봅시다.</p>
```

`editor.getJSON()`은 문서 전체를 트리로 반환합니다. 아래는 **Yurich**에 해당하는 텍스트 노드입니다. `marks`의 `highlight`는 `mark()`에 등록한 서식 이름입니다.

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

태그 이름은 소문자로 씁니다. `mark()`의 `aliases`로 뜻이 같은 입력 태그를 받아들일 수 있습니다.

[확장 검증하기](https://leeyujoo.com/yurich/ko/extensions/verify/)
