How can I ignore leading and trailing linebreaks within an html “code” block using css, javascript or jquery?

前端 未结 6 960
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 18:59

In my HTML source code, I have a code block like the following (I use showdown and highlight.js on this page):


double myNum         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-19 19:52

    That's how pre works by default: it honors line breaks and whitespace. If you don't want the newline to render, then you have to remove it. Either outright remove it from the source or comment it out if you care how the source looks.

    http://jsfiddle.net/VL8tG/

    double myNumber = (double)4;

提交回复
热议问题