# @helpers4/markdown

> Tree-shakable TypeScript utility functions for the `markdown` domain.
> Package: `@helpers4/markdown` — Version: 2.0.1
> License: LGPL-3.0-or-later

## Installation

```sh
npm install @helpers4/markdown
# or
pnpm add @helpers4/markdown
```

## Usage

```typescript
import { escape } from '@helpers4/markdown';
```

## Functions

| Function | Description |
|---|---|
| `escape` | Escapes all Markdown special characters in a string so they render as literal text rather than forma |

---

## API Reference

### `escape`

Escapes all Markdown special characters in a string so they render as
literal text rather than formatting syntax.

Escaped characters: `\ \` * _ { } [ ] ( ) # + - . !`

Pass `{ cell: true }` to also escape pipe characters and replace newlines
with spaces, making the result safe for embedding in a Markdown table cell.

```typescript
import { escape } from '@helpers4/markdown';

escape(str: string, options?: EscapeOptions): string
```

**Parameters:**

- `str: string` — The raw string to escape
- `options?: EscapeOptions` — Optional escaping options

**Returns:** `string` — The escaped string

**Examples:**

*Escape special Markdown characters*

Prefixes every Markdown special character with a backslash.

```typescript
escape('**bold** and _italic_')
// => '\\*\\*bold\\*\\* and \\_italic\\_'
```

*Safely render user input inside Markdown*

Prevents user-supplied strings from breaking Markdown formatting.

```typescript
const userInput = '(C) [helpers4]';
const safe = escape(userInput);
// => '\\(C\\) \\[helpers4\\]'
```

---
