我试图用Prismjs https://prismjs.com/index.html文件突出显示插件https://prismjs.com/plugins/file-highlight/来突出显示C++文件。所以我试着:
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<link href="themes/prism.css" rel="stylesheet" />
</head>
<body>
<script src="prism.js"></script>
<pre data-src="main.cpp"></pre>
<pre><code class="language-css">p { color: red }</code></pre>
</body>
</html>但它不起作用。这段CSS出现在那里,但main.cpp (与index.html和prism.js在同一文件夹中)没有出现。我得到了:

有什么建议吗?我应该看看吗?
我不习惯html/css/js。
发布于 2019-01-18 10:14:22
下载prism时,您没有选择“文件突出显示”插件。只是遇到了同样的问题。再次下载,并选择它,它对我工作。
发布于 2020-06-29 03:52:06
正如@Norman Potts所述,您需要添加文件突出显示插件。
还有,你只需要这个
<pre data-src="main.cpp"></pre>不是这个
<pre><code class="language-css">p { color: red }</code></pre>https://stackoverflow.com/questions/51947855
复制相似问题