How to realize the function of displaying the code of blog articles


I"m going to assign a value to innerHTML, but I find it particularly troublesome. If there is too much code, I need to write a lot of code to the right of the equal sign

there is still a problem with line wrapping

is there a master who has done this function? give me some advice on how to achieve this function

Sep.26,2021

you can simply use the

  tag directly, and you can retain the code format 

.

if you want to be upscale, you can use a code highlighting plug-in highlightjs

if you need code highlighting.

source code output, just use the pre tag. For example,

  


you should first get a code editor so that you can export the code in dom format, and then render dom

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35b9f-34383.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35b9f-34383.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?