Uploaded image for project: 'Maven Doxia'
  1. Maven Doxia
  2. DOXIA-460

Converting XHTML to Confluence and Numeric Lists

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.4, 1.2
    • Fix Version/s: 1.4
    • Component/s: Module - Confluence
    • Labels:
      None
    • Environment:
      All I believe. Tested on Windows and Mac OS.

      Description

      When generating XHTML from a Confluence markup containing a numeric list the following is true:

      1. FirstNumericListItem
      2. SecondNumericListItem

      is turned into an ordered list:

      <ol style="list-style-type: decimal"><li>FirstNumericListItem</li><li>SecondNumericListItem</li></ol>
      

      This seems to work fine. If you try and generate Confluence from the generated XHTML the numeric list is translated to:

      1. FirstNumericListItem
      1. SecondNumericListItem
      

      So basically you cannot round trip Confluence to XHTML and and back using numeric lists.

      Tried to attach the following test example though got an error.

      package jsftest.testwebapp;
      
      import java.io.ByteArrayOutputStream;
      import java.io.File;
      import java.io.FileOutputStream;
      import java.io.FileReader;
      import org.apache.maven.doxia.Converter;
      import org.apache.maven.doxia.DefaultConverter;
      import org.apache.maven.doxia.wrapper.InputReaderWrapper;
      import org.apache.maven.doxia.wrapper.OutputStreamWrapper;
      
      /**
       *
       */
      public class Example {
          /**
           * The input Confluence file.
           */
          private static final String INPUT_FILE = "confluence.txt";
          
          /**
           * The output XHTML file.
           */
          private static final String XHTML_FILE = "output.xhtml";
          
          /**
           * If you run this example with an input file containing a numeric list:
           * 
           * # item1
           * # item2
           * 
           * You'll notice when you parse the XHTML back to confluence it is turned
           * into:
           * 
           * 1. item1
           * 1. item2
           * 
           * This is a numeric list wiki format for some markups though it doesn't 
           * match what is supported from Confluence to XHTML.  If you try this the
           * 1. itemX are not turned into a numeric list when generating XHTML.
           */
          public static void main(String[] args) {
              // A converter
              Converter converter = new DefaultConverter();
                      
              try {
                  // Global var.
                  InputReaderWrapper input = null;
                  OutputStreamWrapper output = null;
                  FileReader reader = null;
                  ByteArrayOutputStream outputStream = null;
                  String results;
                  
                  // Read the Confluence file containing numeric lists and generate 
                  // an XHTML file.
                  reader = new FileReader(new File(INPUT_FILE));         
                  input = InputReaderWrapper.valueOf(reader, "confluence", converter.getInputFormats());
                  FileOutputStream fileOutput = new FileOutputStream(XHTML_FILE);
                  output = OutputStreamWrapper.valueOf(fileOutput, "xhtml", "UTF-8", converter.getOutputFormats());            
                  converter.convert(input, output);
                  fileOutput.close();
      
                  // Try and convert the XHTML back to Confluence.
                  reader = new FileReader(new File(XHTML_FILE));
                  input = InputReaderWrapper.valueOf(reader, "xhtml", converter.getInputFormats());
      
                  outputStream = new ByteArrayOutputStream();
                  output = OutputStreamWrapper.valueOf(outputStream, "confluence", "UTF-8", converter.getOutputFormats());
                  converter.convert(input, output);
                  results = outputStream.toString();
                  
                  System.out.println("Converted xhtml back to wiki:");
                  System.out.println(results);
      
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }    
      }
      

        Attachments

        1. Example.java
          3 kB
          Anthony Milano

          Activity

            People

            • Assignee:
              rfscholte Robert Scholte
              Reporter:
              blueshirts Anthony Milano
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: