A
A
Alexander Koshelev2021-08-30 21:14:26
css
Alexander Koshelev, 2021-08-30 21:14:26

How to insert the source code with the necessary highlighting on the site?

Good day to all!
Can you please tell me how I can insert the code with the edge highlight (which ide offers for each language) on the site? I poked around in other people's sites who and how solves this issue and even saw how each line of code is wrapped in a div, and each element that has its own color is wrapped in a span. This method is very bad when there is a lot of code and I have no idea how much time it takes to kill it, if there are really a lot of code examples.
Can anyone suggest the correct solution to this nuance?
A banal example of the code that I want to insert into the site (the code should be easily copied by users)

public class Main {
    public static void main(String[] args) {
        Box myBox = new Box();
        myBox.height = 10.2;
        myBox.length = 15;
        myBox.width = 11.3;
        double volume = myBox.height * myBox.length * myBox.width;
        System.out.println(volume);
    }
}

612d20bc8dc06377700965.jpeg
PS the first code was inserted using the editor on this site and the Java language was selected, but as you can see it does not highlight as much as I need (second version of the code)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
metallix, 2021-08-30
@Xandr24

highlightjs.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question