我正在使用 prism.js作为我网站的语法荧光笔,但我不希望呈现某些项目,例如运算符和标点符号。
现在,prism.js 的手册指出:
If you want to prevent any elements from being automatically highlighted, you can use the attribute data-manual on the element you used for prism and use the API. Example:
<script src="prism.js" data-manual></script>
但仅此而已。没有进一步的例子。 API 的链接只显示了一些 JavaScript 函数,但在 data-manual
上没有进一步的内容。 . Als 如果我谷歌 site:prismjs.com "data-manual"
, 没有有用的事件出现。
谁能帮我看看这个幻觉是怎么来的data-manual
-需要使用属性吗?
最佳答案
我想,here是一个很好的例子。这归功于 Gregory Schier。
HTML:
<script src="prism.js" data-manual></script>
<pre>
<code id="some-code" class="language-javascript">
// This is some random code
var foo = "bar";
</code>
</pre>
JavaScript:
var block = document.getElementById('some-code');
Prism.highlightElement(block);
关于javascript - 如何在 prism.js 中使用数据手册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40522262/