> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# markdownToFragment

> Convert a Markdown string into an SDM/1 structural fragment.

## Summary

Convert a Markdown string into an SDM/1 structural fragment.

* Operation ID: `markdownToFragment`
* API member path: `editor.doc.markdownToFragment(...)`
* Mutates document: `no`
* Idempotency: `idempotent`
* Supports tracked mode: `no`
* Supports dry run: `no`
* Deterministic target resolution: `yes`

## Expected result

Returns an SDMarkdownToFragmentResult with the converted fragment, lossy flag, and diagnostics.

## Input fields

| Field | Type | Required | Description |
| - | - | - | - |
| `markdown` | string | yes | |

### Example request

```json theme={null}
{
  "markdown": "example"
}
```

## Output fields

| Field | Type | Required | Description |
| - | - | - | - |
| `diagnostics` | object\[] | yes | |
| `fragment` | any | yes | |
| `lossy` | boolean | yes | |

### Example response

```json theme={null}
{
  "diagnostics": [
    {
      "code": "INVALID_TARGET",
      "message": "Operation failed.",
      "path": [
        "example"
      ],
      "severity": "error"
    }
  ],
  "fragment": {},
  "lossy": true
}
```

## Pre-apply throws

* None

## Non-applied failure codes

* None

## Raw schemas

> [accordion] Raw input schema
>
> ```json theme={null}
> {
>   "additionalProperties": false,
>   "properties": {
>     "markdown": {
>       "type": "string"
>     }
>   },
>   "required": [
>     "markdown"
>   ],
>   "type": "object"
> }
> ```

> [accordion] Raw output schema
>
> ```json theme={null}
> {
>   "additionalProperties": false,
>   "properties": {
>     "diagnostics": {
>       "items": {
>         "additionalProperties": false,
>         "properties": {
>           "code": {
>             "type": "string"
>           },
>           "message": {
>             "type": "string"
>           },
>           "path": {
>             "items": {
>               "type": "string"
>             },
>             "type": "array"
>           },
>           "severity": {
>             "enum": [
>               "error",
>               "warning",
>               "info"
>             ],
>             "type": "string"
>           }
>         },
>         "required": [
>           "code",
>           "severity",
>           "message"
>         ],
>         "type": "object"
>       },
>       "type": "array"
>     },
>     "fragment": {},
>     "lossy": {
>       "type": "boolean"
>     }
>   },
>   "required": [
>     "fragment",
>     "lossy",
>     "diagnostics"
>   ],
>   "type": "object"
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.