简体   繁体   中英

Use code-prettify in javascript using local pretty.css?

代码修饰似乎想从CDN中获取pretty.css,而不是使用本地副本-是否有可能进行配置以使其使用本地版本而无需网络调用?

The run_prettify.js loads from a CDN and uses query flags to figure out what to load:

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

The prettify.js script gives you more control over loading but you have to remember to load the language handlers you need and call PR.prettyPrint() on load:

<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>

You can find prettify.{js,css} and the language handlers in https://github.com/google/code-prettify/tree/master/src

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM