Prism.js is a useful syntax highlighter that is good for displaying code samples on web pages.

I have installed the Prism module, and I have followed all of the instructions in the module's README.txt file. When publishing an article node with the following HTML, the resulting web page does not include the syntax highlighting provided by prism.js.

What is the correct way to use prism syntax highlighting in Drupal?

    a { color: #7BC673; } 
    p a { color: #22272A; } 
    p a:hover { color: #7BC673; } 
  • What Drupal version? Are you using FULL HTML format? – No Sssweat Dec 22 '18 at 7:40

I've followed following steps and getting that prism works fine, you can verify your steps as below:

  1. Install Prism and Libraries module (Libraries module is required by prism).
  2. Download prism.js and prism.css from here, then put both files in 'sites/all/libraries'. So, The library path should be like as follows:
    See screenshot:
    enter image description here
  3. Check or Enable 'Prism (syntax highlight)' check box from Full HTML Text format configuration page (admin/config/content/formats/full_html) then click on the Save Configuration button to save changes.
  4. Create a node/content with and put your css code in a field whose Text Format is Full HTML.
    enter image description here

    Output/Result (though it includes <br> but it can be removed by configure text format):
    enter image description here
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.