mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-09 15:03:57 +00:00
Fix some comment issues in the boostbook syntax highlighter.
[SVN r64833]
This commit is contained in:
parent
b828baab1d
commit
8ab66ba51e
26
test/more/tests/syntax-highlight/comments.gold
Normal file
26
test/more/tests/syntax-highlight/comments.gold
Normal 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 <<ulink url="../../example.hpp">example.hpp</ulink>></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: <<link linkend="header.example_hpp">example.hpp</link>>
|
||||
|
||||
</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>
|
24
test/more/tests/syntax-highlight/comments.xml
Normal file
24
test/more/tests/syntax-highlight/comments.xml
Normal 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>
|
@ -363,6 +363,8 @@
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="substring($text, 1, 2) = '//'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($text, '
')">
|
||||
<xsl:call-template name="highlight-comment">
|
||||
<xsl:with-param name="text" select="substring-before($text, '
')"/>
|
||||
</xsl:call-template>
|
||||
@ -370,14 +372,31 @@
|
||||
<xsl:with-param name="text" select="concat('
', substring-after($text, '
'))"/>
|
||||
</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('

', substring($text, 1, 1))">
|
||||
<xsl:value-of select="substring($text, 1, 1)"/>
|
||||
<xsl:call-template name="highlight-text-impl-leading-whitespace">
|
||||
|
Loading…
x
Reference in New Issue
Block a user