Index: jrst2/src/test/org/codelutin/jrst/Compare.java diff -u jrst2/src/test/org/codelutin/jrst/Compare.java:1.1 jrst2/src/test/org/codelutin/jrst/Compare.java:1.2 --- jrst2/src/test/org/codelutin/jrst/Compare.java:1.1 Fri May 4 16:23:28 2007 +++ jrst2/src/test/org/codelutin/jrst/Compare.java Wed May 9 08:36:16 2007 @@ -5,30 +5,21 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; -import java.io.StringReader; +import java.io.StringWriter; import java.net.URL; -import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import javax.swing.JFrame; - import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; - - import org.codelutin.jrst.JRSTReader; import org.dom4j.Document; +import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; - -import org.dom4j.Element; - - - +import org.dom4j.io.XMLWriter; +import sdoc.*; public class Compare { - private static final String PATH="/home/letellier/PROJET/jrst2/"; + private static final String PATH="/home/letellier/PROJET/jrst2/"; // a redefinir manuelement static public void main(String [] args) throws Exception { File source = null; if (args.length>0){ @@ -39,18 +30,14 @@ else System.err.println("Argument source manquant"); } - private static void parser(File source) throws Exception { URL url = source.toURL(); - Reader in = new InputStreamReader(url.openStream()); + Reader in = new InputStreamReader(url.openStream()); JRSTReader jrst = new JRSTReader(); - Document docRst = jrst.read(in); + Document docRst = jrst.read(in); // JRST String cmd = "rst2xml "+PATH+source.getPath()+" "+PATH+"src/test/org/codelutin/jrst/comparePython.xml"; - System.out.println(cmd); Runtime.getRuntime().exec("rm "+PATH+"src/test/org/codelutin/jrst/comparePython.xml"); - final Process p =Runtime.getRuntime().exec(cmd); - //Runtime.getRuntime().exec(new String[] { "rst2xml", PATH+source.getPath(), PATH+"src/test/org/codelutin/jrst/comparePython.xml" }); - + final Process p =Runtime.getRuntime().exec(cmd); // Python Thread t = new Thread() { public void run() { try { @@ -58,7 +45,7 @@ String line = ""; try { while((line = reader.readLine()) != null) { - System.err.println(line); + System.err.println(line); // Pour rediriger la sortie des érreurs } } finally { reader.close(); @@ -69,105 +56,50 @@ } }; t.start(); - while(t.isAlive()); + while(t.isAlive()); // On attend que le processus ce termine t.stop(); p.destroy(); - File xml = new File("src/test/org/codelutin/jrst/comparePython.xml"); - SAXReader sr= new SAXReader(); Document docPython = sr.read(xml); - - - - compare(docRst, docPython); - } - private static void compare(Document docRst, Document docPython) throws IOException { - - JTextArea jrst = new JTextArea(); JTextArea python = new JTextArea(); - jrst.setText(convert(docRst.asXML())); - python.setText(convert(docPython.asXML())); - - - JScrollPane droit = new JScrollPane(jrst); - JScrollPane gauche = new JScrollPane(python); + SyntaxSupport support = SyntaxSupport.getInstance(); + support.addSupport(SyntaxSupport.XML_LEXER, jrst); // Coloration + support.addSupport(SyntaxSupport.XML_LEXER, python); + jrst.getDocument().putProperty(SyntaxDocument.tabSizeAttribute, new Integer(2)); + python.getDocument().putProperty(SyntaxDocument.tabSizeAttribute,new Integer(2)); + JScrollPane spJrst = new JScrollPane(jrst); + JScrollPane spPython = new JScrollPane(python); + // Ajout de gutter : la numérotation des lignes + spJrst.setRowHeaderView(new Gutter(jrst , spJrst)); + spPython.setRowHeaderView(new Gutter(python , spPython)); + jrst.setText(indent(docRst)); // On indente + python.setText(indent(docPython)); + JScrollPane droit = new JScrollPane(spJrst); + JScrollPane gauche = new JScrollPane(spPython); JFrame comparateur = new JFrame(); JSplitPane separateur = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true, gauche,droit); separateur.setResizeWeight(0.5); separateur.setOneTouchExpandable(true); separateur.setContinuousLayout(true); comparateur.add(separateur); - comparateur.setSize(1280, 900); comparateur.setVisible(true); comparateur.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - + comparateur.setTitle("Comparateur"); } - private static String convert(String xml) throws IOException { - - - - - String txt=""; - txt+="\n"+xml.replaceAll("><", ">\n<"); - - StringReader sr = new StringReader(txt); - BufferedReader bf= new BufferedReader(sr); - Pattern ligneFinit = Pattern.compile("(^<.+())|(^<\\?)|(^<\\!)"); - Pattern ligneOuvrante = Pattern.compile("^<.+>$"); - Pattern ligneFermante = Pattern.compile("^$"); - String line = bf.readLine(); - String txtFin=""; - int level = 0; - String sLevel = ""; - boolean ouvrante=false; - int cnt=0; - while (line!=null){ - cnt++; - sLevel=""; - for (int i = 0;i + + +Auto-symbol footnotes are also +possible, like this: * and § # ** †† .123456789101112 \ No newline at end of file Index: jrst2/src/test/org/codelutin/jrst/footnoteTest2.rst diff -u /dev/null jrst2/src/test/org/codelutin/jrst/footnoteTest2.rst:1.3 --- /dev/null Wed May 9 08:36:21 2007 +++ jrst2/src/test/org/codelutin/jrst/footnoteTest2.rst Wed May 9 08:36:16 2007 @@ -0,0 +1,17 @@ +Auto-symbol footnotes are also +possible, like this: [*]_ and [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [1]_ aaaa_. + +.. _aaaa: index.html +.. [1] 1 +.. [*] 1 +.. [*] 2 +.. [*] 3 +.. [*] 4 +.. [*] 5 +.. [*] 6 +.. [*] 7 +.. [*] 8 +.. [*] 9 +.. [*] 10 +.. [*] 11 +.. [*] 12 Index: jrst2/src/test/org/codelutin/jrst/sdoc-0.5.0-beta.jar