PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.26.1
Code Block Pro – Beautiful Syntax Highlighting v1.26.1
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / util / code.ts

code.ts in Code Block Pro – Beautiful Syntax Highlighting 1.26.1, at src/util/code.ts

28 lines 757 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { escapeHTML } from '@wordpress/escape-html';
2 import { decodeEntities } from '@wordpress/html-entities';
3 import { Attributes } from '../types';
4
5 export const encode = (code: string, { useDecodeURI }: Partial<Attributes>) => {
6 if (useDecodeURI) {
7 try {
8 // Here for bw compatability
9 return encodeURIComponent(code);
10 } catch (e) {
11 return code;
12 }
13 }
14 return escapeHTML(code);
15 };
16
17 export const decode = (code: string, { useDecodeURI }: Partial<Attributes>) => {
18 if (useDecodeURI) {
19 try {
20 // Here for bw compatability
21 return decodeURIComponent(code);
22 } catch (e) {
23 return code;
24 }
25 }
26 return decodeEntities(code);
27 };
28