r282 - in jrst/trunk/src/main: java/org/codelutin/jrst resources/xsl
Author: chatellier Date: 2009-02-27 08:17:59 +0000 (Fri, 27 Feb 2009) New Revision: 282 Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java jrst/trunk/src/main/resources/xsl/rst2xhtml.xsl Log: Fix comment directive and trailing spaces Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java 2009-02-23 08:48:45 UTC (rev 281) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java 2009-02-27 08:17:59 UTC (rev 282) @@ -463,9 +463,6 @@ result = peekInclude(); } if (result == null) { - result = peekComment(); - } - if (result == null) { result = peekDoctestBlock(); } if (result == null) { @@ -483,7 +480,11 @@ if (result == null) { result = peekDirectiveOrReference(); } + // comment must be read after peekDirectiveOrReference() if (result == null) { + result = peekComment(); + } + if (result == null) { result = peekTransition(); } if (result == null) { @@ -1936,11 +1937,11 @@ } else { String title = in.readLine(); if (title != null && startsWithTitleChar(title) - && line.length() == title.length()) { + && line.replaceFirst("\\s*$", "").length() == title.length()) { result = DocumentHelper.createElement(TITLE).addAttribute( "type", "simple").addAttribute("char", - title.substring(0, 1)).addText(line); + title.substring(0, 1)).addText(line.replaceFirst("\\s*$", "")); } } } @@ -2074,17 +2075,23 @@ 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"); + + // first line is part of comment + result.setText(line.substring(2).trim() + "\n"); line = in.readLine(); int level = level(line); - String[] lines = readBlock(level); - String text = line.substring(level); - for (String l : lines) - text += "\n" + l.substring(level); - result.setText(text); + if (level > 0) { + String[] lines = readBlock(level); + String text = line.substring(level); + for (String l : lines) { + text += "\n" + l.substring(level); + } + result.addText(text); + } } } Modified: jrst/trunk/src/main/resources/xsl/rst2xhtml.xsl =================================================================== --- jrst/trunk/src/main/resources/xsl/rst2xhtml.xsl 2009-02-23 08:48:45 UTC (rev 281) +++ jrst/trunk/src/main/resources/xsl/rst2xhtml.xsl 2009-02-27 08:17:59 UTC (rev 282) @@ -18,6 +18,12 @@ </html> </xsl:template> + <xsl:template match="comment"> + <xsl:comment> + <xsl:apply-templates/> + </xsl:comment> + </xsl:template> + <xsl:template match="title"> <xsl:if test="name(..)='document'"> <h1 class="mainTitle">
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org