prismjs 基本使用

官网

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

posted @ 2024-07-21 00:25  潼关路边的一只野鬼  阅读(57)  评论(0编辑  收藏  举报