We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents cc1b7e7 + a287c5a commit 3b268abCopy full SHA for 3b268ab
src/code-block/transforms.js
@@ -21,6 +21,16 @@ export default {
21
node.children.length === 1 &&
22
node.firstChild.nodeName === 'CODE'
23
),
24
+ transform( node ) {
25
+ const content = node.firstChild.textContent;
26
+ const [ startingMatch, language ] = content.match( /^```(\w+)?\n/ ) || [ null, null ];
27
+ const attributes = language ? { language } : {};
28
+
29
+ // Extract content without backticks and (optionally) language.
30
+ attributes.content = startingMatch ? content.replace( startingMatch, '' ).replace( /```\s*$/, '' ) : content;
31
32
+ return createBlock( 'syntaxhighlighter/code', attributes );
33
+ },
34
schema: {
35
pre: {
36
children: {
0 commit comments