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

Code Block Pro – Beautiful Syntax Highlighting, version 1.28.0. 35 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.28.0/code/src/util/code.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.28.0/raw/src/util/code.ts
- Modified: 2026-04-12T13:22:22+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.28.0/code/src/util/code.ts#L10-L20`.

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

export const encode = (code: string, { useDecodeURI }: Partial<Attributes>) => {
	if (useDecodeURI) {
		try {
			// Here for bw compatability
			return encodeURIComponent(code);
		} catch (e) {
			console.error(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) {
			console.error(e);
			return code;
		}
	}
	return decodeEntities(code);
};

export const escapeShortcodes = (content: string) =>
	content.replaceAll(/\[([^[\]]+)\]/g, (match) =>
		match.replace('[', '&#91;').replace(']', '&#93;'),
	);

```
