简体   繁体   English

忽略代码和前置标签中的空格

[英]Ignoring whitespace in code and pre tags

I am having some issues regarding whitespace in my HTML code. 我的HTML代码中有一些有关空格的问题。 This is what is currently looks like: 这是当前的样子:

        <pre>
        <code>
             -(void)respring {
               system("killall -9 SpringBoard");
             }
        </code>
        </pre> 

The indentation marks are to format my HTML a little better, make it more readable. 缩进标记可以使我的HTML格式更好,使其更具可读性。 When I save it and upload it to my server, I get this . 保存并将其上传到服务器时,我得到了这个 I have already tried using the white-space CSS property to try to fix the issue, but all it does it mess up my codes formatting. 我已经尝试使用空白CSS属性来尝试解决此问题,但是所有这些操作都弄乱了我的代码格式。 I also looked at the JavaScript solutions to this problem via Google but they don't seem to work. 我还通过Google查看了针对此问题的JavaScript解决方案,但它们似乎不起作用。 I am using highlight js for syntax highlighting if that helps. 如果有帮助,我正在使用Highlight js进行语法突出显示。

Thanks. 谢谢。

The whole point of a pre tag is to preserve the spacing that's displayed, including anything at the beginning of a line. pre标签的重点是保留显示的间距,包括行首的所有内容。 This should fix it. 这应该解决它。

        <code>-(void)respring {
  system("killall -9 SpringBoard");
}</code>

It may not look pretty in code, but on the page it'll look just fine. 它在代码中看起来可能并不漂亮,但是在页面上看起来就很好。

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

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