Index: jrst2/src/java/org/codelutin/jrst/JRSTReader.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.9 jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.10 --- jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.9 Wed Apr 18 16:12:58 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTReader.java Thu Apr 19 12:40:50 2007 @@ -23,9 +23,9 @@ * Created: 27 oct. 06 00:15:34 * * @author poussin - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Last update: $Date: 2007/04/18 16:12:58 $ + * Last update: $Date: 2007/04/19 12:40:50 $ * by : $Author: sletellier $ */ @@ -515,6 +515,12 @@ if (itemEquals(JRSTLexer.BLANK_LINE, item)) { // go to the next element lexer.remove(); + } else if (itemEquals(ADMONITION, item)) { + lexer.remove(); + Element list = composeAdmonition(lexer, item); + parent.add(list); + + } else if (itemEquals(PARAGRAPH, item)) { lexer.remove(); Element para = parent.addElement(PARAGRAPH); @@ -556,12 +562,6 @@ } else if (itemEquals(FIELD_LIST, item)) { Element list = composeFieldList(lexer); parent.add(list); - } else if (itemEquals(ADMONITION, item)) { - lexer.remove(); - Element list = composeAdmonition(lexer, item); - parent.add(list); - - } else { if (ERROR_MISSING_ITEM) { throw new DocumentException("Unknow item type: " + item.getName()); @@ -591,8 +591,13 @@ String admonitionClass="admonition_"+title; admonitionClass=admonitionClass.toLowerCase().replaceAll("\\p{Punct}",""); admonitionClass=admonitionClass.replace(' ', '-'); + admonitionClass=admonitionClass.replace('\n', '-'); result.addAttribute("class", admonitionClass); - result.addElement("title").setText(title.trim()); + Element eTitle= result.addElement("title"); + title=title.trim(); + JRSTReader reader = new JRSTReader(); // Le titre doit etre parsé + Document doc = reader.read(new StringReader(title)); + eTitle.appendContent(doc.getRootElement()); } else{ @@ -600,7 +605,7 @@ } JRSTReader reader = new JRSTReader(); String text = item.getText(); - Document doc = reader.read(new StringReader(text)); + Document doc = reader.read(new StringReader(text)); // Ainsi que le txt result.appendContent(doc.getRootElement()); return result; } Index: jrst2/src/java/org/codelutin/jrst/JRSTLexer.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.10 jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.11 --- jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.10 Wed Apr 18 16:12:58 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTLexer.java Thu Apr 19 12:40:50 2007 @@ -23,9 +23,9 @@ * Created: 28 oct. 06 00:44:20 * * @author poussin - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * - * Last update: $Date: 2007/04/18 16:12:58 $ + * Last update: $Date: 2007/04/19 12:40:50 $ * by : $Author: sletellier $ */ @@ -321,28 +321,7 @@ private Element peekAdmonition() throws IOException { beginPeek(); - /*.. Tip:: Roles based on "raw" should clearly indicate their origin, so - they are not mistaken for reStructuredText markup. Using a "raw-" - prefix for role names is recommended.*/ - - /*.. WARNING:: - - The "raw" role is a stop-gap measure allowing the author to bypass - reStructuredText's markup. It is a "power-user" feature that - should not be overused or abused. The use of "raw" ties documents - to specific output formats and makes them less portable. - - If you often need to use "raw"-derived interpreted text roles or - the "raw" directive, that is a sign either of overuse/abuse or that - functionality may be missing from reStructuredText. Please - describe your situation in a message to the Docutils-users_ mailing - list. - - .. _Docutils-users: ../../user/mailing-lists.html#docutils-user*/ - - Element result = null; -// in.skipBlankLines(); - + Element result = null; String line = in.readLine(); if (line != null) { String lineTest = line.toLowerCase(); @@ -353,54 +332,61 @@ matcher = Pattern.compile(ADMONITION).matcher(lineTest); matcher.find(); result = DocumentHelper.createElement("admonition").addAttribute("level", String.valueOf(0)); - if (matcher.group().equals("admonition")){ + int level; + if (matcher.group().equals("admonition")){ admonition=true; result.addAttribute("type", "admonition"); String title=line.substring(matcher.end()+2,line.length()); + String tmp=in.readLine(); + if (!tmp.matches("\\s*")){ + title += " "+tmp; + level = level(title); + title += "\n"+joinBlock(readBlock(level)); + } result.addAttribute("title", title); - - - } - else{ - result.addAttribute("type",matcher.group()); } + else + result.addAttribute("type",matcher.group()); matcher = Pattern.compile(ADMONITION).matcher(lineTest); matcher.find(); - String firstLine=""; line=line.trim(); + String firstLine=""; if (!admonition && matcher.end()+2 < line.length()) - firstLine=line.substring(matcher.end()+2,line.length()); + firstLine =line.substring(matcher.end()+2,line.length()); in.skipBlankLines(); line = in.readLine(); - int level = level(line); + level = level(line); if (level>0){ String txt = firstLine.trim() + "\n" + line.trim() + "\n"; - String [] lines = in.readWhile("(^ {"+level+"}.*)|(\\s*)"); - while (lines.length > 0) { - for (String l : lines) { - l=l.trim(); - if (l.matches("\\s*")){ - txt += l + "\n"; - } - else{ - txt += l + "\n"; - } - } - lines = in.readWhile("(^ {"+level+"}.*)|(\\s*)"); - } - + txt += "\n" + readBlockWithBlankLine(level); result.setText(txt); } else result.setText(firstLine); } } - + /*if (result!=null) + System.out.println(result.asXML());*/ endPeek(); return result; - - } - + } + public String readBlockWithBlankLine(int level) throws IOException{ + String txt=""; + String [] lines = in.readWhile("(^ {"+level+"}.*)|(\\s*)"); + while (lines.length > 0) { + for (String l : lines) { + l=l.trim(); + if (l.matches("\\s*")){ + txt += l + "\n"; + } + else{ + txt += l + "\n"; + } + } + lines = in.readWhile("(^ {"+level+"}.*)|(\\s*)"); + } + return txt; + } /** * Lit les premieres ligne non vide et les retourne, rien n'est modifier par rapport * aux positions dans le fichier. Util pour afficher a l'utilisateur les lignes