how to create a block of display c ++ / java code in HTML / CSS?

0

I have a JAVA code, I would like to publish it on a website. How do I do that? I'm using CSS sheets but they "spoil" the spaces between the keys and do not show the JAVA code in high light, how do I fix this "eating spaces" problem and the problem of adding Hylight syntax in the JAVA Blocks? this in view on a website.

    
asked by anonymous 25.04.2017 / 17:13

1 answer

1

I recommend using highlight.js . It works in over 174 languages and 77 styles.

You can download it and to use only add in the HEAD of the page

<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

Then I will only place code to highlight the tags like this:

<pre><code class="html">...</code></pre>

It detects automatic also without needing to mark the language.

    
26.04.2017 / 12:03