Author: echatellier Date: 2011-03-09 11:36:38 +0100 (Wed, 09 Mar 2011) New Revision: 554 Url: http://nuiton.org/repositories/revision/jrst/554 Log: Fix comment and topic parsing Modified: trunk/jrst/src/main/java/org/nuiton/jrst/JRSTLexer.java Modified: trunk/jrst/src/main/java/org/nuiton/jrst/JRSTLexer.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/JRSTLexer.java 2011-03-09 10:26:35 UTC (rev 553) +++ trunk/jrst/src/main/java/org/nuiton/jrst/JRSTLexer.java 2011-03-09 10:36:38 UTC (rev 554) @@ -718,7 +718,7 @@ Element result = null; String line = in.readLine(); if (line != null) { - if (line.matches("^\\.\\.\\s*(" + TOPIC + ")::\\s*(.*)$")) { + if (line.matches("^\\.\\.\\s+(" + TOPIC + ")::\\s*(.*)$")) { Matcher matcher = Pattern.compile(TOPIC + "::").matcher(line); matcher.find(); result = DocumentHelper.createElement(TOPIC).addAttribute( @@ -2111,7 +2111,7 @@ Element result = null; String line = in.readLine(); if (line != null) { - if (line.matches("^\\.\\.\\s*.*$")) { + if (line.matches("^\\.\\.\\s+.*$")) { result = DocumentHelper.createElement("comment"); result.addAttribute("level", "0"); result.addAttribute("xml:space", "preserve"); @@ -2119,14 +2119,16 @@ // first line is part of comment result.setText(line.substring(2).trim()); line = in.readLine(); - int level = level(line); - if (level > 0) { - String[] lines = readBlock(level); - String text = line.substring(level); - for (String l : lines) { - text += "\n" + l.substring(level); + if(line != null) { + int level = level(line); + if (level > 0) { + String[] lines = readBlock(level); + String text = line.substring(level); + for (String l : lines) { + text += "\n" + l.substring(level); + } + result.addText(text); } - result.addText(text); } } }
participants (1)
-
echatellier@users.nuiton.org