使用本地 pretty.css 在 javascript 中使用代码美化?
Use code-prettify in javascript using local pretty.css?
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/src
中找到 prettify.{js,css}
和语言处理程序
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/src
中找到prettify.{js,css}
和语言处理程序