1

我正在尝试使用 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.htmlprism.js

在此处输入图像描述

我应该看看有什么建议吗?

我不习惯 html/css/js。

4

2 回答 2

2

下载 prism 时没有选择“文件高亮”插件。刚遇到同样的问题。选择它再次下载它,它对我有用。

于 2019-01-18T02:14:21.680 回答
1

正如@Norman Potts 所述,您需要添加文件高亮插件。

我用过: https ://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+cpp+json&plugins=line-highlight+line-numbers+file-highlight+keep-markup+unescaped -标记

你也只需要这个

<pre data-src="main.cpp"></pre>

不是这个

<pre><code class="language-css">p { color: red }</code></pre>
于 2020-06-28T19:52:05.757 回答