# DataProcessor

interface

The data processor interface. It should be implemented by actual data processors.

Each data processor implements a certain format of the data. For example, [Markdown data processor](../features/markdown.md) will convert the data (a Markdown string) to a [document fragment](module_engine_view_documentfragment-ViewDocumentFragment.md) and back.

**Note:** While the CKEditor 5 architecture supports changing the data format, in most scenarios we do recommend sticking to the default format which is HTML (supported by the [`HtmlDataProcessor`](module_engine_dataprocessor_htmldataprocessor-HtmlDataProcessor.md)). HTML remains [the best standard for rich-text data](https://medium.com/content-uneditable/a-standard-for-rich-text-data-4b3a507af552).

And please do remember – using Markdown [does not automatically make your application/website secure](https://github.com/ckeditor/ckeditor5-markdown-gfm/issues/16#issuecomment-375752994).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L27)

<a id="properties">

## Properties

<a id="member-skipComments">

### `skipComments?: boolean`

If `false`, comment nodes will be converted to `$comment`. Otherwise comment nodes are ignored.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L69)

<a id="methods">

## Methods

<a id="function-registerRawContentMatcher">

### `registerRawContentMatcher( pattern ) → void`

Registers a [`MatcherPattern`](module_engine_view_matcher-MatcherPattern.md) for view elements whose content should be treated as raw data and its content should be converted to a [custom property of a view element](module_engine_view_element-ViewElement.md#function-getCustomProperty) called `"$rawContent"` while converting [to view](#function-toView).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L51)

#### Parameters

* `pattern: MatcherPattern`

  Pattern matching all view elements whose content should be treated as plain text.

#### Returns

* `void`

<a id="function-toData">

### `toData( viewFragment ) → string`

Converts a [document fragment](module_engine_view_documentfragment-ViewDocumentFragment.md) to data.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L34)

#### Parameters

* `viewFragment: ViewDocumentFragment`

  The document fragment to be processed.

#### Returns

* `string`

<a id="function-toView">

### `toView( data ) → ViewDocumentFragment`

Converts the data to a [document fragment](module_engine_view_documentfragment-ViewDocumentFragment.md).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L41)

#### Parameters

* `data: string`

  The data to be processed.

#### Returns

* `ViewDocumentFragment`

<a id="function-useFillerType">

### `useFillerType( type ) → void`

If the processor is set to use marked fillers, it will insert `&nbsp;` fillers wrapped in `<span>` elements (`<span data-cke-filler="true">&nbsp;</span>`) instead of regular `&nbsp;` characters.

This mode allows for more precise handling of block fillers (so they do not leak into the editor content) but bloats the editor data with additional markup.

This mode may be required by some features and will be turned on by them automatically.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.ts#L64)

#### Parameters

* `type: 'default' | 'marked'`

  Whether to use the default or marked `&nbsp;` block fillers.

#### Returns

* `void`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
