prism4j
스타0
포크0
업데이트2026년 3월 18일 02:36
Prism4j best practices
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SKILL.md
readonly메뉴
Prism4j best practices
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | prism4j |
| description | Prism4j best practices |
Prism4j is a simplified Java clone of prism-js. No rendering, no themes, no hooks, no plugins. But still a language parsing. Primary aim of this library is to provide a tokenization strategy of arbitrary syntaxes for later processing.
public class Prism4jExample {
public static void main(String[] args) {
String language = "java";
String code = "public class Hello { public static void main(String[] args) { System.out.println(\"Hello world!\"); } }";
final Prism4j prism4j = new Prism4j(new DefaultGrammarLocator());
final Prism4j.Grammar grammar = prism4j.grammar("java");
StringBuilder sb = new StringBuilder();
// add prism html structure
sb.append(String.format("<pre class=\"language-%s\"><code class=\"language-%s\">\n", language, language));
if (grammar != null) {
final List<Prism4j.Node> nodes = prism4j.tokenize(code, grammar);
final AbsVisitor visitor = new AbsVisitor() {
@Override
protected void visitText(@NotNull Prism4j.Text text) {
// raw text
sb.append(text.literal());
}
@Override
protected void visitSyntax(@NotNull Prism4j.Syntax syntax) {
// type of the syntax token
final String tokenType = syntax.type();
sb.append("<span class=\"token ").append(tokenType).append("\">");
visit(syntax.children());
sb.append("</span>");
}
};
visitor.visit(nodes);
}
sb.append("\n</code></pre>");
System.out.println(sb);
}
}
Then you can paste the above HTML code into page as following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Prism4j demo</title>
<link rel="stylesheet" href="https://dev.prismjs.com/themes/prism.css"/>
</head>
<body>
paste prism html structure code here
</body>