Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64833 - in trunk/tools/boostbook: test/more/tests/syntax-highlight xsl
From: daniel_james_at_[hidden]
Date: 2010-08-15 12:50:00


Author: danieljames
Date: 2010-08-15 12:49:58 EDT (Sun, 15 Aug 2010)
New Revision: 64833
URL: http://svn.boost.org/trac/boost/changeset/64833

Log:
Fix some comment issues in the boostbook syntax highlighter.
Added:
   trunk/tools/boostbook/test/more/tests/syntax-highlight/
   trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.gold (contents, props changed)
   trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.xml (contents, props changed)
Text files modified:
   trunk/tools/boostbook/xsl/source-highlight.xsl | 43 ++++++++++++++++++++++++++++-----------
   1 files changed, 31 insertions(+), 12 deletions(-)

Added: trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.gold
==============================================================================
--- (empty file)
+++ trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.gold 2010-08-15 12:49:58 EDT (Sun, 15 Aug 2010)
@@ -0,0 +1,26 @@
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<section id="header.example_hpp"><title>Header &lt;<ulink url="../../example.hpp">example.hpp</ulink>&gt;</title><para>
+ Fake reference documentation, so that the syntax highlighter will kick in.
+ </para><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
+
+<link linkend="foo">foo</link></synopsis>
+
+
+ <refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="foo"><refmeta><refentrytitle>Macro foo</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>foo</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
+
+</phrase>foo</synopsis></refsynopsisdiv><refsect1><title>Description</title>
+ <programlisting><phrase role="comment">/* C style comment */</phrase></programlisting>
+ <programlisting><phrase role="comment">/* Broken C style comment</phrase></programlisting>
+ <programlisting>
+<phrase role="comment">/* Multi-line
+ *comment
+ */</phrase></programlisting>
+ <programlisting><phrase role="comment">/*/ Tricky comment */</phrase></programlisting>
+ <programlisting><phrase role="comment">/**/</phrase></programlisting>
+ <programlisting><phrase role="comment">/***/</phrase></programlisting>
+ <programlisting><phrase role="comment">// Single line comment</phrase></programlisting>
+ <programlisting><phrase role="comment">// Single line comment</phrase>
+</programlisting>
+ </refsect1></refentry>
+
+</section>
\ No newline at end of file

Added: trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.xml
==============================================================================
--- (empty file)
+++ trunk/tools/boostbook/test/more/tests/syntax-highlight/comments.xml 2010-08-15 12:49:58 EDT (Sun, 15 Aug 2010)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<header name="example.hpp">
+ <para>
+ Fake reference documentation, so that the syntax highlighter will kick in.
+ </para>
+
+ <macro name="foo">
+ <description>
+ <programlisting>/* C style comment */</programlisting>
+ <programlisting>/* Broken C style comment</programlisting>
+ <programlisting>
+/* Multi-line
+ *comment
+ */</programlisting>
+ <programlisting>/*/ Tricky comment */</programlisting>
+ <programlisting>/**/</programlisting>
+ <programlisting>/***/</programlisting>
+ <programlisting>// Single line comment</programlisting>
+ <programlisting>// Single line comment
+</programlisting>
+ </description>
+ </macro>
+
+</header>

Modified: trunk/tools/boostbook/xsl/source-highlight.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/source-highlight.xsl (original)
+++ trunk/tools/boostbook/xsl/source-highlight.xsl 2010-08-15 12:49:58 EDT (Sun, 15 Aug 2010)
@@ -363,20 +363,39 @@
         </xsl:call-template>
       </xsl:when>
       <xsl:when test="substring($text, 1, 2) = '//'">
- <xsl:call-template name="highlight-comment">
- <xsl:with-param name="text" select="substring-before($text, '&#xA;')"/>
- </xsl:call-template>
- <xsl:call-template name="highlight-text-impl-root">
- <xsl:with-param name="text" select="concat('&#xA;', substring-after($text, '&#xA;'))"/>
- </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="contains($text, '&#xA;')">
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="substring-before($text, '&#xA;')"/>
+ </xsl:call-template>
+ <xsl:call-template name="highlight-text-impl-root">
+ <xsl:with-param name="text" select="concat('&#xA;', substring-after($text, '&#xA;'))"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
       </xsl:when>
       <xsl:when test="substring($text, 1, 2) = '/*'">
- <xsl:call-template name="highlight-comment">
- <xsl:with-param name="text" select="concat(substring-before($text, '*/'), '*/')"/>
- </xsl:call-template>
- <xsl:call-template name="highlight-text-impl-root">
- <xsl:with-param name="text" select="substring-after($text, '*/')"/>
- </xsl:call-template>
+ <xsl:variable name="after-start" select="substring($text, 3)" />
+ <xsl:choose>
+ <xsl:when test="contains($after-start, '*/')">
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="concat('/*', substring-before($after-start, '*/'), '*/')"/>
+ </xsl:call-template>
+ <xsl:call-template name="highlight-text-impl-root">
+ <xsl:with-param name="text" select="substring-after($after-start, '*/')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
       </xsl:when>
       <xsl:when test="contains('&#xA;&#xD;', substring($text, 1, 1))">
         <xsl:value-of select="substring($text, 1, 1)"/>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk