prismjs 基本使用

潼关路边的一只野鬼發表於2024-07-21

官網

https://prismjs.com/index.html

下載

https://prismjs.com/download.html

注意儲存位址列地址,下次訪問可以恢復所選的內容

選擇配色方案

image

選擇語言

image

選擇外掛

image

如何使用

<link rel="stylesheet" type="text/css" href="../libs/prismjs/prism.css" />

			<!-- 行內程式碼 -->
            <code class="language-css">p { color: red }</code>
			<!-- 行號與高亮行 -->
            <pre class="line-numbers" data-line="2,5-15">
			<!-- 設定語言 -->
<code class="language-java">
package com.laolang.graver.util;

import lombok.experimental.UtilityClass;

@UtilityClass
public class CharUtil {
    public static final char zero_char = '\0';
    public static final char brace_left_char = '{';
    public static final String brace_left_literal = "{";
    public static final char brace_right_char = '}';
    public static final String brace_right_literal = "}";
    public static final char parentheses_left_char = '(';
    public static final String parentheses_left_literal = "(";
    public static final char parentheses_right_char = ')';
    public static final String parentheses_right_literal = ")";
    public static final char semi = ';';
    public static final String semi_literal = ";";


    public static boolean isLowerLetter(char ch) {
        return cn.hutool.core.util.CharUtil.isLetterLower(ch);
    }

    public static boolean isUpperLetter(char ch) {
        return cn.hutool.core.util.CharUtil.isLetterUpper(ch);
    }

    public static boolean isDigit(char ch) {
        return Character.isDigit(ch);
    }

    public static boolean isWordChar(char ch) {
        return isLowerLetter(ch) || isUpperLetter(ch) || isDigit(ch) || '_' == ch;
    }

    public static boolean isWhitespace(char ch) {
        return Character.isWhitespace(ch);
    }
}
</code>
            </pre>


        <script>
            window.Prism = window.Prism || {};
            window.Prism.manual = false;
        </script>
		<script src="../libs/prismjs/prism.js"></script>

效果

image