servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r950184 - in /servicemix/maven-plugins/docs-maven-plugin/trunk/src: main/java/org/apache/servicemix/docs/confluence/ test/java/org/apache/servicemix/docs/confluence/ test/resources/org/apache/servicemix/docs/confluence/
Date Tue, 01 Jun 2010 18:19:20 GMT
Author: gertv
Date: Tue Jun  1 18:19:19 2010
New Revision: 950184

URL: http://svn.apache.org/viewvc?rev=950184&view=rev
Log:
Adding support for hyperlinks

Added:
    servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki
      - copied, changed from r949752, servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.wiki
    servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml
      - copied, changed from r949752, servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml
Modified:
    servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
    servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
    servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml

Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java?rev=950184&r1=950183&r2=950184&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
(original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
Tue Jun  1 18:19:19 2010
@@ -144,23 +144,23 @@ public class ConfluenceConverter {
     private void writeImage(String line) {
         String file = line.trim().replaceAll("!", "");
         openElement("imageobject");
-        writeText(String.format("<imagedate fileref=\"%s\"/>", file));
+        writeRaw(String.format("<imagedata fileref=\"%s\"/>", file));
         closeElement("imageobject");
     }
 
     private void writeProgramListing(String line) throws IOException {
         String language = Macro.parse(line).getParameter("lang");
         if (language == null) {
-            writeText("<programlisting><![CDATA[");
+            writeRaw("<programlisting><![CDATA[");
         } else {
-            writeText(String.format("<programlisting language=\"%s\"><![CDATA[",
language));
+            writeRaw(String.format("<programlisting language=\"%s\"><![CDATA[",
language));
         }
 
         while ((line = reader.readLine()) != null && !line.equals("{code}")) {
-            writeText(line, "");
+            writeRaw(line, "");
         }
 
-        writeText("]]></programlisting>");
+        writeRaw("]]></programlisting>");
     }
 
     private void writePara(String line) {
@@ -176,7 +176,7 @@ public class ConfluenceConverter {
             if (!elements.peek().equals("para")) {
                 openElement("para");
             }
-            writeText(filter(line));
+            writeText(line);
         }
     }
 
@@ -187,7 +187,26 @@ public class ConfluenceConverter {
     }
 
     private String filter(String line) {
-        return line.replaceAll("[\\{]{2}", "<code>").replaceAll("[\\}]{2}", "</code>").replaceAll("&",
"&amp;");
+        String filtered = line.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">",
"&gt;");
+        while (filtered.indexOf("[") >= 0 && filtered.indexOf("]") > 0 &&
filtered.indexOf("[") < filtered.indexOf("]")) {
+            int begin = filtered.indexOf("[");
+            int end = filtered.indexOf("]");
+            String confluence = filtered.substring(begin, end  + 1);
+            String[] parts = filtered.substring(begin + 1, end).split("\\|");
+            String docbook = String.format("<ulink url=\"%s\">%s</ulink>",
+                                           parts.length == 2 ? parts[1] : parts[0], parts[0]);
+            filtered = filtered.replace(confluence, docbook);
+        }
+        filtered = filtered.replaceAll("[\\{]{2}", "<code>").replaceAll("[\\}]{2}",
"</code>");
+        return filtered;
+    }
+
+    private void writeRaw(String text) {
+        writeRaw(text, indent());        
+    }
+
+    private void writeRaw(String text, String indent) {
+        writer.printf("%s%s%n", indent, text);
     }
 
     private void writeText(String text) {

Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java?rev=950184&r1=950183&r2=950184&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
(original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
Tue Jun  1 18:19:19 2010
@@ -56,6 +56,11 @@ public class ConfluenceDocumentTest {
     }
 
     @org.junit.Test
+    public void generateLinks() throws Exception {
+        assertDocBook("links");
+    }
+
+    @org.junit.Test
     public void generateTables() throws Exception {
         assertDocBook("tables");
     }

Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml?rev=950184&r1=950183&r2=950184&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml
(original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml
Tue Jun  1 18:19:19 2010
@@ -6,7 +6,7 @@
       This section contains an image
     </para>
     <imageobject>
-      <imagedate fileref="image.png"/>
+      <imagedata fileref="image.png"/>
     </imageobject>
   </section>
 </chapter>
\ No newline at end of file

Copied: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki
(from r949752, servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.wiki)
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki?p2=servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki&p1=servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.wiki&r1=949752&r2=950184&rev=950184&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.wiki
(original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki
Tue Jun  1 18:19:19 2010
@@ -1,6 +1,11 @@
 h1. Chapter
 
 h2. Section 1
-This section contains an image
+This section contains a simple link to [http://www.google.be]
 
-!image.png!
\ No newline at end of file
+h2. Section 2
+Click [here|http://www.google.be] to follow the link with text
+
+h2. Section 3
+Links in a variable list
+- search provider :: [Google|http://www.google.be] is often used for searching the web 
\ No newline at end of file

Copied: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml
(from r949752, servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml)
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml?p2=servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml&p1=servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml&r1=949752&r2=950184&rev=950184&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml
(original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml
Tue Jun  1 18:19:19 2010
@@ -3,61 +3,27 @@
   <section>
     <title>Section 1</title>
     <para>
-      This section contains a bulleted list:
-      <itemizedlist>
-        <listitem>
-          <para>item 1</para>
-        </listitem>
-        <listitem>
-          <para><code>item 2</code></para>
-        </listitem>
-        <listitem>
-          <para>item 3</para>
-        </listitem>
-      </itemizedlist>
+      This section contains a simple link to <ulink url="http://www.google.be">http://www.google.be</ulink>
     </para>
   </section>
   <section>
     <title>Section 2</title>
     <para>
-      This section contains a numbered list:
-      <orderedlist>
-        <listitem>
-          <para>item 1</para>
-        </listitem>
-        <listitem>
-          <para><code>item 2</code></para>
-        </listitem>
-        <listitem>
-          <para>item 3</para>
-        </listitem>
-      </orderedlist>
+      Click <ulink url="http://www.google.be">here</ulink> to follow the link
with text
     </para>
   </section>
   <section>
-    <title>Variable list</title>
+    <title>Section 3</title>
     <para>
-      This section contains a variable list:
+      Links in a variable list
       <variablelist>
         <varlistentry>
-          <term>term1</term>
+          <term>search provider</term>
           <listitem>
-            <para>Definition for term1</para>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term><code>term2</code></term>
-          <listitem>
-            <para>Definition for term2 (including <code>code text</code>)</para>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term>term3</term>
-          <listitem>
-            <para>Definition for term3</para>
+            <para><ulink url="http://www.google.be">Google</ulink> is often
used for searching the web</para>
           </listitem>
         </varlistentry>
       </variablelist>
     </para>
-  </section>
+  </section>    
 </chapter>
\ No newline at end of file



Mime
View raw message