Index: jrst2/src/java/org/codelutin/jrst/JRSTReader.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.10 jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.11 --- jrst2/src/java/org/codelutin/jrst/JRSTReader.java:1.10 Thu Apr 19 12:40:50 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTReader.java Thu Apr 19 15:54:01 2007 @@ -23,9 +23,9 @@ * Created: 27 oct. 06 00:15:34 * * @author poussin - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * - * Last update: $Date: 2007/04/19 12:40:50 $ + * Last update: $Date: 2007/04/19 15:54:01 $ * by : $Author: sletellier $ */ @@ -193,7 +193,7 @@ * attribution * author (done) * authors (done) - * block_quote + * block_quote (done) * bullet_list (done) * caption * caution (done) @@ -562,7 +562,13 @@ } else if (itemEquals(FIELD_LIST, item)) { Element list = composeFieldList(lexer); parent.add(list); - } else { + } else if (itemEquals(BLOCK_QUOTE, item)) { + lexer.remove(); + Element list =composeBlockQuote(lexer, item); + parent.add(list); + } + + else { if (ERROR_MISSING_ITEM) { throw new DocumentException("Unknow item type: " + item.getName()); } else { @@ -571,8 +577,8 @@ } // Pour afficher le "PseudoXML" - /*if (item!=null) - System.out.println(item.asXML());*/ + if (item!=null) + System.out.println(item.asXML()); item = lexer.peekTitleOrBodyElement(); @@ -583,9 +589,22 @@ } + private Element composeBlockQuote(JRSTLexer lexer, Element item) throws Exception { + Element result = null; + result=DocumentHelper.createElement(BLOCK_QUOTE); + JRSTReader reader = new JRSTReader(); + String text = item.getText(); + Document doc = reader.read(new StringReader(text)); + result.appendContent(doc.getRootElement()); + Element attribution = result.addElement(ATTRIBUTION); + attribution.setText(item.attributeValue(ATTRIBUTION)); + return result; + } + + private Element composeAdmonition(JRSTLexer lexer, Element item) throws Exception { Element result = null; - if (item.attributeValue("type").equalsIgnoreCase("admonition")){ + if (item.attributeValue("type").equalsIgnoreCase(ADMONITION)){ result=DocumentHelper.createElement(ADMONITION); String title = item.attributeValue("title"); String admonitionClass="admonition_"+title; Index: jrst2/src/java/org/codelutin/jrst/JRSTLexer.java diff -u jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.11 jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.12 --- jrst2/src/java/org/codelutin/jrst/JRSTLexer.java:1.11 Thu Apr 19 12:40:50 2007 +++ jrst2/src/java/org/codelutin/jrst/JRSTLexer.java Thu Apr 19 15:54:01 2007 @@ -23,9 +23,9 @@ * Created: 28 oct. 06 00:44:20 * * @author poussin - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ * - * Last update: $Date: 2007/04/19 12:40:50 $ + * Last update: $Date: 2007/04/19 15:54:01 $ * by : $Author: sletellier $ */ @@ -37,6 +37,7 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.locks.ReadWriteLock; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -311,15 +312,56 @@ if (result == null) { result = peekBlankLine(); } - if (result == null) { + if (result == null) { + result = peekBlockQuote(); + } + if (result == null) { result = peekPara(); } + return result; } - private Element peekAdmonition() throws IOException { + private Element peekBlockQuote() throws IOException { + beginPeek(); + Element result = null; + String line = in.readLine(); + if (line != null){ + int level = level(line); + String txt=line; + boolean done=(level==0); + String blockQuote = null; + while (!done) { + line = in.readLine(); + if (line!=null){ + if (line.matches("(^ {"+level+"}.*)|(\\s*)")){ + if (line.matches("^ {"+level+"}--\\s.*")){ + done=true; + blockQuote=line; + blockQuote = blockQuote.replaceAll("--","").trim(); + } + else + txt += "\n" + line; + } + else + done=true; + } + else + done=true; + } + if (blockQuote!=null){ + result = DocumentHelper.createElement("block_quote").addAttribute("level", String.valueOf(level)); + result.addAttribute("attribution", blockQuote); + result.setText(txt.trim()); + } + } + endPeek(); + return result; + } + + private Element peekAdmonition() throws IOException { beginPeek(); Element result = null; String line = in.readLine(); @@ -376,12 +418,8 @@ while (lines.length > 0) { for (String l : lines) { l=l.trim(); - if (l.matches("\\s*")){ - txt += l + "\n"; - } - else{ - txt += l + "\n"; - } + txt += l + "\n"; + } lines = in.readWhile("(^ {"+level+"}.*)|(\\s*)"); }