commit | 32fa081a797a97beaf77a4f2efca26c39168e72f | [log] [tgz] |
---|---|---|
author | David Ostrovsky <david@ostrovsky.org> | Fri Sep 29 10:30:37 2023 +0200 |
committer | David Ostrovsky <david@ostrovsky.org> | Fri Sep 29 10:48:28 2023 +0200 |
tree | 51a2e4f35f0d72cce88850b026bf17858bd2536e | |
parent | 8af621b7b99641eb803caa460009290a47fa3111 [diff] |
Fix BoxedPrimitiveEquality bug pattern flagged by error prone Details: https://errorprone.info/bugpattern/BoxedPrimitiveEquality Change-Id: I50c127363866ad654841e2238967a030cfb859b1
This library is a java port of Google Prettify, the current version ported is 4-Mar-2013. The copyright holder of the Google Prettify is Mike Samuel (mikesamuel@gmail.com). It is licensed under the Apache License Version 2. This port is distributed under Apache License Version 2.
If you need an editor more than a highlighter, please find jsyntaxpane.
Java SE 6 or up
The comments in prettify.parser.Prettify are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, Makefiles and Rust. It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and Ruby, but, because of commenting conventions, doesn't work on Smalltalk, or CAML-like languages.
LISPy languages are supported via an extension: prettify.lang.LangLisp.
And similarly for Clojure, CSS, Go, Haskell, Lua, OCAML, SML, F#, Matlab, Nemerle, Protocol Buffers, Scala, SQL, TeX, LaTeX, VHDL, Visual Basic, WikiText, XQuery, and YAML.
If you'd like to add an extension for your favorite language, please look at prettify.lang.LangLisp.
Default, Desert, Sons of Obsidian, Sunburst
Note that this highlighter extends Swing component, so all operations are better be executed inside Swing dispatching thread.
import java.io.*; import java.util.Arrays; import java.util.logging.*; import javax.swing.*; import prettify.PrettifyParser; import prettify.theme.ThemeDefault; import syntaxhighlight.*; public class Example { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // the Prettify parser Parser parser = new PrettifyParser(); // initialize the highlighter and use Default theme SyntaxHighlighter highlighter = new SyntaxHighlighter(parser, new ThemeDefault()); // set the line number count from 10 instead of 1 highlighter.setFirstLine(10); // set to highlight line 13, 27, 28, 38, 42, 43 and 53 highlighter.setHighlightedLineList(Arrays.asList(13, 27, 28, 38, 42, 43, 53)); try { highlighter.setContent(new File("test.html")); } catch (IOException ex) { Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(highlighter); frame.setLocationByPlatform(true); frame.pack(); frame.setVisible(true); } }); } }