【问题标题】:Use code-prettify in javascript using local pretty.css?使用本地 pretty.css 在 javascript 中使用代码美化?
【发布时间】:2018-04-01 10:24:23
【问题描述】:

code-prettify 似乎想从 cdn 中获取 pretty.css,而不是使用本地副本 - 是否可以进行配置以使其使用本地版本而无需网络调用?

【问题讨论】:

    标签: javascript google-code-prettify


    【解决方案1】:

    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} 和语言处理程序

    【讨论】:

      猜你喜欢
      • 2010-09-06
      • 1970-01-01
      • 1970-01-01
      • 2012-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      相关资源
      最近更新 更多