> For the complete documentation index, see [llms.txt](https://gitbook-open-v2-preview.gitbook.workers.dev/url/gitbook.gitbook.io/test-gitbook-open/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-open-v2-preview.gitbook.workers.dev/url/gitbook.gitbook.io/test-gitbook-open/blocks/code.md).

# Code

## Code block with lines and no wrapping

<pre class="language-typescript" data-line-numbers><code class="lang-typescript">function CodeHighlightLine(props: {
    block: DocumentBlockCode;
    line: HighlightLine;
    lineIndex: number;
    isLast: boolean;
    withLineNumbers: boolean;
    withWrap: boolean;
    context: ContentRefContext;
}) {
    const { block, line, isLast, withLineNumbers, context } = props;

    return (
        &#x3C;span
            className={tcls(
                'flex',
                'flex-row',
                'px-4',
                line.highlighted ? 'bg-slate-200' : null,
                withLineNumbers
                    ? [
                          'before:shrink-0',
                          'before:absolute',
                          'before:left-0',
                          'before:pl-4',
<strong>                          line.highlighted ? 'before:bg-slate-200' : 'before:bg-slate-100',
</strong>                          'before:text-slate-400',
                          'before:content-[counter(line)]',
                          '[counter-increment:line]',
                          getLineNumberGutterWidth(block),
                      ]
                    : [],
            )}
        >
            &#x3C;span className="flex-1">
                &#x3C;CodeHighlightTokens tokens={line.tokens} context={context} />
                {isLast ? null : !withLineNumbers &#x26;&#x26; line.tokens.length === 0 &#x26;&#x26; 0 ? (
                    &#x3C;span className="ew">{'\u200B'}&#x3C;/span>
                ) : (
                    '\n'
                )}
            &#x3C;/span>
        &#x3C;/span>
    );
}
</code></pre>

## Code block with line numbers and wrapping

<pre class="language-typescript" data-overflow="wrap" data-line-numbers><code class="lang-typescript">function CodeHighlightLine(props: {
    block: DocumentBlockCode;
    line: HighlightLine;
    lineIndex: number;
    isLast: boolean;
    withLineNumbers: boolean;
    withWrap: boolean;
    context: ContentRefContext;
}) {
    const { block, line, isLast, withLineNumbers, context } = props;

    return (
        &#x3C;span
            className={tcls(
                'flex',
                'flex-row',
                'px-4',
                line.highlighted ? 'bg-slate-200' : null,
                withLineNumbers
                    ? [
                          'before:shrink-0',
                          'before:absolute',
                          'before:left-0',
                          'before:pl-4',
<strong>                          line.highlighted ? 'before:bg-slate-200' : 'before:bg-slate-100',
</strong>                          'before:text-slate-400',
                          'before:content-[counter(line)]',
                          '[counter-increment:line]',
                          getLineNumberGutterWidth(block),
                      ]
                    : [],
            )}
        >
            &#x3C;span className="flex-1">
                &#x3C;CodeHighlightTokens tokens={line.tokens} context={context} />
                {isLast ? null : !withLineNumbers &#x26;&#x26; line.tokens.length === 0 &#x26;&#x26; 0 ? (
                    &#x3C;span className="ew">{'\u200B'}&#x3C;/span>
                ) : (
                    '\n'
                )}
            &#x3C;/span>
        &#x3C;/span>
    );
}
</code></pre>

## Code block with wrapping but no line numbers

<pre class="language-typescript" data-overflow="wrap"><code class="lang-typescript">function CodeHighlightLine(props: {
    block: DocumentBlockCode;
    line: HighlightLine;
    lineIndex: number;
    isLast: boolean;
    withLineNumbers: boolean;
    withWrap: boolean;
    context: ContentRefContext;
}) {
    const { block, line, isLast, withLineNumbers, context } = props;

    return (
        &#x3C;span
            className={tcls(
                'flex',
                'flex-row',
                'px-4',
                line.highlighted ? 'bg-slate-200' : null,
                withLineNumbers
                    ? [
                          'before:shrink-0',
                          'before:absolute',
                          'before:left-0',
                          'before:pl-4',
<strong>                          line.highlighted ? 'before:bg-slate-200' : 'before:bg-slate-100',
</strong>                          'before:text-slate-400',
                          'before:content-[counter(line)]',
                          '[counter-increment:line]',
                          getLineNumberGutterWidth(block),
                      ]
                    : [],
            )}
        >
            &#x3C;span className="flex-1">
                &#x3C;CodeHighlightTokens tokens={line.tokens} context={context} />
                {isLast ? null : !withLineNumbers &#x26;&#x26; line.tokens.length === 0 &#x26;&#x26; 0 ? (
                    &#x3C;span className="ew">{'\u200B'}&#x3C;/span>
                ) : (
                    '\n'
                )}
            &#x3C;/span>
        &#x3C;/span>
    );
}
</code></pre>

## Code block with full-width option

{% code fullWidth="true" %}

```
// Some code
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook-open-v2-preview.gitbook.workers.dev/url/gitbook.gitbook.io/test-gitbook-open/blocks/code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
