使用local Pretty.css在JavaScript中使用Code-Prettify



code -prettify似乎想从cdn中获取Pretty.css,而不是使用本地副本 - 是否可以配置事物,以便它在没有网络呼叫的情况下使用本地版本?

run_prettify.js从CDN加载并使用查询标志来查找出去加载什么:

<head>
  <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
  ...
</body>

prettify.js脚本使您可以更多地控制加载,但是您必须记住加载所需的语言处理程序,并在加载上调用PR.prettyPrint()

<head>
  <script src="/path/to/prettify.js"></script>
  <link rel="stylesheet" href="/path/to/prettify.css" />
  <!-- You would also need to load the language handlers you need here. -->
</head>
<body onload="PR.prettyPrint()">
  ...
</body>

您可以在https://github.com/google/code-prettify/tree/master/master/src

中找到prettify.{js,css}和语言处理程序

最新更新