You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/11/03 00:18:35 UTC

[maven-doxia-converter] branch DOXIATOOLS-62 created (now 6ccb11f)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch DOXIATOOLS-62
in repository https://gitbox.apache.org/repos/asf/maven-doxia-converter.git.


      at 6ccb11f  [DOXIATOOLS-62] Enable xhtml5 parser/sink

This branch includes the following new commits:

     new 6ccb11f  [DOXIATOOLS-62] Enable xhtml5 parser/sink

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-doxia-converter] 01/01: [DOXIATOOLS-62] Enable xhtml5 parser/sink

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch DOXIATOOLS-62
in repository https://gitbox.apache.org/repos/asf/maven-doxia-converter.git

commit 6ccb11fb68e2abb97a5df320a3f8372d90a47724
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun Nov 3 00:39:23 2019 +0100

    [DOXIATOOLS-62] Enable xhtml5 parser/sink
---
 pom.xml                                            |   6 +-
 .../org/apache/maven/doxia/DefaultConverter.java   |  13 +-
 src/main/resources/META-INF/plexus/components.xml  |  14 ++
 src/site/apt/index.apt                             |   4 +-
 src/site/apt/usage.apt.vm                          |   6 +-
 .../java/org/apache/maven/doxia/ConverterTest.java |  65 +++++++++
 src/test/resources/unit/xhtml/test.xhtml5          | 154 +++++++++++++++++++++
 7 files changed, 252 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index 10cb84d..282ca2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,7 +135,11 @@ under the License.
       <artifactId>doxia-module-xhtml</artifactId>
       <version>${doxiaVersion}</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-module-xhtml5</artifactId>
+      <version>${doxiaVersion}</version>
+    </dependency>
     <!-- Misc -->
     <dependency>
       <groupId>commons-cli</groupId>
diff --git a/src/main/java/org/apache/maven/doxia/DefaultConverter.java b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
index 86ddad4..99698cf 100644
--- a/src/main/java/org/apache/maven/doxia/DefaultConverter.java
+++ b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
@@ -92,9 +92,12 @@ public class DefaultConverter
 
     private static final String XHTML_PARSER = "xhtml";
 
+    private static final String XHTML5_PARSER = "xhtml5";
+
     /** Supported input format, i.e. supported Doxia parser */
     public static final String[] SUPPORTED_FROM_FORMAT =
-        { APT_PARSER, CONFLUENCE_PARSER, DOCBOOK_PARSER, FML_PARSER, TWIKI_PARSER, XDOC_PARSER, XHTML_PARSER };
+        { APT_PARSER, CONFLUENCE_PARSER, DOCBOOK_PARSER, FML_PARSER, TWIKI_PARSER, XDOC_PARSER, XHTML_PARSER,
+                XHTML5_PARSER};
 
     private static final String APT_SINK = "apt";
 
@@ -116,10 +119,12 @@ public class DefaultConverter
 
     private static final String XHTML_SINK = "xhtml";
 
+    private static final String XHTML5_SINK = "xhtml5";
+
     /** Supported output format, i.e. supported Doxia Sink */
     public static final String[] SUPPORTED_TO_FORMAT =
         { APT_SINK, CONFLUENCE_SINK, DOCBOOK_SINK, FO_SINK, ITEXT_SINK, LATEX_SINK, RTF_SINK, TWIKI_SINK, XDOC_SINK,
-            XHTML_SINK };
+            XHTML_SINK, XHTML5_SINK };
 
     /** Flag to format the generated files, actually only for XML based sinks. */
     private boolean formatOutput;
@@ -434,7 +439,7 @@ public class DefaultConverter
 
         if ( formatOutput && ( DOCBOOK_SINK.equals( output.getFormat() ) || FO_SINK.equals( output.getFormat() )
             || ITEXT_SINK.equals( output.getFormat() ) || XDOC_SINK.equals( output.getFormat() )
-            || XHTML_SINK.equals( output.getFormat() ) ) )
+            || XHTML_SINK.equals( output.getFormat() ) || XHTML5_SINK.equals( output.getFormat() ) ) )
         {
             // format all xml files excluding docbook which is buggy
             // TODO Add doc book format
@@ -658,7 +663,7 @@ public class DefaultConverter
             throw new IllegalArgumentException( "The file '" + xmlFile.getAbsolutePath() + "' is not a file." );
         }
 
-        
+
         try ( Reader reader = ReaderFactory.newXmlReader( xmlFile ) )
         {
             XmlPullParser parser = new MXParser();
diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml
index 1d4157a..a843948 100644
--- a/src/main/resources/META-INF/plexus/components.xml
+++ b/src/main/resources/META-INF/plexus/components.xml
@@ -214,5 +214,19 @@
       <implementation>org.apache.maven.doxia.module.xhtml.XhtmlSinkFactory</implementation>
       <description>Xhtml implementation of the Sink factory.</description>
     </component>
+
+    <!-- Doxia xhtml5 -->
+    <component>
+      <role>org.apache.maven.doxia.parser.Parser</role>
+      <role-hint>xhtml5</role-hint>
+      <implementation>org.apache.maven.doxia.module.xhtml5.Xhtml5Parser</implementation>
+      <description>Parse an xhtml5 model and emit events into a Doxia Sink.</description>
+    </component>
+    <component>
+      <role>org.apache.maven.doxia.sink.SinkFactory</role>
+      <role-hint>xhtml5</role-hint>
+      <implementation>org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory</implementation>
+      <description>Xhtml5 implementation of the Sink factory.</description>
+    </component>
   </components>
 </component-set>
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index b17ec29..dd9aeae 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -33,9 +33,9 @@ Doxia Converter
 
   Currently, the supported Doxia formats are:
 
-    * input format: apt, confluence, docbook, fml, twiki, xdoc, xhtml or autodetect
+    * input format: apt, confluence, docbook, fml, twiki, xdoc, xhtml, xhtml5 or autodetect
 
-    * output format: apt, confluence, docbook, fo, itext, latex, rtf, twiki, xdoc, xhtml
+    * output format: apt, confluence, docbook, fo, itext, latex, rtf, twiki, xdoc, xhtml, xhtml5
 
     []
 
diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm
index 62ea925..a3ecaa2 100644
--- a/src/site/apt/usage.apt.vm
+++ b/src/site/apt/usage.apt.vm
@@ -58,8 +58,8 @@ Options:
  -X,--debug                          Produce execution debug output.
 
 Supported Formats:
-from: apt, confluence, docbook, fml, twiki, xdoc, xhtml or autodetect
-out: apt, docbook, fo, itext, latex, rtf, xdoc, xhtml
+from: apt, confluence, docbook, fml, twiki, xdoc, xhtml, xhtml5 or autodetect
+out: apt, docbook, fo, itext, latex, rtf, xdoc, xhtml, xhtml5
 Supported Encoding:
 UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, Shift_JIS, ISO-2022-JP,
 ISO-2022-CN, ISO-2022-KR, GB18030, EUC-JP, EUC-KR, Big5, ISO-8859-1,
@@ -113,7 +113,7 @@ catch ( ConverterException e )
 +---
  <target name="doxia-convert">
      <java
-         jar="./lib/doxia-converter-1.2-jar-with-dependencies.jar"
+         jar="./lib/doxia-converter-${project.version}-jar-with-dependencies.jar"
          dir="."
          fork="true"
          failonerror="true"
diff --git a/src/test/java/org/apache/maven/doxia/ConverterTest.java b/src/test/java/org/apache/maven/doxia/ConverterTest.java
index 08f6830..065f30a 100644
--- a/src/test/java/org/apache/maven/doxia/ConverterTest.java
+++ b/src/test/java/org/apache/maven/doxia/ConverterTest.java
@@ -422,6 +422,43 @@ public class ConverterTest
         assertTrue( new File( out ).exists() );
         assertTrue( new File( out ).length() != 0 );
     }
+    /**
+     * Input xhtml5 file / output dir
+     *
+     * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+     * @throws Exception if any
+     */
+    public void testXhtml5FileConverter()
+            throws Exception
+    {
+        String in = getBasedir() + "/src/test/resources/unit/xhtml/test.xhtml5";
+        String from = "xhtml5";
+        String out = getBasedir() + "/target/unit/file/xhtml/test.xhtml.xhtml5";
+        String to = "xhtml5";
+
+        InputFileWrapper input =
+                InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
+        OutputFileWrapper output =
+                OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+
+        converter.setFormatOutput( formatOutput );
+        converter.convert( input, output );
+        assertTrue( new File( out ).exists() );
+        assertTrue( new File( out ).length() != 0 );
+
+        in = getBasedir() + "/target/unit/file/xhtml/test.xhtml.xhtml5";
+        from = "xhtml5";
+        out = getBasedir() + "/target/unit/file/xhtml/test.xhtml5";
+        to = "xhtml5";
+
+        input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
+        output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+
+        converter.setFormatOutput( formatOutput );
+        converter.convert( input, output );
+        assertTrue( new File( out ).exists() );
+        assertTrue( new File( out ).length() != 0 );
+    }
 
     /**
      * Input apt reader / output writer
@@ -582,6 +619,34 @@ public class ConverterTest
         {
             assertTrue( true );
         }
+
+        in = getBasedir() + "/src/test/resources/unit/xhtml/test.xhtml5";
+        out = getBasedir() + "/target/unit/writer/xhtml/test.html5.xhtml5";
+        to = "xhtml5";
+
+        inFile = new File( in );
+        outFile = new File( out );
+        outFile.getParentFile().mkdirs();
+
+        try (FileWriter fw = new FileWriter( outFile ))
+        {
+            StringWriter writer = new StringWriter();
+
+            InputFileWrapper input =
+                    InputFileWrapper.valueOf( inFile.getAbsolutePath(), null, converter.getInputFormats() );
+            OutputFileWrapper output =
+                    OutputFileWrapper.valueOf( outFile.getAbsolutePath(), to, converter.getOutputFormats() );
+
+            converter.setFormatOutput( formatOutput );
+            converter.convert( input, output );
+
+            IOUtil.copy( writer.toString(), fw );
+
+            assertTrue( outFile.exists() );
+            assertTrue( outFile.length() != 0 );
+        }
+
+
     }
 
     private String autoDetectEncoding( File f )
diff --git a/src/test/resources/unit/xhtml/test.xhtml5 b/src/test/resources/unit/xhtml/test.xhtml5
new file mode 100644
index 0000000..215c59d
--- /dev/null
+++ b/src/test/resources/unit/xhtml/test.xhtml5
@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.9.1 from content/apt/maven-features.apt at 2019-11-02
+ | Rendered using Apache Maven Fluido Skin 1.8
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="generator" content="Apache Maven Doxia Site Renderer 1.9.1" />
+    <meta name="author" content="Jason van Zyl" />
+    <meta name="date" content="2005-10-12" />
+    <title>Maven &#x2013; Maven Features</title>
+    <link rel="stylesheet" href="./css/apache-maven-fluido-1.8.min.css" />
+    <link rel="stylesheet" href="./css/site.css" />
+    <link rel="stylesheet" href="./css/print.css" media="print" />
+    <script src="./js/apache-maven-fluido-1.8.min.js"></script>
+    <!-- Google Analytics -->
+    <script>
+      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+       (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+      ga('create', 'UA-140879-1', 'auto');
+      ga('send', 'pageview');
+      ga('set', 'anonymizeIp', true);
+      ga('set', 'forceSSL', true);
+    </script>
+  </head>
+  <body class="topBarDisabled">
+    <div class="container-fluid">
+      <header>
+        <div id="banner">
+          <div class="pull-left"><a href="https://www.apache.org/" id="bannerLeft"><img src="images/apache-maven-project.png"  alt="Apache Maven Site"/></a></div>
+          <div class="pull-right"><a href="./" id="bannerRight"><img src="images/maven-logo-black-on-white.png"  alt=""/></a></div>
+          <div class="clear"><hr/></div>
+        </div>
+
+        <div id="breadcrumbs">
+          <ul class="breadcrumb">
+      <li class=""><a href="https://www.apache.org/" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li>
+      <li class=""><a href="index.html" title="Maven">Maven</a><span class="divider">/</span></li>
+    <li class="active ">Maven Features <a href="https://github.com/apache/maven-site/tree/master/content/apt/maven-features.apt"><img src="./images/accessories-text-editor.png" title="Edit" /></a></li>
+        <li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2019-11-02</li>
+      <li class="pull-right"><span class="divider">|</span>
+<a href="scm.html" title="Get Sources">Get Sources</a></li>
+      <li class="pull-right"><a href="download.cgi" title="Download">Download</a></li>
+          </ul>
+        </div>
+      </header>
+      <div class="row-fluid">
+        <header id="leftColumn" class="span2">
+          <nav class="well sidebar-nav">
+  <ul class="nav nav-list">
+    <li><a href="index.html" title="Welcome"><span class="none"></span>Welcome</a></li>
+    <li><a href="https://www.apache.org/licenses/" class="externalLink" title="License"><span class="none"></span>License</a></li>
+   <li class="nav-header">About Maven</li>
+    <li><a href="what-is-maven.html" title="What is Maven?"><span class="none"></span>What is Maven?</a></li>
+    <li class="active"><a href="#"><span class="none"></span>Features</a></li>
+    <li><a href="download.html" title="Download"><span class="none"></span>Download</a></li>
+    <li><a href="users/index.html" title="Use"><span class="icon-chevron-right"></span>Use</a></li>
+    <li><a href="docs/history.html" title="Release Notes"><span class="none"></span>Release Notes</a></li>
+   <li class="nav-header">Documentation</li>
+    <li><a href="plugins/index.html" title="Maven Plugins"><span class="none"></span>Maven Plugins</a></li>
+    <li><a href="guides/index.html" title="Index (category)"><span class="none"></span>Index (category)</a></li>
+    <li><a href="users/index.html" title="User Centre"><span class="icon-chevron-right"></span>User Centre</a></li>
+    <li><a href="plugin-developers/index.html" title="Plugin Developer Centre"><span class="icon-chevron-right"></span>Plugin Developer Centre</a></li>
+    <li><a href="repository/index.html" title="Maven Central Repository"><span class="icon-chevron-right"></span>Maven Central Repository</a></li>
+    <li><a href="developers/index.html" title="Maven Developer Centre"><span class="icon-chevron-right"></span>Maven Developer Centre</a></li>
+    <li><a href="articles.html" title="Books and Resources"><span class="none"></span>Books and Resources</a></li>
+    <li><a href="security.html" title="Security"><span class="none"></span>Security</a></li>
+   <li class="nav-header">Community</li>
+    <li><a href="community.html" title="Community Overview"><span class="none"></span>Community Overview</a></li>
+    <li><a href="project-roles.html" title="Project Roles"><span class="none"></span>Project Roles</a></li>
+    <li><a href="guides/development/guide-helping.html" title="How to Contribute"><span class="none"></span>How to Contribute</a></li>
+    <li><a href="users/getting-help.html" title="Getting Help"><span class="none"></span>Getting Help</a></li>
+    <li><a href="issue-management.html" title="Issue Management"><span class="none"></span>Issue Management</a></li>
+    <li><a href="scm.html" title="Getting Maven Source"><span class="none"></span>Getting Maven Source</a></li>
+    <li><a href="team.html" title="The Maven Team"><span class="none"></span>The Maven Team</a></li>
+   <li class="nav-header">Project Documentation</li>
+    <li><a href="project-info.html" title="Project Information"><span class="icon-chevron-right"></span>Project Information</a></li>
+   <li class="nav-header">Maven Projects</li>
+    <li><a href="archetype/index.html" title="Archetype"><span class="none"></span>Archetype</a></li>
+    <li><a href="resolver/index.html" title="Artifact Resolver"><span class="none"></span>Artifact Resolver</a></li>
+    <li><a href="doxia/index.html" title="Doxia"><span class="none"></span>Doxia</a></li>
+    <li><a href="jxr/index.html" title="JXR"><span class="none"></span>JXR</a></li>
+    <li><a href="ref/current" title="Maven"><span class="none"></span>Maven</a></li>
+    <li><a href="pom/index.html" title="Parent POMs"><span class="none"></span>Parent POMs</a></li>
+    <li><a href="plugins/index.html" title="Plugins"><span class="none"></span>Plugins</a></li>
+    <li><a href="plugin-testing/index.html" title="Plugin Testing"><span class="none"></span>Plugin Testing</a></li>
+    <li><a href="plugin-tools/index.html" title="Plugin Tools"><span class="none"></span>Plugin Tools</a></li>
+    <li><a href="apache-resource-bundles/index.html" title="Resource Bundles"><span class="none"></span>Resource Bundles</a></li>
+    <li><a href="scm/index.html" title="SCM"><span class="none"></span>SCM</a></li>
+    <li><a href="shared/index.html" title="Shared Components"><span class="none"></span>Shared Components</a></li>
+    <li><a href="skins/index.html" title="Skins"><span class="none"></span>Skins</a></li>
+    <li><a href="surefire/index.html" title="Surefire"><span class="none"></span>Surefire</a></li>
+    <li><a href="wagon/index.html" title="Wagon"><span class="none"></span>Wagon</a></li>
+   <li class="nav-header">ASF</li>
+    <li><a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How Apache Works"><span class="none"></span>How Apache Works</a></li>
+    <li><a href="https://www.apache.org/foundation/" class="externalLink" title="Foundation"><span class="none"></span>Foundation</a></li>
+    <li><a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsoring Apache"><span class="none"></span>Sponsoring Apache</a></li>
+    <li><a href="https://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a></li>
+  </ul>
+          </nav>
+          <div class="well sidebar-nav">
+<form id="search-form" action="https://www.google.com/search" method="get" >
+  <input value="https://maven.apache.org" name="sitesearch" type="hidden"/>
+  <input class="search-query" name="q" id="query" type="text" />
+</form>
+<script>asyncJs( 'https://cse.google.com/brand?form=search-form' )</script>
+            <hr />
+            <div id="poweredBy">
+              <div class="clear"></div>
+    <div id="twitter">
+    <a href="https://twitter.com/ASFMavenProject" class="twitter-follow-button" data-show-count="false" data-align="left" data-size="medium" data-show-screen-name="true" data-lang="en">Follow ASFMavenProject</a>
+    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
+    </div>
+              <div class="clear"></div>
+              <div class="clear"></div>
+<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
+            </div>
+          </div>
+        </header>
+        <main id="bodyColumn"  class="span10" >
+<section>
+<h2><a name="Feature_Summary"></a>Feature Summary</h2>
+<p>The following are the key features of Maven in a nutshell:</p>
+<ul>
+<li>Simple project setup that follows best practices - get a new project or module started in seconds</li>
+<li>Consistent usage across all projects - means no ramp up time for new developers coming onto a project</li>
+<li>Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies)</li>
+<li>Able to easily work with multiple projects at the same time</li>
+<li>A <a href="/repository/">large and growing repository of libraries and metadata</a> to use out of the box, and arrangements in place with the largest Open Source projects for real-time availability of their latest releases</li>
+<li>Extensible, with the ability to easily <a href="/plugin-developers/">write plugins</a> in Java or scripting languages</li>
+<li>Instant access to new features with little or no extra configuration</li>
+<li>Ant tasks for dependency management and deployment outside of Maven</li>
+<li>Model based builds: Maven is able to build any number of projects into predefined output types such as a JAR, WAR, or distribution based on metadata about the project, without the need to do any scripting in most cases.</li>
+<li>Coherent site of project information: Using the same metadata as for the build process, Maven is able to generate a web site or PDF including any documentation you care to add, and adds to that standard reports about the state of development of the project. Examples of this information can be seen at the bottom of the left-hand navigation of this site under the &quot;Project Information&quot; and &quot;Project Reports&quot; submenus.</li>
+<li>Release management and distribution publication: Without much additional configuration, Maven will integrate with your source control system (such as Subversion or Git) and manage the release of a project based on a certain tag. It can also publish this to a distribution location for use by other projects. Maven is able to publish individual outputs such as a JAR, an archive including other dependencies and documentation, or as a source distribution.</li>
+<li>Dependency management: Maven encourages the use of a central repository of JARs and other dependencies. Maven comes with a mechanism that your project's clients can use to download any JARs required for building your project from a central JAR repository much like Perl's CPAN. This allows users of Maven to reuse JARs across projects and encourages communication between projects to ensure that backward compatibility issues are dealt with.</li></ul></section>
+        </main>
+      </div>
+    </div>
+    <hr/>
+    <footer>
+      <div class="container-fluid">
+        <div class="row-fluid">
+            <p>Copyright &#169;      2002&#x2013;2019<a href="https://www.apache.org/">The Apache Software Foundation</a>.
+.</p>
+        </div>
+      </div>
+    </footer>
+  </body>
+</html>
\ No newline at end of file