From 6953b37ee5a7c0566d2e11e7141768f8a4c03fa2 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Mon, 27 Apr 2020 12:56:04 +0200 Subject: [PATCH 2/3] Remove dependency on jtidy --- .../plugin/generator/GeneratorUtils.java | 55 +------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java index e9ec47fe..1393b507 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java @@ -52,7 +52,6 @@ import org.apache.maven.reporting.MavenReport; import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XMLWriter; -import org.w3c.tidy.Tidy; import static java.nio.charset.StandardCharsets.UTF_8; @@ -262,58 +261,6 @@ public final class GeneratorUtils return decoded.toString(); } - /** - * Fixes some javadoc comment to become a valid XHTML snippet. - * - * @param description Javadoc description with HTML tags, may be null. - * @return The description with valid XHTML tags, never null. - */ - public static String makeHtmlValid( String description ) - { - if ( StringUtils.isEmpty( description ) ) - { - return ""; - } - - String commentCleaned = decodeJavadocTags( description ); - - // Using jTidy to clean comment - Tidy tidy = new Tidy(); - tidy.setDocType( "loose" ); - tidy.setXHTML( true ); - tidy.setXmlOut( true ); - tidy.setInputEncoding( "UTF-8" ); - tidy.setOutputEncoding( "UTF-8" ); - tidy.setMakeClean( true ); - tidy.setNumEntities( true ); - tidy.setQuoteNbsp( false ); - tidy.setQuiet( true ); - tidy.setShowWarnings( false ); - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream( commentCleaned.length() + 256 ); - tidy.parse( new ByteArrayInputStream( commentCleaned.getBytes( UTF_8 ) ), out ); - commentCleaned = out.toString( "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - // cannot happen as every JVM must support UTF-8, see also class javadoc for java.nio.charset.Charset - } - - if ( StringUtils.isEmpty( commentCleaned ) ) - { - return ""; - } - - // strip the header/body stuff - String ls = System.getProperty( "line.separator" ); - int startPos = commentCleaned.indexOf( "" + ls ) + 6 + ls.length(); - int endPos = commentCleaned.indexOf( ls + "" ); - commentCleaned = commentCleaned.substring( startPos, endPos ); - - return commentCleaned; - } - /** * Converts a HTML fragment as extracted from a javadoc comment to a plain text string. This method tries to retain * as much of the text formatting as possible by means of the following transformations: @@ -345,7 +292,7 @@ public final class GeneratorUtils try { - parser.parse( new StringReader( makeHtmlValid( html ) ), htmlCallback, true ); + parser.parse( new StringReader( html ), htmlCallback, true ); } catch ( IOException e ) { -- 2.35.1