我正在尝试在网站上显示我的代码,但我遇到了正确保留空白缩进的问题.
例如,给出以下代码段:
<html>
<body>
Here is my code:
<pre>
def some_funtion
return 'Hello, World!'
end
</pre>
<body>
</html>
Run Code Online (Sandbox Code Playgroud)
这在浏览器中显示为:
Here is my code:
def some_funtion
return 'Hello, World!'
end
Run Code Online (Sandbox Code Playgroud)
当我希望它显示为:
Here is my code:
def some_funtion
return 'Hello, World!'
end
Run Code Online (Sandbox Code Playgroud)
区别在于HTML预标记的当前缩进级别被添加到代码的缩进中.我正在使用nanoc作为静态网站生成器,我使用谷歌美化也添加语法高亮.
有人可以提供任何建议吗?