How to format div as pre-blocks?

I am trying to display some HTML files with code samples surrounded by codeblock tags. Is there a CSS style that can render code blocks as if they were pre tags? (respect newlines, respect spaces, etc.)

+10
source share
2 answers

Like this

 div { white-space: pre; } 
+27
source

If you want to become pretty trendy , think of libraries like Pygments or highlight.js that will do full syntax coloring in addition to beautifully printing your code.

Snippets will be implemented in server-side Python; highlight.js works on the browser side.

OR: use a browser-based “code editor” such as Ace , which will then format / colorize the code ... and just use the read-only control.

0
source

Source: https://habr.com/ru/post/909766/


All Articles