# code-block-pro/1.26.1/src/util/code.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.26.1. 28 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.26.1/code/src/util/code.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.26.1/raw/src/util/code.ts
- Modified: 2023-11-14T00:09:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.26.1/code/src/util/code.ts#L10-L20`.

```typescript
import { escapeHTML } from '@wordpress/escape-html';
import { decodeEntities } from '@wordpress/html-entities';
import { Attributes } from '../types';

export const encode = (code: string, { useDecodeURI }: Partial<Attributes>) => {
    if (useDecodeURI) {
        try {
            // Here for bw compatability
            return encodeURIComponent(code);
        } catch (e) {
            return code;
        }
    }
    return escapeHTML(code);
};

export const decode = (code: string, { useDecodeURI }: Partial<Attributes>) => {
    if (useDecodeURI) {
        try {
            // Here for bw compatability
            return decodeURIComponent(code);
        } catch (e) {
            return code;
        }
    }
    return decodeEntities(code);
};

```
