Index: jrst2/src/java/org/codelutin/jrst/ReStructuredText.java diff -u jrst2/src/java/org/codelutin/jrst/ReStructuredText.java:1.10 jrst2/src/java/org/codelutin/jrst/ReStructuredText.java:1.11 --- jrst2/src/java/org/codelutin/jrst/ReStructuredText.java:1.10 Tue May 22 13:09:33 2007 +++ jrst2/src/java/org/codelutin/jrst/ReStructuredText.java Tue May 22 14:01:15 2007 @@ -23,9 +23,9 @@ * Created: 27 oct. 06 11:10:30 * * @author poussin - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * - * Last update: $Date: 2007/05/22 13:09:33 $ + * Last update: $Date: 2007/05/22 14:01:15 $ * by : $Author: sletellier $ */ @@ -183,7 +183,7 @@ public static final Pattern REGEX_STRONG = Pattern.compile("\\*\\*(.+?)\\*\\*"); public static final Pattern REGEX_LITERAL = Pattern.compile("``(.+?)``"); public static final Pattern REGEX_REFERENCE = Pattern.compile("(http://[-/%#&\\._\\w]+)([^-/%#&_\\w]+)"); - public static final Pattern REGEX_INLINE_REFERENCE = Pattern.compile("`(.+) ?<(http://[-/%#&\\._\\w]+)>`_"); + public static final Pattern REGEX_INLINE_REFERENCE = Pattern.compile("`(.+) ?[(<)<](http://[-/%#&\\._\\w]+)[(>)>]`_"); public static final Pattern REGEX_EMAIL = Pattern.compile("(^|[^_\\w])([-\\._\\w]+@[-\\._\\w]+)([^-\\._\\w]|$)"); public static final Pattern REGEX_FOOTNOTE_REFERENCE = Pattern.compile("\\[(#|[0-9]|\\*)\\w*\\]_"); //"\\[([0-9]+?|#)\\]"); Index: jrst2/src/java/org/codelutin/jrst/JRSTReader.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.26 jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.27 --- jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.26 Tue May 22 13:09:33 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTReader.java Tue May 22 14:01:15 2007 @@ -23,9 +23,9 @@ * Created: 27 oct. 06 00:15:34 * * @author poussin - * @version $Revision: 1.26 $ + * @version $Revision: 1.27 $ * - * Last update: $Date: 2007/05/22 13:09:33 $ + * Last update: $Date: 2007/05/22 14:01:15 $ * by : $Author: sletellier $ */ @@ -300,16 +300,16 @@ static protected Map defaultDirectives = null; protected Map directives = new HashMap(); - private boolean sectnum = false; - private int idMax = 0; - private int symbolMax = 0; - private int symbolMaxRef = 0; - private LinkedList lblFootnotes = new LinkedList(); - private LinkedList lblFootnotesRef = new LinkedList(); - private LinkedList eFootnotes = new LinkedList(); - private LinkedList eTarget = new LinkedList(); - private LinkedList eTargetAnonymous = new LinkedList(); - private LinkedList eTitle = new LinkedList(); + private static boolean sectnum = false; + private static int idMax = 0; + private static int symbolMax = 0; + private static int symbolMaxRef = 0; + private static LinkedList lblFootnotes = new LinkedList(); + private static LinkedList lblFootnotesRef = new LinkedList(); + private static LinkedList eFootnotes = new LinkedList(); + private static LinkedList eTarget = new LinkedList(); + private static LinkedList eTargetAnonymous = new LinkedList(); + private static LinkedList eTitle = new LinkedList(); static { defaultDirectives = new HashMap(); @@ -355,7 +355,7 @@ public void addDirectives(String name, JRSTDirective directive) { directives.put(name, directive); } - + /** * On commence par decouper tout le document en Element, puis on construit * l'article a partir de ces elements. @@ -364,8 +364,7 @@ * @throws IOException * @throws DocumentException */ - public Document read(Reader reader, int idMax) throws Exception { - this.idMax=idMax; + public Document read(Reader reader) throws Exception { JRSTLexer lexer = new JRSTLexer(reader); try { Element root = composeDocument(lexer); @@ -545,8 +544,8 @@ lexer.remove(); Element title = result.addElement(TITLE); String txt = item.getText(); - result.addAttribute("id", txt.replaceAll("\\W"," ").toLowerCase().trim().replaceAll(" ", "-")); - result.addAttribute("name", txt.toLowerCase().replaceAll("\\W", " ").trim()); + result.addAttribute("id", txt.replaceAll("[(\\W+)_]"," ").toLowerCase().trim().replaceAll("\\s+", "-")); + result.addAttribute("name", txt.toLowerCase().replaceAll("[(\\W+)_&&[^\\:]]+", " ").trim()); copyLevel(item, title); title.addAttribute("inline", "true").setText(txt.trim()); } @@ -560,8 +559,8 @@ lexer.remove(); Element subtitle = result.addElement(SUBTITLE); String txt = item.getText(); - subtitle.addAttribute("id", txt.replaceAll("\\W"," ").toLowerCase().trim().replaceAll(" ", "-")); - subtitle.addAttribute("name",txt.toLowerCase().replaceAll("\\W", " ").trim()); + subtitle.addAttribute("id", txt.replaceAll("[(\\W+)_]"," ").toLowerCase().trim().replaceAll("\\s+", "-")); + subtitle.addAttribute("name",txt.toLowerCase().replaceAll("[(\\W+)_]", " ").trim()); copyLevel(item, subtitle);DocumentHelper.createElement("footnotes"); subtitle.addAttribute("inline", "true").setText(txt.trim()); } @@ -808,7 +807,7 @@ URL url = fileIn.toURL(); Reader in = new InputStreamReader(url.openStream()); JRSTReader jrst = new JRSTReader(); - Document doc = jrst.read(in,idMax); + Document doc = jrst.read(in); result = doc.getRootElement(); } @@ -936,7 +935,7 @@ JRSTReader reader = new JRSTReader(); String text = footnote.getText(); - Document doc = reader.read(new StringReader(text),idMax); + Document doc = reader.read(new StringReader(text)); result[cnt].appendContent(doc.getRootElement()); @@ -1010,7 +1009,7 @@ result.addElement(SUBTITLE).addAttribute("inline", "true").setText(item.attributeValue(SUBTITLE)); JRSTReader reader = new JRSTReader(); String text = item.getText(); - Document doc = reader.read(new StringReader(text), idMax); + Document doc = reader.read(new StringReader(text)); result.appendContent(doc.getRootElement()); return result; @@ -1083,7 +1082,7 @@ result=DocumentHelper.createElement(BLOCK_QUOTE); JRSTReader reader = new JRSTReader(); String text = item.getText(); - Document doc = reader.read(new StringReader(text),idMax); + Document doc = reader.read(new StringReader(text)); result.appendContent(doc.getRootElement()); String sAttribution = item.attributeValue(ATTRIBUTION); if (sAttribution != null){ @@ -1114,7 +1113,7 @@ result=DocumentHelper.createElement(item.attributeValue("type").toLowerCase()); JRSTReader reader = new JRSTReader(); String text = item.getText(); - Document doc = reader.read(new StringReader(text),idMax); + Document doc = reader.read(new StringReader(text)); result.appendContent(doc.getRootElement()); return result; } @@ -1242,7 +1241,7 @@ } // parse entry text in table JRSTReader reader = new JRSTReader(); - Document doc = reader.read(new StringReader(text),idMax); + Document doc = reader.read(new StringReader(text)); entry.appendContent(doc.getRootElement()); } } Index: jrst2/src/java/org/codelutin/jrst/JRST.java diff -u jrst2/src/java/org/codelutin/jrst/JRST.java:1.7 jrst2/src/java/org/codelutin/jrst/JRST.java:1.8 --- jrst2/src/java/org/codelutin/jrst/JRST.java:1.7 Tue May 22 13:09:33 2007 +++ jrst2/src/java/org/codelutin/jrst/JRST.java Tue May 22 14:01:15 2007 @@ -23,9 +23,9 @@ * Created: 3 nov. 06 20:56:00 * * @author poussin - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * - * Last update: $Date: 2007/05/22 13:09:33 $ + * Last update: $Date: 2007/05/22 14:01:15 $ * by : $Author: sletellier $ */ @@ -150,7 +150,7 @@ URL url = fileIn.toURL(); Reader in = new InputStreamReader(url.openStream()); JRSTReader jrst = new JRSTReader(); - Document doc = jrst.read(in,0); + Document doc = jrst.read(in); // apply xsl on rst xml document JRSTGenerator gen = new JRSTGenerator();