Title: From syntax highlight
Last modified: December 14, 2023

---

# From syntax highlight

 *  [Loran A. Rendel](https://wordpress.org/support/users/loranrendel/)
 * (@loranrendel)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/from-syntax-highlight/)
 * The contact form can contain html code.
   I suggest to add this code into ContactForm7:
 *     ```wp-block-code
       add_action(
           'admin_enqueue_scripts',
           function (string $hook): void {
               if ($hook === 'toplevel_page_wpcf7' && isset($_GET['post'])) {
                   $type = 'text/html';
                   $settings = wp_enqueue_code_editor(
                       [
                           'type' => $type,
                           'htmlhint' => ['space-tab-mixed-disabled' => 'space'],
                           'codemirror' => ['indentWithTabs' => false]
                       ]
                   );
                   if ($settings !== false) {
                       wp_add_inline_script(
                           'code-editor',
                           sprintf(
                               <<<'EOF'
                               jQuery(function () {
                                 const codemirror = wp.codeEditor.initialize('wpcf7-form', %s).codemirror
                                 wpcf7.taggen.insert = content => {
                                   let cursor = codemirror.getCursor()
                                   codemirror.replaceRange(content, cursor)
                                   cursor = codemirror.getCursor()
                                   codemirror.focus()
                                   codemirror.setCursor(cursor)
                                 }
                               })
                               EOF,
                               wp_json_encode($settings)
                           )
                       );
                   }
               }
           }
       );
       ```
   
 * This will activate CodeMirror code editor integrated in WordPress and highlight
   HTML code if it is used in a Contact Form.

The topic ‘From syntax highlight’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)

 * 0 replies
 * 1 participant
 * Last reply from: [Loran A. Rendel](https://wordpress.org/support/users/loranrendel/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/from-syntax-highlight/)
 * Status: not a support question