简体   繁体   English

如何将长代码行包装在google-code-prettify中

[英]How to wrap long code lines in google-code-prettify

I'm using default setting of google-code-prettify. 我使用的是google-code-prettify的默认设置。 When a line is too long, it exceeds the boundary, like the following: 当一条线太长时,它将超出边界,如下所示: 在此处输入图片说明 Are they any possible solution to wrap the code line? 他们有没有可能包装代码行的解决方案?

You need to use pre-wrap . 您需要使用pre-wrap

 pre { white-space: pre-wrap; } 

You can use the CSS property word-wrap: break-word; 您可以使用CSS属性word-wrap: break-word; to enable word-wrapping. 启用自动换行功能。 Make sure that your selector has priority over Google's style, as they probably set word-wrap: nowrap; 确保您的选择器优先于Google的样式,因为他们可能设置了word-wrap: nowrap; somewhere. 某处。

An alternative is changing the overflow to auto 一种替代方法是将overflow更改为auto

pre {
  overflow: auto;
}

For anyone using linenums you need this 对于使用linenums的任何人,您都需要此

:not(pre) > code {
    white-space: pre-wrap; 
    word-wrap: break-word;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM