html 突出显示JS以进行代码突出显示

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 突出显示JS以进行代码突出显示相关的知识,希望对你有一定的参考价值。

https://github.com/isagalaev/highlight.js/blob/master/src/styles/solarized-dark.css


<!DOCTYPE html>
<html>
<head>
	<title></title>
<!-- remove this style sheet if using a custom sheet like solarized css   -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
<!--  this is required in order for JS to style on load -->
<script>hljs.initHighlightingOnLoad();</script>



<style>
/*  this is for solarized dark theme 
for more styles see: https://github.com/isagalaev/highlight.js/tree/master/src/styles
*/
.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  background: #002b36;
  color: #839496;
}

.hljs-comment,
.hljs-quote {
  color: #586e75;
}

/* Solarized Green */
.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
  color: #859900;
}

/* Solarized Cyan */
.hljs-number,
.hljs-string,
.hljs-meta .hljs-meta-string,
.hljs-literal,
.hljs-doctag,
.hljs-regexp {
  color: #2aa198;
}

/* Solarized Blue */
.hljs-title,
.hljs-section,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
  color: #268bd2;
}

/* Solarized Yellow */
.hljs-attribute,
.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-class .hljs-title,
.hljs-type {
  color: #b58900;
}

/* Solarized Orange */
.hljs-symbol,
.hljs-bullet,
.hljs-subst,
.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-link {
  color: #cb4b16;
}

/* Solarized Red */
.hljs-built_in,
.hljs-deletion {
  color: #dc322f;
}

.hljs-formula {
  background: #073642;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}
</style>



</head>
<body>

<pre><code class="hljs php solarized-dark">...

require_once 'Zend/Uri/Http.php';

namespace Location\Web;

interface Factory
{
    static function _factory();
}

abstract class URI extends BaseURI implements Factory
{
    abstract function test();

    public static $st1 = 1;
    const ME = "Yo";
    var $list = NULL;
    private $var;

    /**
     * Returns a URI
     *
     * @return URI
     */
    static public function _factory($stats = array(), $uri = 'http')
    {
        echo __METHOD__;
        $uri = explode(':', $uri, 0b10);
        $schemeSpecific = isset($uri[1]) ? $uri[1] : '';
        $desc = 'Multi
line description';

        // Security check
        if (!ctype_alnum($scheme)) {
            throw new Zend_Uri_Exception('Illegal scheme');
        }

        $this->var = 0 - self::$st;
        $this->list = list(Array("1"=> 2, 2=>self::ME, 3 => \Location\Web\URI::class));

        return [
            'uri'   => $uri,
            'value' => null,
        ];
    }
}

echo URI::ME . URI::$st1;

__halt_compiler () ; datahere
datahere
datahere */
datahere


</code>

</pre>


</body>
</html>

以上是关于html 突出显示JS以进行代码突出显示的主要内容,如果未能解决你的问题,请参考以下文章

如何突出显示部分textarea html代码

如何禁用 html 或 JS 中的突出显示?

创建Chrome扩展程序,以突出显示网站上特定的预定义字词。

使用dygraph.js突出显示交互式区域

如何修改此 SQL 查询中的 XML 代码以突出显示表的特定行?

Excel以2列为基础查找和突出显示重复项