|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53454 - in branches/quickbook-1.5: . detail doc test
From: daniel_james_at_[hidden]
Date: 2009-05-30 09:02:29
Author: danieljames
Date: 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
New Revision: 53454
URL: http://svn.boost.org/trac/boost/changeset/53454
Log:
Teletype source mode. Refs #1202.
Added:
branches/quickbook-1.5/test/code-block-teletype.gold (contents, props changed)
branches/quickbook-1.5/test/code-block-teletype.quickbook (contents, props changed)
Text files modified:
branches/quickbook-1.5/detail/actions.cpp | 8 ++++
branches/quickbook-1.5/detail/actions.hpp | 12 ++++++
branches/quickbook-1.5/doc/quickbook.qbk | 2 +
branches/quickbook-1.5/doc_info.hpp | 1
branches/quickbook-1.5/phrase.hpp | 1
branches/quickbook-1.5/syntax_highlight.hpp | 79 ++++++++++++++++++++++++++++++++++++++++
branches/quickbook-1.5/test/Jamfile.v2 | 1
7 files changed, 104 insertions(+), 0 deletions(-)
Modified: branches/quickbook-1.5/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5/detail/actions.cpp (original)
+++ branches/quickbook-1.5/detail/actions.cpp 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -320,6 +320,14 @@
{
parse(first, last, python_p);
}
+ else if (source_mode == "teletype")
+ {
+ parse(first, last, teletype_p);
+ }
+ else
+ {
+ BOOST_ASSERT(0);
+ }
std::string str;
temp.swap(str);
Modified: branches/quickbook-1.5/detail/actions.hpp
==============================================================================
--- branches/quickbook-1.5/detail/actions.hpp (original)
+++ branches/quickbook-1.5/detail/actions.hpp 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -432,6 +432,16 @@
, collector>
python_p_type;
+ typedef teletype_highlight<
+ plain_char_action
+ , string_symbols
+ , do_macro_action
+ , pre_escape_back
+ , post_escape_back
+ , actions
+ , collector>
+ teletype_p_type;
+
struct syntax_highlight
{
syntax_highlight(
@@ -443,6 +453,7 @@
, source_mode(source_mode)
, cpp_p(temp, macro, do_macro_action(temp), escape_actions)
, python_p(temp, macro, do_macro_action(temp), escape_actions)
+ , teletype_p(temp, macro, do_macro_action(temp), escape_actions)
{
}
@@ -452,6 +463,7 @@
std::string const& source_mode;
cpp_p_type cpp_p;
python_p_type python_p;
+ teletype_p_type teletype_p;
};
struct code_action
Modified: branches/quickbook-1.5/doc/quickbook.qbk
==============================================================================
--- branches/quickbook-1.5/doc/quickbook.qbk (original)
+++ branches/quickbook-1.5/doc/quickbook.qbk 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -176,6 +176,7 @@
* Improved handling of unmatched escape in code blocks.
* Support for python snippets.
* Use static scoping in templates, should be a lot more intuitive.
+* `teletype` source mode.
[endsect]
@@ -448,6 +449,7 @@
[[Mode] [Source Mode Markup]]
[[C++] [[^\[c++\]]]]
[[Python] [[^\[python\]]]]
+ [[Plain Text] [[^\[teletype\]]]]
]
[note The source mode strings are lowercase.]
Modified: branches/quickbook-1.5/doc_info.hpp
==============================================================================
--- branches/quickbook-1.5/doc_info.hpp (original)
+++ branches/quickbook-1.5/doc_info.hpp 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -153,6 +153,7 @@
>> (
str_p("c++")
| "python"
+ | "teletype"
) [assign_a(actions.source_mode)]
;
Modified: branches/quickbook-1.5/phrase.hpp
==============================================================================
--- branches/quickbook-1.5/phrase.hpp (original)
+++ branches/quickbook-1.5/phrase.hpp 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -403,6 +403,7 @@
(
str_p("c++")
| "python"
+ | "teletype"
) [assign_a(actions.source_mode)]
;
Modified: branches/quickbook-1.5/syntax_highlight.hpp
==============================================================================
--- branches/quickbook-1.5/syntax_highlight.hpp (original)
+++ branches/quickbook-1.5/syntax_highlight.hpp 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -323,6 +323,85 @@
DoMacro do_macro;
EscapeActions& escape_actions;
};
+
+ // Grammar for plain text (no actual highlighting)
+ template <
+ typename CharProcess
+ , typename Macro
+ , typename DoMacro
+ , typename PreEscape
+ , typename PostEscape
+ , typename EscapeActions
+ , typename Out>
+ struct teletype_highlight
+ : public grammar<teletype_highlight<CharProcess, Macro, DoMacro, PreEscape, PostEscape, EscapeActions, Out> >
+ {
+ teletype_highlight(Out& out, Macro const& macro, DoMacro do_macro, EscapeActions& escape_actions)
+ : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {}
+
+ template <typename Scanner>
+ struct definition
+ {
+ definition(teletype_highlight const& self)
+ : common(self.escape_actions, unused)
+ , unused(false)
+ {
+ program
+ =
+ *( macro
+ | escape
+ | repeat_p(1)[anychar_p] [CharProcess(self.out)]
+ )
+ ;
+
+ macro =
+ eps_p(self.macro // must not be followed by
+ >> (eps_p - (alpha_p | '_'))) // alpha or underscore
+ >> self.macro [self.do_macro]
+ ;
+
+ qbk_phrase =
+ *( common
+ | (anychar_p - str_p("``")) [self.escape_actions.plain_char]
+ )
+ ;
+
+ escape =
+ str_p("``") [PreEscape(self.escape_actions, save)]
+ >>
+ (
+ (
+ (
+ (+(anychar_p - "``") >> eps_p("``"))
+ & qbk_phrase
+ )
+ >> str_p("``")
+ )
+ |
+ (
+ eps_p [self.escape_actions.error]
+ >> *anychar_p
+ )
+ ) [PostEscape(self.out, self.escape_actions, save)]
+ ;
+ }
+
+ rule<Scanner> program, macro, qbk_phrase, escape;
+
+ phrase_grammar<EscapeActions> common;
+ std::string save;
+ bool unused;
+
+ rule<Scanner> const&
+ start() const { return program; }
+ };
+
+ Out& out;
+ Macro const& macro;
+ DoMacro do_macro;
+ EscapeActions& escape_actions;
+ };
+
}
#endif // BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP
Modified: branches/quickbook-1.5/test/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5/test/Jamfile.v2 (original)
+++ branches/quickbook-1.5/test/Jamfile.v2 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -15,6 +15,7 @@
[ quickbook-test code-block-1 ]
[ quickbook-test code-block-2 ]
[ quickbook-test code-block-3 ]
+ [ quickbook-test code-block-teletype ]
[ quickbook-test code-snippet ]
[ quickbook-test preformatted ]
[ quickbook-test link-side-by-side ]
Added: branches/quickbook-1.5/test/code-block-teletype.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5/test/code-block-teletype.gold 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="code_block_teletype_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Code Block Teletype 1</title>
+ <articleinfo>
+ </articleinfo>
+ <para>
+ </para>
+ <section id="code_block_teletype_1.a_code_block">
+ <title><link linkend="code_block_teletype_1.a_code_block">A code block</link></title>
+
+<programlisting>Just some plain text.
+With some <emphasis role="bold">quickbook</emphasis> thrown in?
+</programlisting>
+ </section>
+</article>
Added: branches/quickbook-1.5/test/code-block-teletype.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5/test/code-block-teletype.quickbook 2009-05-30 09:02:28 EDT (Sat, 30 May 2009)
@@ -0,0 +1,14 @@
+[article Code Block Teletype 1
+ [quickbook 1.5]
+]
+
+[teletype]
+
+[section A code block]
+
+[def __text__ text]
+
+ Just some plain __text__.
+ ``With some *quickbook* thrown in?``
+
+[endsect]
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