# RtfSyntaxTree

Loss-preserving RTF syntax tree produced from tokens.

Class 

`OfficeIMO.Rtf.Syntax`

**Namespace**

`OfficeIMO.Rtf.Syntax`

**Assembly**

`OfficeIMO.Rtf`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[RtfSyntaxTree.cs:50](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L50)

**Modifiers**

sealed

Loss-preserving RTF syntax tree produced from tokens.

## Inheritance

- object
- RtfSyntaxTree

## Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 4

- Property [RtfLosslessEditor.SyntaxTree](/api/rtf/officeimo-rtf-rtflosslesseditor/#property-syntaxtree)
- Property [RtfReadResult.SyntaxTree](/api/rtf/officeimo-rtf-rtfreadresult/#property-syntaxtree)
- Method [RtfSyntaxParser.Parse](/api/rtf/officeimo-rtf-syntax-rtfsyntaxparser/#method-parse-string)
- Method [RtfSyntaxTree.Parse](/api/rtf/officeimo-rtf-syntax-rtfsyntaxtree/#method-parse-string)

### Accepted by parameters 2

- Constructor [RtfLosslessEditor.RtfLosslessEditor](/api/rtf/officeimo-rtf-rtflosslesseditor/#constructor-ctor-officeimo-rtf-syntax-rtfsyntaxtree) parameter `syntaxTree`
- Method [RtfSyntaxWriter.Write](/api/rtf/officeimo-rtf-syntax-rtfsyntaxwriter/#method-write-officeimo-rtf-syntax-rtfsyntaxtree) parameter `tree`

Filter members 

Show inherited

## Methods

`public RtfLosslessEditor EditLossless()` [#](#method-editlossless)

[RtfSyntaxTree.cs:71](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L71)

Creates an editor for targeted syntax-preserving changes.

Returns

`RtfLosslessEditor`

Parse 3 overloads

`public static RtfSyntaxTree Parse(string rtf)` [#](#method-parse-string)

[RtfSyntaxTree.cs:50](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L50)

Parses RTF content into a syntax tree.

Parameters

**rtf string required**

Returns

`RtfSyntaxTree`

`public static RtfSyntaxTree Parse(string rtf, int maxDepth)` [#](#method-parse-string-int32)

[RtfSyntaxTree.cs:55](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L55)

Parses RTF content into a syntax tree while limiting nested group depth.

Parameters

**rtf string required**

**maxDepth int required**

Returns

`RtfSyntaxTree`

`public static RtfSyntaxTree Parse(string rtf, RtfLoadOptions? options, CancellationToken cancellationToken = default)` [#](#method-parse-string-officeimo-rtf-rtfloadoptions-threading-cancellationtoken)

[RtfSyntaxTree.cs:61](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L61)

Parses RTF content using configured resource limits and cancellation.

Parameters

**rtf string required**

**options OfficeIMO.Rtf.RtfLoadOptions? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`RtfSyntaxTree`

`public string ToRtf()` [#](#method-tortf)

[RtfSyntaxTree.cs:66](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L66)

Serializes the original syntax tree without semantic normalization.

Returns

`string`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public RtfGroup Root { get; }` [#](#property-root)

[RtfSyntaxTree.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L24)

Root RTF group.

`public IReadOnlyList<RtfDiagnostic> Diagnostics { get; }` [#](#property-diagnostics)

[RtfSyntaxTree.cs:27](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Rtf/Syntax/RtfSyntaxTree.cs#L27)

Parser diagnostics.

<!-- PowerForge markdown artifact sha256:D618DC169F82FC0BE0B3EA3D84B2644C9589FF5E9E28D28140D6464358499352 -->
