Skip to content

Commit fb86972

Browse files
authored
Merge pull request #201 from Automattic/fix/transform-issue
Fix transform issue
2 parents 52e98ba + 38cbf3f commit fb86972

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

package-lock.json

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@wordpress/escape-html": "1.9.0",
2323
"cgb-scripts": "1.23.0",
2424
"classnames": "2.2.6",
25+
"lodash.unescape": "4.0.1",
2526
"npm-force-resolutions": "0.0.3"
2627
},
2728
"resolutions": {

src/code-block/transforms.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { createBlock } from '@wordpress/blocks';
2+
import { escapeHTML } from '@wordpress/escape-html';
3+
import unescape from 'lodash.unescape';
24

35
export default {
46
from: [
@@ -35,7 +37,7 @@ export default {
3537
type: 'block',
3638
blocks: [ 'core/code' ],
3739
transform: ( { content } ) => {
38-
return createBlock( 'syntaxhighlighter/code', { content } );
40+
return createBlock( 'syntaxhighlighter/code', { content: unescape( content ) } );
3941
},
4042
},
4143
],
@@ -44,7 +46,7 @@ export default {
4446
type: 'block',
4547
blocks: [ 'core/code' ],
4648
transform: ( { content } ) => {
47-
return createBlock( 'core/code', { content } );
49+
return createBlock( 'core/code', { content: escapeHTML( content ) } );
4850
},
4951
},
5052
],

0 commit comments

Comments
 (0)