0

eg python code

import  os

def main:
    print("Hello, Stackers")

[To be shown as this image in webpage][1]

Is there any template that does the styling for itself?

Note: I know how to use pre and code tags also checked Wordpress, So anything other than that. Thankyou for answers.

  • If you use the '' opening and closing HTML tags, you can insert Javascript code on one of your webpages between those two tags. You can set one of the ' – Mark Fernandes Dec 18 '20 at 10:13
  • thankyou for your answer learnt something new. – Priyansh Bordia Dec 22 '20 at 11:08

1 Answers1

1

You can do this like you said without syntax highlighting using <code>, <pre> or <samp>, see this SO answer for the explanation of them. However, if you want some fancy colors, you have to use a js library. Some nice ones I've found:

highlight.js

Prism.js

SHJS

Rainbow

Note: all of these are not live - means edits of the code would break the highlighting. As example for an editor CodeMirror is a good solution.

I hope I could help you. Have a nice day :)

Luca
  • 174
  • 1
  • 8