Add syntax highlighting to a code snippet in knowledge articles using the HTML editor.

Before you begin

Open the knowledge article in which you want to use the HTML editor.

Role required: knowledge

About this task

You can also use the HTML editor when creating or editing a knowledge article using the Knowledge Management application in the ServiceNow AI Platform interface or in Agent Workspace. To create or edit a knowledge article in the ServiceNow AI Platform interface, see Create a knowledge article or Edit a knowledge article. To create or edit a knowledge article in Agent Workspace, see Create a knowledge article in Agent Workspace or Edit a knowledge article in Agent Workspace.

Procedure

  1. In the Article body section, place the cursor where you want to insert the code snippet.
  2. Click the insert/edit code sample icon (Insert/Edit code sample icon) on the HTML toolbar.
  3. In the Insert/Edit code sample dialog box, select a markup or programming language from the Language list.
  4. In the text box after the Language list, enter your code.
    Alternatively, you can copy the code from an external source and paste it.
  5. Click Ok.
  6. (Optional) Edit the code by clicking the code snippet, and then clicking the insert/edit code sample icon (Insert/Edit code sample icon).