Author: sjur Date: Fri Jan 18 09:54:19 2013 New Revision: 1435063 URL: http://svn.apache.org/viewvc?rev=1435063&view=rev Log: A number of changes: * Added support for definition list constructs (<code>;Term:definition</code>). * Fixed numerous spacing bugs: extra or missing spaces after inline elements. * Improved support for inline formatting and breaks, especially in tables. * Fixed processing of no-link constructs: <code>[[text]</code> should be rendered as <code>[text]</code>, earlier it was rendered as <code>[[text]</code>.
The plugin should now support all relevant <a href="http://www.jspwiki.org/wiki/TextFormattingRules">jspwiki markup</a>. As part of the changes, I also added whitespace to the grammar and the xsl, to make them more readable. I also added comments to the xsl. Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/grammars/wiki.grm forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/stylesheets/wiki2xdoc.xsl forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/status.xml Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/grammars/wiki.grm URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/grammars/wiki.grm?rev=1435063&r1=1435062&r2=1435063&view=diff ============================================================================== --- forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/grammars/wiki.grm (original) +++ forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/grammars/wiki.grm Fri Jan 18 09:54:19 2013 @@ -33,19 +33,30 @@ %token source "\{\{\{ (\}{0,2}[^\}])* \}\}\}"; +%token text "([^\ \t\n\r\[\{\}\|\*\\\-_!#';:] + | _[^_\n\r] + | \{[^\{\n\r] + | \}[^\}\n\r] + | '[^'\n\r] + | \[\[ + | \\[^\\\n\r] + | \-{1,3}[^\-\n\r]?) + ([^ \n\r\[\{\}\|\\\-_':] + | _[^_\n\r] + | \{[^\{\n\r] + | \}[^\}\n\r] + | '[^'\n\r] + | \[\[ + | \\[^\\\n\r] + | \-{1,3}[^\-\n\r]? + | \|[^\|\ \t])*"; + %token anchor "\[( [^\[\|\]]* \| )? # [^\[\|\]]* \]"; %token link "\[( [^\[\|\]]* \| )? [^\[\|\]]* \]"; -%token text "([^\ \t\n\r\[\{\}\|\*\\\-_!#'] | _[^_\n\r] | \{[^\{\n\r] | \}[^\}\n\r] | '[^'\n\r] - | \[\[ | \\[^\\\n\r] | \-{1,3}[^\-\n\r]?) - ([^ \n\r\[\{\}\|\\\-_'] | _[^_\n\r] | \{[^\{\n\r] | \}[^\}\n\r] | '[^'\n\r] - | \[\[ | \\[^\\\n\r] | \-{1,3}[^\-\n\r]? | \|[^\|\ \t])*"; - -%right softbreak "\r(\n?) | \n"; - -%right break "\\\\"; - +%right break "\\\\"; +%right softbreak "\r(\n?) | \n"; %right hardbreak "(\r(\n?) | \n) ([\ \t]* (\r(\n?) | \n))+"; %token bulleted1item "\*"; @@ -56,6 +67,9 @@ %token numbered2item "##"; %token numbered3item "###"; +%right deftermstart "\;"; +%token deftermdefstart "\:"; + %ignore "[\ \t]+"; %start document; @@ -143,6 +157,7 @@ paragraphs paragraph : bulletedlist1 | numberedlist1 + | deflist | textsequence | line | source %prec softbreak @@ -240,24 +255,45 @@ tablecolumns ; tablecolumn - : tablecolumnitem textblock + : tablecolumnitem limitedtextsequence ; -textsequence - : textsequence textblock softbreak - | textsequence textblock +limitedtextsequence + : textblock break limitedtextsequence + | textblock limitedtextsequence + | textblock + ; + +textsequence + : textblock textsequence softbreak + | textblock textsequence | textblock softbreak | textblock - | textsequence textblock break - | textblock break ; textblock : link | anchor - | strongblock - | emblock - | text + | strongblock + | emblock + | text + | codeblock + | deftermdefstart + | break + ; + +termtextsequence + : termtextblock break termtextsequence + | termtextblock termtextsequence + | termtextblock + ; + +termtextblock + : link + | anchor + | strongblock + | emblock + | text | codeblock ; @@ -273,8 +309,22 @@ codeblock : codeopenitem text codecloseitem ; -/* -deflistblock - : defliststart text deflistnext +deflist + : defentry deflist %prec PLUS + | defentry + ; + +defentry + : deflistterm deflistdef + ; + +deflistterm + : deftermstart termtextsequence + | deftermstart + ; + +deflistdef + : deftermdefstart textsequence + | deftermdefstart softbreak + | deftermdefstart ; -*/ Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/stylesheets/wiki2xdoc.xsl URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/stylesheets/wiki2xdoc.xsl?rev=1435063&r1=1435062&r2=1435063&view=diff ============================================================================== --- forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/stylesheets/wiki2xdoc.xsl (original) +++ forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/resources/chaperon/stylesheets/wiki2xdoc.xsl Fri Jan 18 09:54:19 2013 @@ -20,12 +20,13 @@ xmlns:st="http://chaperon.sourceforge.net/schema/syntaxtree/2.0" exclude-result-prefixes="st"> <xsl:output indent="yes" - method="html" + method="xml" doctype-public="-//APACHE//DTD Documentation V1.1//EN" doctype-system="document-v11.dtd" cdata-section-elements="source"/> <xsl:param name="name" select="''"/> <xsl:param name="spaceless-filenames" select="''"/> + <xsl:template name="splitString"> <xsl:param name="restOfString"/> <xsl:variable name="uppercase">(ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable> @@ -62,6 +63,45 @@ </xsl:otherwise> </xsl:choose> </xsl:template> + + <!-- Only add a space if the following char is not a punctuation mark: --> + <xsl:template name="addSpace"> + <xsl:choose> + <xsl:when test="starts-with(./following::*[text()],'.') or + starts-with(./following::*[text()],',') or + starts-with(./following::*[text()],'!') or + starts-with(./following::*[text()],'?') or + starts-with(./following::*[text()],';') or + starts-with(./following::*[text()],':') or + starts-with(./following::*[text()],'"') or + ./following::*[1]/st:deftermdefstart"> + <xsl:text></xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="cleanNoLink"> + <xsl:param name="String"/> + <xsl:choose> + <xsl:when test="contains($String,'[[')"> + <xsl:variable name="StringBefore" select="substring-before($String,'[[')"/> + <xsl:variable name="StringAfter" select="substring-after($String,'[[')"/> + + <xsl:value-of select="concat($StringBefore, '[')"/> + <xsl:call-template name="cleanNoLink"> + <xsl:with-param name="String" select="$StringAfter"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$String"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <!-- Top level match: --> <xsl:template match="st:output"> <document> <header> @@ -90,6 +130,8 @@ </body> </document> </xsl:template> + + <!-- Sections: --> <xsl:template match="st:section"> <section> <title><xsl:value-of select="st:title/st:textsequence"/></title> @@ -108,19 +150,24 @@ <xsl:apply-templates select="st:paragraphs/st:paragraph/*" mode="paragraph"/> </section> </xsl:template> + <xsl:template match="st:source" mode="paragraph"> <source> <xsl:value-of select="substring(.,4,string-length(.)-6)"/> </source> </xsl:template> + <xsl:template match="st:textsequence" mode="paragraph"> <p> <xsl:apply-templates select="st:textblock/*|st:break"/> </p> </xsl:template> + <xsl:template match="st:line" mode="paragraph"> <hr/> </xsl:template> + + <!-- Tables: --> <xsl:template match="st:table" mode="paragraph"> <table> <xsl:apply-templates select="st:tablehead|st:tablerows/st:tablecolumns"/> @@ -141,18 +188,44 @@ <xsl:apply-templates select="st:tablecolumn"/> </tr> </xsl:template> + <xsl:template match="st:tablecolumn"> <td> - <xsl:apply-templates select="st:textblock/*"/> + <xsl:apply-templates select="st:limitedtextsequence/st:textblock/* + | st:limitedtextsequence/st:break"/> </td> </xsl:template> + + <!-- Textual content: --> <xsl:template match="st:text"> + <xsl:choose> + <xsl:when test="contains(.,'[[')"> + <xsl:call-template name="cleanNoLink"> + <xsl:with-param name="String" select="."/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="."/> + </xsl:otherwise> + </xsl:choose> + <xsl:call-template name="addSpace"/> + </xsl:template> + + <xsl:template match="st:deftermdefstart[not(ancestor::st:deflist)]" > <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:template> + + <xsl:template match="st:subsubtitleitem[parent::st:textblock]" > + <xsl:value-of select="."/> +<xsl:text> </xsl:text> + </xsl:template> + <xsl:template match="st:break"> <br/> </xsl:template> + + <!-- Links: --> <xsl:template match="st:link"> <xsl:choose> <xsl:when test="contains(.,'|')"> @@ -171,7 +244,9 @@ </xsl:call-template> </xsl:otherwise> </xsl:choose> + <xsl:call-template name="addSpace"/> </xsl:template> + <xsl:template name="convertLink" > <xsl:param name="href0"/> <xsl:param name="text"/> @@ -181,16 +256,15 @@ </xsl:variable> <xsl:choose> <xsl:when test="string(number($href)) != 'NaN'"><link href="#{$href}"> - <xsl:value-of select="$text"/> -<!-- $href --></link> + <xsl:value-of select="$text"/><!-- $href --></link> </xsl:when> <xsl:when test="contains($href,'.png') or contains($href,'.jpg') or contains($href,'.gif')"> <img src="{$href}" alt="{$text}"/> <!-- $href --> </xsl:when> - <xsl:when test="contains($href,':') or contains($href,'.')"><link href="{$href}"> - <xsl:value-of select="$text"/> -<!-- $href --></link> + <xsl:when test="contains($href,':') or contains($href,'.')"> + <link href="{$href}"> + <xsl:value-of select="$text"/><!-- $href --></link> </xsl:when> <xsl:otherwise><link> <xsl:attribute name="href"> @@ -203,11 +277,11 @@ </xsl:otherwise> </xsl:choose> </xsl:attribute> - <xsl:value-of select="$text"/> -<!-- $href --></link> + <xsl:value-of select="$text"/><!-- $href --></link> </xsl:otherwise> </xsl:choose> </xsl:template> + <xsl:template match="st:anchor" > <p> <xsl:choose> @@ -222,26 +296,34 @@ </xsl:otherwise> </xsl:choose> </p> + + <!-- Inline formatting: --> </xsl:template> <xsl:template match="st:emblock"><em> <xsl:value-of select="st:text"/></em> -<xsl:text> </xsl:text> + <xsl:call-template name="addSpace"/> </xsl:template> <xsl:template match="st:strongblock"><strong> <xsl:value-of select="st:text"/></strong> -<xsl:text> </xsl:text> + <xsl:call-template name="addSpace"/> </xsl:template> <xsl:template match="st:codeblock"><code> <xsl:value-of select="st:text"/></code> -<xsl:text> </xsl:text> + <xsl:call-template name="addSpace"/> </xsl:template> + + <!-- Bulleted lists: --> <xsl:template match="st:bulletedlist1" mode="paragraph"> <ul> <xsl:apply-templates select="st:bulletedlistitem1"/> </ul> </xsl:template> <xsl:template match="st:bulletedlistitem1" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*|following-sibling::st:*[1][name() != 'bulletedlistitem1']"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | following-sibling::st:*[1][name() != 'bulletedlistitem1'] + | st:textsequence/st:break"/> + </li> </xsl:template> <xsl:template match="st:bulletedlist2" > <ul> @@ -249,7 +331,11 @@ </ul> </xsl:template> <xsl:template match="st:bulletedlistitem2" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*|following-sibling::st:*[1][name() != 'bulletedlistitem2']"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | following-sibling::st:*[1][name() != 'bulletedlistitem2'] + | st:textsequence/st:break"/> + </li> </xsl:template> <xsl:template match="st:bulletedlist3" > <ul> @@ -257,32 +343,75 @@ </ul> </xsl:template> <xsl:template match="st:bulletedlistitem3" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | st:textsequence/st:break"/> + </li> </xsl:template> + + <!-- Numbered lists: --> <xsl:template match="st:numberedlist1" mode="paragraph"> <ol> <xsl:apply-templates select="st:numberedlistitem1"/> </ol> </xsl:template> <xsl:template match="st:numberedlistitem1" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*|following-sibling::st:*[1][name() != 'numberedlistitem1']"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | following-sibling::st:*[1][name() != 'numberedlistitem1'] + | st:textsequence/st:break"/> + </li> </xsl:template> + <xsl:template match="st:numberedlist2" > <ol> <xsl:apply-templates select="st:numberedlistitem2"/> </ol> </xsl:template> <xsl:template match="st:numberedlistitem2" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*|following-sibling::st:*[1][name() != 'numberedlistitem2']"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | following-sibling::st:*[1][name() != 'numberedlistitem2'] + | st:textsequence/st:break"/> + </li> </xsl:template> + <xsl:template match="st:numberedlist3" > <ol> <xsl:apply-templates select="st:numberedlistitem3"/> </ol> </xsl:template> <xsl:template match="st:numberedlistitem3" > - <li><xsl:apply-templates select="st:textsequence/st:textblock/*"/></li> + <li> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | st:textsequence/st:break"/> + </li> + </xsl:template> + + <!-- Definition lists: --> + <xsl:template match="st:deflist" mode="paragraph"> + <dl> + <xsl:apply-templates select="*"/> + </dl> + </xsl:template> + <xsl:template match="st:defentry"> + <xsl:apply-templates select="./st:deflistterm"/> + <xsl:apply-templates select="./st:deflistdef"/> + </xsl:template> + <xsl:template match="st:deflistterm"> + <dt> + <xsl:apply-templates select="st:termtextsequence/st:termtextblock/* + | st:termtextsequence/st:break"/> + </dt> + </xsl:template> + <xsl:template match="st:deflistdef"> + <dd> + <xsl:apply-templates select="st:textsequence/st:textblock/* + | st:textsequence/st:break"/> + </dd> </xsl:template> + <xsl:template match="st:deflist/st:softbreak" /> + <xsl:template match="@*|*|text()|processing-instruction()" priority="-1"> <xsl:copy> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/> Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/status.xml URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/status.xml?rev=1435063&r1=1435062&r2=1435063&view=diff ============================================================================== --- forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/status.xml (original) +++ forrest/trunk/plugins/org.apache.forrest.plugin.input.wiki/status.xml Fri Jan 18 09:54:19 2013 @@ -23,6 +23,19 @@ </developers> <changes> <release version="0.2-dev" date="not-released"> + <action type="fix" context="code" dev="SNM"> + Added support for definition list constructs (<code>;Term:definition</code>). + Fixed numerous spacing bugs: extra or missing spaces after inline elements. + Improved support for inline formatting and breaks, especially in tables. + Fixed processing of no-link constructs: <code>[[text]</code> should be + rendered as <code>[text]</code>, earlier it was rendered as <code>[[text]</code>. + The plugin should now support all relevant <a + href="http://www.jspwiki.org/wiki/TextFormattingRules">jspwiki markup</a>. + </action> + <action type="fix" context="code" dev="SNM"> + Fixed locationmap resource lookup, so that it is possible to override the + wiki parsing grammar and the wiki2xdocs stylesheet in the projecct source tree. + </action> <action type="add" context="code" dev="SNM"> Added handling of localised content in wiki format, that is, filenames following the <code>filename.locale.wiki</code> format, where each <code>locale</code> variant