{"id":28535539,"url":"https://github.com/gerritcodereview/java-prettify","last_synced_at":"2025-07-06T10:33:46.120Z","repository":{"id":62066204,"uuid":"47751848","full_name":"GerritCodeReview/java-prettify","owner":"GerritCodeReview","description":"Java port of Google Prettify - (mirror of http://gerrit.googlesource.com/java-prettify)","archived":false,"fork":false,"pushed_at":"2024-03-19T14:52:38.000Z","size":1295,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T17:16:49.599Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GerritCodeReview.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-10T09:34:11.000Z","updated_at":"2024-09-13T15:38:29.000Z","dependencies_parsed_at":"2023-01-28T15:31:50.414Z","dependency_job_id":null,"html_url":"https://github.com/GerritCodeReview/java-prettify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GerritCodeReview/java-prettify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerritCodeReview%2Fjava-prettify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerritCodeReview%2Fjava-prettify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerritCodeReview%2Fjava-prettify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerritCodeReview%2Fjava-prettify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GerritCodeReview","download_url":"https://codeload.github.com/GerritCodeReview/java-prettify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerritCodeReview%2Fjava-prettify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262003966,"owners_count":23243350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-09T17:15:44.753Z","updated_at":"2025-06-26T05:04:02.491Z","avatar_url":"https://github.com/GerritCodeReview.png","language":"Java","readme":"# Java Prettify\n\n[TOC]\n\nThis library is a java port of [Google Prettify][jsprettify], the\ncurrent version ported is 4-Mar-2013. The copyright holder of the\nGoogle Prettify is Mike Samuel (mikesamuel@gmail.com). It is licensed\nunder the Apache License Version 2. This port is distributed under\nApache License Version 2.\n\n[jsprettify]: https://github.com/google/code-prettify\n\nIf you need an editor more than a highlighter, please find jsyntaxpane.\n\n## Alternatives\n\n[Java SyntaxHighlighter](https://code.google.com/p/java-syntax-highlighter/)\n\n## Requirement\n\nJava SE 6 or up\n\n## Language Supported\n\nThe comments in prettify.parser.Prettify are authoritative but the\nlexer should work on a number of languages including C and friends,\nJava, Python, Bash, SQL, HTML, XML, CSS, Javascript, Makefiles\nand Rust. It works passably on Ruby, PHP, VB, and Awk and a decent\nsubset of Perl and Ruby, but, because of commenting conventions,\ndoesn't work on Smalltalk, or CAML-like languages.\n\nLISPy languages are supported via an extension: prettify.lang.LangLisp.\n\nAnd similarly for Clojure, CSS, Go, Haskell, Lua, OCAML, SML, F#,\nMatlab, Nemerle, Protocol Buffers, Scala, SQL, TeX, LaTeX, VHDL,\nVisual Basic, WikiText, XQuery, and YAML.\n\nIf you'd like to add an extension for your favorite language,\nplease look at prettify.lang.LangLisp.\n\n## Themes\n\nDefault, Desert, Sons of Obsidian, Sunburst\n\n## Configurations\n\n* Allows you to change the first (starting) line number.\n* Allows you to turn gutter with line numbers on and off.\n* Allows you to highlight one or more lines to focus user's attention.\n\n## Example\n\nNote that this highlighter extends Swing component, so all operations\nare better be executed inside Swing dispatching thread.\n\n```java\nimport java.io.*;\nimport java.util.Arrays;\nimport java.util.logging.*;\nimport javax.swing.*;\nimport prettify.PrettifyParser;\nimport prettify.theme.ThemeDefault;\nimport syntaxhighlight.*;\n\npublic class Example {\n\n  public static void main(String[] args) {\n    SwingUtilities.invokeLater(new Runnable() {\n\n      @Override\n      public void run() {\n        // the Prettify parser\n        Parser parser = new PrettifyParser();\n\n        // initialize the highlighter and use Default theme\n        SyntaxHighlighter highlighter = new SyntaxHighlighter(parser, new ThemeDefault());\n        // set the line number count from 10 instead of 1\n        highlighter.setFirstLine(10);\n        // set to highlight line 13, 27, 28, 38, 42, 43 and 53\n        highlighter.setHighlightedLineList(Arrays.asList(13, 27, 28, 38, 42, 43, 53));\n        try {\n          highlighter.setContent(new File(\"test.html\"));\n        } catch (IOException ex) {\n          Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);\n        }\n\n        JFrame frame = new JFrame();\n        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n        frame.setContentPane(highlighter);\n        frame.setLocationByPlatform(true);\n        frame.pack();\n        frame.setVisible(true);\n      }\n    });\n  }\n}\n```\n\n## Sample Screenshot\n\n![sample screenshot](https://java-prettify.googlecode.com/svn/wiki/ThemesDemo/ThemeDesert.png)\n\n## Support \u0026 Discussion\n\n[Support \u0026 Discussion Group](https://groups.google.com/group/java-prettify)\n\n## Known Issues\n\n* Perl formatting is really crappy. Partly because Perl is hard to parse.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerritcodereview%2Fjava-prettify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerritcodereview%2Fjava-prettify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerritcodereview%2Fjava-prettify/lists"}