Title: Easy migration path to this plugin from &#8216;Code Syntax Block&#8217;
Last modified: November 10, 2020

---

# Easy migration path to this plugin from ‘Code Syntax Block’

 *  Resolved [Jan Reilink](https://wordpress.org/support/users/janr/)
 * (@janr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/easy-migration-path-to-this-plugin-from-code-syntax-block/)
 * Is there an easy migration path from mkaz’s [Code Syntax Block ](https://wordpress.org/plugins/code-syntax-block/)
   plugin to yours? Code blocks are broken since I disabled ‘Code Syntax Block’ 
   and need to be converted. I don’t want to edit hundreds of posts manually with
   possibly even more code blocks.. 🙂
 * What I have now is, for example
 *     ```
       <!-- wp:code -->
       <pre class="wp-block-code"><code lang="powershell" class="language-powershell">Get-SmbServerConfiguration | Select EnableSMB1Protocol</code></pre>
       <!-- /wp:code -->
       ```
   
 * And this needs to be converted into:
 *     ```
       <!-- wp:code {"language":"powershell"} -->
       <pre class="wp-block-code"><code>Get-SmbServerConfiguration | Select EnableSMB1Protocol</code></pre>
       <!-- /wp:code -->
       ```
   
 * BTW: I tried to use John Godley’s [Search Regex](https://wordpress.org/plugins/search-regex/)
   plugin, but that broke more than it fixed… A kind of working regexp is:
 * `s/<!-- wp:code -->\n<pre class="wp-block-code"><code lang="\(.*\)" class="language-.*"
   >/<!-- wp:code {"language":"\1"} -->\r<pre class="wp-block-code"><code>/`
 * But I like a more fail-safe migration path 🙂 I’ll update this support question
   if I find a solution in the meantime.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Jan Reilink](https://wordpress.org/support/users/janr/)
 * (@janr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/easy-migration-path-to-this-plugin-from-code-syntax-block/#post-13643434)
 * For anyone facing the same issue: I used MariaDB’s [REGEXP_REPLACE](https://mariadb.com/kb/en/regexp_replace/)
   function (MySQL has it [too](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-replace)).
 *     ```
       UPDATE test_posts SET post_content = REGEXP_REPLACE( post_content, '<!-- wp:code -->\n<pre class="wp-block-code"><code lang="(.*)" class="language-.*">', '<!-- wp:code {"language":"\\1"} -->\n<pre class="wp-block-code"><code>');
       ```
   
 * After this, I had to perform some smaller changes, as not all language names 
   are the same:
 *     ```
       UPDATE test_posts SET post_content = REGEXP_REPLACE( post_content, '<!-- wp:code {"language":"csharp"} -->', '<!-- wp:code {"language":"cs"} -->');
       UPDATE test_posts SET post_content = REGEXP_REPLACE( post_content, '<!-- wp:code {"language":"visual-basic"} -->', '<!-- wp:code {"language":"vbnet"} -->');
       UPDATE test_posts SET post_content = REGEXP_REPLACE( post_content, '<!-- wp:code {"language":"none"} -->', '<!-- wp:code {"language":"plaintext"} -->');
       ```
   
 * **PS**:
    Gutenberg does not recognize the language when using an alias, e.g if
   I have `<!-- wp:code {"language":"vb"} -->`, then editing a post shows **Auto-
   detect** instead of **VB.NET**
    -  This reply was modified 5 years, 6 months ago by [Jan Reilink](https://wordpress.org/support/users/janr/).
    -  This reply was modified 5 years, 6 months ago by [Jan Reilink](https://wordpress.org/support/users/janr/).
      Reason: had to remove backtics for code blocks

Viewing 1 replies (of 1 total)

The topic ‘Easy migration path to this plugin from ‘Code Syntax Block’’ is closed
to new replies.

 * ![](https://ps.w.org/syntax-highlighting-code-block/assets/icon.svg?rev=3406002)
 * [Syntax-highlighting Code Block (with Server-side Rendering)](https://wordpress.org/plugins/syntax-highlighting-code-block/)
 * [Support Threads](https://wordpress.org/support/plugin/syntax-highlighting-code-block/)
 * [Active Topics](https://wordpress.org/support/plugin/syntax-highlighting-code-block/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/syntax-highlighting-code-block/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/syntax-highlighting-code-block/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Jan Reilink](https://wordpress.org/support/users/janr/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/easy-migration-path-to-this-plugin-from-code-syntax-block/#post-13643434)
 * Status: resolved