Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 057d964
Showing
48 changed files
with
11,287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/target | ||
/bin | ||
/work | ||
.settings | ||
.classpath | ||
.project | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
JHighlight is Copyright (C) 2000-2006 | ||
* Omnicore Software, Hans Kratz & Dennis Strein GbR, | ||
* Geert Bevin <gbevin[remove] at uwyn dot com> | ||
* Arnout Engelen <arnouten[remove] at bzzt dot net> | ||
|
||
It is distributed under the terms of either: | ||
- the common development and distribution license (CDDL), v1.0; or | ||
- the GNU Lesser General Public License, v2.1 or later |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RIFE, | ||
|
||
Copyright 2001-2006 Geert Bevin <gbevin[remove] at uwyn dot com>, | ||
|
||
Distributed under the GNU Lesser General Public License v2.1. | ||
|
||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
|
||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
Distributed under the GNU General Public License v2 or later. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
JHighlight | ||
================== | ||
|
||
## Overview | ||
|
||
JHighlight is an embeddable pure Java syntax highlighting library that supports Java, HTML, XHTML, XML and LZX languages and outputs to XHTML. | ||
It also supports RIFE templates tags and highlights them clearly so that you can easily identify the difference between your RIFE markup and the actual marked up source. | ||
|
||
This project is forked from https://jhighlight.dev.java.net/ to fix several bugs. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.codelibs</groupId> | ||
<artifactId>jhighlight</artifactId> | ||
<version>1.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>JHighlight</name> | ||
<description>JHighlight is an embeddable pure Java syntax highlighting library | ||
that supports Java, HTML, XHTML, XML and LZX languages and outputs to XHTML. | ||
It also supports RIFE templates tags and highlights them clearly | ||
so that you can easily identify the difference between your RIFE markup | ||
and the actual marked up source.</description> | ||
<inceptionYear>2011</inceptionYear> | ||
<url>https://github.com/codelibs/jhighlight</url> | ||
<licenses> | ||
<license> | ||
<name>CDDL, v1.0</name> | ||
<url>http://www.opensource.org/licenses/cddl1.php</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
<license> | ||
<name>LGPL, v2.1 or later</name> | ||
<url>http://www.opensource.org/licenses/lgpl-license.php</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<scm> | ||
<connection>scm:git:git@github.com:codelibs/jhighlight.git</connection> | ||
<developerConnection>scm:git:git@github.com:codelibs/jhighlight.git</developerConnection> | ||
<url>git@github.com:codelibs/jhighlight.git</url> | ||
</scm> | ||
<parent> | ||
<groupId>org.sonatype.oss</groupId> | ||
<artifactId>oss-parent</artifactId> | ||
<version>7</version> | ||
</parent> | ||
<properties> | ||
<elasticsearch.version>1.2.1</elasticsearch.version> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.11</version> | ||
<configuration> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.1.2</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
/* | ||
* Copyright 2004-2006 Geert Bevin <gbevin[remove] at uwyn dot com> | ||
* Distributed under the terms of either: | ||
* - the common development and distribution license (CDDL), v1.0; or | ||
* - the GNU Lesser General Public License, v2.1 or later | ||
* $Id: JHighlight.java 3108 2006-03-13 18:03:00Z gbevin $ | ||
*/ | ||
package com.uwyn.jhighlight; | ||
|
||
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; | ||
import com.uwyn.jhighlight.tools.FileUtils; | ||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Provides console access to the source code syntax highlighting for Java, | ||
* HTML, XHTML, XML and LZX files. The rendering will be done in HTML. | ||
* <p>The following file extensions will be processed: <code>.java</code>, | ||
* <code>.html</code>, <code>.htm</code>, <code>.xhtml</code>, | ||
* <code>.xml</code> and <code>.lzx</code>. | ||
* <p>Execute the highlighting with the following syntax: | ||
* <pre>java com.uwyn.jhighlight.JHighlight [--verbose] [--fragment] [-d destdir] [-e encoding] file|dir ...</pre> | ||
* <table border="0"> | ||
* <tr> | ||
* <td><code>--verbose</code></td> | ||
* <td>Output messages about what the parser is doing.</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>--fragment</code></td> | ||
* <td>Output fragments instead of complete documents.</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>-d</code></td> | ||
* <td>Specify the destination directory</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>-e</code></td> | ||
* <td>Specify the encoding of the files</td> | ||
* </tr> | ||
* </table> | ||
* <p><a href="https://rife.dev.java.net">RIFE</a> template tags are also | ||
* supported and will be clearly highlighted. | ||
* | ||
* @author Geert Bevin (gbevin[remove] at uwyn dot com) | ||
* @version $Revision: 3108 $ | ||
* @since 1.0 | ||
*/ | ||
public class JHighlight | ||
{ | ||
public static void main(String[] arguments) throws Throwable | ||
{ | ||
String destdir_name = null; | ||
boolean verbose = false; | ||
String encoding = null; | ||
boolean fragment = false; | ||
ArrayList names = new ArrayList(); | ||
|
||
boolean valid_arguments = true; | ||
if (arguments.length < 1) | ||
{ | ||
valid_arguments = false; | ||
} | ||
else | ||
{ | ||
boolean next_is_destdir = false; | ||
boolean next_is_encoding = false; | ||
String argument; | ||
for (int i = 0; i < arguments.length; i++) | ||
{ | ||
argument = arguments[i]; | ||
if (next_is_destdir) | ||
{ | ||
destdir_name = argument; | ||
next_is_destdir = false; | ||
continue; | ||
} | ||
|
||
if (next_is_encoding) | ||
{ | ||
encoding = argument; | ||
next_is_encoding = false; | ||
continue; | ||
} | ||
|
||
if (argument.equals("-d")) | ||
{ | ||
next_is_destdir = true; | ||
continue; | ||
} | ||
|
||
if (argument.equals("-e")) | ||
{ | ||
next_is_encoding = true; | ||
continue; | ||
} | ||
|
||
if (argument.equals("--verbose")) | ||
{ | ||
verbose = true; | ||
continue; | ||
} | ||
|
||
if (argument.equals("--fragment")) | ||
{ | ||
fragment = true; | ||
continue; | ||
} | ||
|
||
names.add(argument); | ||
} | ||
} | ||
|
||
if (0 == names.size()) | ||
{ | ||
valid_arguments = false; | ||
} | ||
|
||
if (!valid_arguments) | ||
{ | ||
System.err.println("Usage : java " + JHighlight.class.getName() + " [--verbose] [--fragment] [-d destdir] [-e encoding] file|dir ..."); | ||
System.err.println("Generates highlighted XHTML files from all Java and XML source files"); | ||
System.err.println("in the specified directories."); | ||
System.err.println(" --verbose Output messages about what the parser is doing"); | ||
System.err.println(" --fragment Output fragments instead of complete documents"); | ||
System.err.println(" -d Specify the destination directory"); | ||
System.err.println(" -e Specify the encoding of the files"); | ||
System.exit(1); | ||
} | ||
|
||
File destdir = null; | ||
if (destdir_name != null) | ||
{ | ||
destdir = new File(destdir_name); | ||
if (!destdir.exists()) | ||
{ | ||
throw new IOException("The destination directory '" + destdir_name + "' doesn't exist."); | ||
} | ||
if (!destdir.canWrite()) | ||
{ | ||
throw new IOException("The destination directory '" + destdir_name + "' is not writable."); | ||
} | ||
if (!destdir.isDirectory()) | ||
{ | ||
throw new IOException("The destination directory '" + destdir_name + "' is not a directory."); | ||
} | ||
} | ||
|
||
Iterator names_it = names.iterator(); | ||
String name; | ||
while (names_it.hasNext()) | ||
{ | ||
name = (String)names_it.next(); | ||
|
||
File location = new File(name); | ||
if (!location.exists()) | ||
{ | ||
throw new IOException("The source location '" + name + "' doesn't exist."); | ||
} | ||
if (!location.canRead()) | ||
{ | ||
throw new IOException("The source location '" + name + "' is not readable."); | ||
} | ||
|
||
if (!location.isDirectory()) | ||
{ | ||
File out = null; | ||
if (null == destdir) | ||
{ | ||
out = new File(location.getAbsolutePath() + ".html"); | ||
} | ||
else | ||
{ | ||
out = new File(destdir, location.getName() + ".html"); | ||
} | ||
|
||
highlightFile(location.getName(), location, out, encoding, fragment, verbose); | ||
} | ||
else | ||
{ | ||
Set supported_types = XhtmlRendererFactory.getSupportedTypes(); | ||
Pattern[] included = new Pattern[supported_types.size()]; | ||
Pattern[] excluded = new Pattern[supported_types.size()+5]; | ||
excluded[0] = Pattern.compile(".*SCCS.*"); | ||
excluded[0] = Pattern.compile(".*svn.*"); | ||
excluded[0] = Pattern.compile(".*CVS.*"); | ||
excluded[0] = Pattern.compile(".*jetty.*"); | ||
excluded[0] = Pattern.compile(".*tomcat.*"); | ||
|
||
Iterator types_it = supported_types.iterator(); | ||
String type; | ||
int counter = 0; | ||
while (types_it.hasNext()) | ||
{ | ||
type = (String)types_it.next(); | ||
included[counter] = Pattern.compile(".*\\."+type+"$"); | ||
excluded[counter+5] = Pattern.compile(".*\\."+type+"\\.html\\.*"); | ||
|
||
counter++; | ||
} | ||
|
||
ArrayList file_names = FileUtils.getFileList(location, included, excluded); | ||
|
||
Iterator file_names_it = file_names.iterator(); | ||
String file_name; | ||
while (file_names_it.hasNext()) | ||
{ | ||
file_name = (String)file_names_it.next(); | ||
|
||
File in = new File(location.getAbsolutePath() + File.separator + file_name); | ||
File out = null; | ||
if (null == destdir) | ||
{ | ||
out = new File(location.getAbsolutePath() + File.separator + file_name + ".html"); | ||
} | ||
else | ||
{ | ||
out = new File(destdir, location.getName() + File.separator + file_name + ".html"); | ||
} | ||
|
||
highlightFile(location.getName() + File.separator + file_name, in, out, encoding, fragment, verbose); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void highlightFile(String name, File in, File out, String encoding, boolean fragment, boolean verbose) | ||
throws IOException | ||
{ | ||
out.getParentFile().mkdirs(); | ||
|
||
if (verbose) | ||
{ | ||
System.out.print(name + " ... "); | ||
} | ||
|
||
XhtmlRendererFactory.getRenderer(FileUtils.getExtension(name)) | ||
.highlight(name, | ||
in.toURL().openStream(), | ||
new FileOutputStream(out), | ||
encoding, | ||
fragment); | ||
|
||
if (verbose) | ||
{ | ||
System.out.println("done."); | ||
} | ||
} | ||
} |
Oops, something went wrong.