Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86509 - in trunk/tools/boostbook: test/more/tests/syntax-highlight xsl
From: dnljms_at_[hidden]
Date: 2013-10-28 18:35:16


Author: danieljames
Date: 2013-10-28 18:35:16 EDT (Mon, 28 Oct 2013)
New Revision: 86509
URL: http://svn.boost.org/trac/boost/changeset/86509

Log:
Add support for language='c++'.

The implementation is a bit odd, but I was trying to match the existing
templates.

Added:
   trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.gold (contents, props changed)
   trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.xml (contents, props changed)
Text files modified:
   trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.gold | 13 +++++++++++++
   trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.xml | 25 +++++++++++++++++++++++++
   trunk/tools/boostbook/xsl/annotation.xsl | 8 ++++++++
   trunk/tools/boostbook/xsl/docbook.xsl | 8 ++++++++
   4 files changed, 54 insertions(+), 0 deletions(-)

Added: trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.gold
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.gold 2013-10-28 18:35:16 EDT (Mon, 28 Oct 2013) (r86509)
@@ -0,0 +1,13 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<book xmlns:xi="http://www.w3.org/2001/XInclude" id="test" lang="en">
+ <title>Test language attribute</title>
+ <programlisting>plain text</programlisting>
+ <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase><phrase role="special">}</phrase></programlisting>
+ <programlisting><phrase role="keyword">actions</phrase> something <phrase role="special">;</phrase></programlisting>
+
+ <para>
+ <computeroutput>plain text</computeroutput>
+ <computeroutput><phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase><phrase role="special">}</phrase></computeroutput>
+ <computeroutput><phrase role="keyword">actions</phrase> something <phrase role="special">;</phrase></computeroutput>
+ </para>
+</book>
\ No newline at end of file

Added: trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.xml
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/boostbook/test/more/tests/syntax-highlight/language-attribute.xml 2013-10-28 18:35:16 EDT (Mon, 28 Oct 2013) (r86509)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 Daniel James.
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+-->
+<!DOCTYPE boostbook PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<boostbook id="test" xmlns:xi="http://www.w3.org/2001/XInclude"
+ last-revision="$Date: 2010-10-30 15:29:27 +0100 (Sat, 30 Oct 2010) $"
+ lang="en">
+ <title>Test language attribute</title>
+ <programlisting>plain text</programlisting>
+ <programlisting language="c++">void main() {}</programlisting>
+ <programlisting language="jam">actions something ;</programlisting>
+
+ <para>
+ <code>plain text</code>
+ <code language="c++">void main() {}</code>
+ <code language="jam">actions something ;</code>
+ </para>
+</boostbook>
+

Modified: trunk/tools/boostbook/xsl/annotation.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/annotation.xsl Mon Oct 28 18:34:35 2013 (r86508)
+++ trunk/tools/boostbook/xsl/annotation.xsl 2013-10-28 18:35:16 EDT (Mon, 28 Oct 2013) (r86509)
@@ -400,6 +400,14 @@
     </computeroutput>
   </xsl:template>
 
+ <xsl:template match="code[@language='c++']" mode="annotation">
+ <computeroutput>
+ <xsl:apply-templates mode="annotation">
+ <xsl:with-param name="highlight" select="true()"/>
+ </xsl:apply-templates>
+ </computeroutput>
+ </xsl:template>
+
   <xsl:template match="bold" mode="annotation">
     <emphasis role="bold">
       <xsl:apply-templates mode="annotation"/>

Modified: trunk/tools/boostbook/xsl/docbook.xsl
==============================================================================
--- trunk/tools/boostbook/xsl/docbook.xsl Mon Oct 28 18:34:35 2013 (r86508)
+++ trunk/tools/boostbook/xsl/docbook.xsl 2013-10-28 18:35:16 EDT (Mon, 28 Oct 2013) (r86509)
@@ -398,6 +398,10 @@
     </computeroutput>
   </xsl:template>
 
+ <xsl:template match="code[@language='c++']">
+ <xsl:apply-templates select="." mode="annotation"/>
+ </xsl:template>
+
   <xsl:template match="bold">
     <emphasis role="bold">
       <xsl:apply-templates mode="annotation"/>
@@ -454,6 +458,10 @@
     </programlisting>
   </xsl:template>
 
+ <xsl:template match="programlisting[@language='c++']">
+ <xsl:apply-templates select="." mode="annotation"/>
+ </xsl:template>
+
   <!-- These DocBook elements have special meaning. Use the annotation mode -->
   <xsl:template match="classname|methodname|functionname|enumname|
                        macroname|headername|globalname">


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