Enable Code Syntax Highlighting in PDF Generator

Administrators can enable code syntax highlighting in PDF Generator. We use the highlight.js syntax highlighting library, version 11.4.0. Once syntax highlighting is enabled in PDF Generator, when you publish your content, code in code block elements is automatically detected and highlighted.

Note: Code syntax is not highlighted when you preview content in publishing interface or Administration interface. Code is highlighted when you actually publish content.
  1. In the top left corner, click the Main Menu and go to PDF Generator.
  2. Click a scenario and, in the left pane, click Edit Extra Params.
    Note: If you don't see the Edit Extra Params option, contact your Customer Success Manager.
  3. In the Parameters window, click New parameter and set the following fields:
    1. Set Type to Boolean.
    2. Set Name to pdfgen_highlight_code.
    3. Provide Display name.
      The Display name will be visible as an option in the publishing interface.
      Code Syntax Highlighting
    4. Leave the User settable option selected.
    5. Click Save.
    Parameter set to enable code syntax highlighting.
  4. In the CSS tab, add the following import:
    @import url("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/default.min.css");
  5. Click Save Scenario.
You can now see the Code Syntax Highlighting option in the publishing interface. Select it to ensure that your PDF Generator output highlights code added in code block elements.