Fix some comment issues in the boostbook syntax highlighter.

[SVN r64833]
This commit is contained in:
Daniel James 2010-08-15 16:49:58 +00:00
parent b828baab1d
commit 8ab66ba51e
3 changed files with 81 additions and 12 deletions

View File

@ -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>

View File

@ -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>

View File

@ -363,6 +363,8 @@
</xsl:call-template>
</xsl:when>
<xsl:when test="substring($text, 1, 2) = '//'">
<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>
@ -370,14 +372,31 @@
<xsl:with-param name="text" select="concat('&#xA;', substring-after($text, '&#xA;'))"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="substring($text, 1, 2) = '/*'">
<xsl:otherwise>
<xsl:call-template name="highlight-comment">
<xsl:with-param name="text" select="concat(substring-before($text, '*/'), '*/')"/>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="substring($text, 1, 2) = '/*'">
<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($text, '*/')"/>
<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)"/>
<xsl:call-template name="highlight-text-impl-leading-whitespace">