diff --git a/src/code-block/transforms.js b/src/code-block/transforms.js index e402b64..03ed7ad 100644 --- a/src/code-block/transforms.js +++ b/src/code-block/transforms.js @@ -4,8 +4,13 @@ export default { from: [ { type: 'enter', - regExp: /^```$/, - transform: () => createBlock( 'syntaxhighlighter/code' ), + regExp: /^```\w*$/, + transform: ( { content = '' } ) => { + const [ , language ] = content.match( /^```(\w+)/ ) || [ null, null ]; + + const attributes = language ? { language } : undefined; + return createBlock( 'syntaxhighlighter/code', attributes ); + }, }, { type: 'raw', @@ -43,4 +48,4 @@ export default { }, }, ], -}; \ No newline at end of file +};