|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69332 - in branches/quickbook-filenames/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-02-27 10:37:49
Author: danieljames
Date: 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
New Revision: 69332
URL: http://svn.boost.org/trac/boost/changeset/69332
Log:
Support escapes in simple markup.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 13 +++++------
branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 2
branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 46 ++++++++++++++++++++++++++++-----------
branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold | 15 +++++++++++++
branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook | 12 ++++++++++
5 files changed, 67 insertions(+), 21 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
@@ -307,11 +307,10 @@
content.get_boostbook(), anchor + "-heading", linkend);
}
- void simple_phrase_action::operator()(iterator first, iterator last) const
+ void simple_phrase_action::operator()(char mark) const
{
if(!actions.output_pre(out)) return;
- char mark = *first;
int tag =
mark == '*' ? phrase_tags::bold :
mark == '/' ? phrase_tags::italic :
@@ -322,18 +321,18 @@
assert(tag != 0);
detail::markup markup = detail::markups[tag];
- std::string str(
- boost::next(first.base()),
- boost::prior(last.base()));
+ value_consumer values = actions.values.get();
+ value content = values.consume();
+ values.finish();
out << markup.pre;
- if (std::string const* ptr = find(macro, str.c_str()))
+ if (std::string const* ptr = find(macro, content.get_quickbook().c_str()))
{
out << *ptr;
}
else
{
- detail::print_string(str, out.get());
+ out << content.get_boostbook();
}
out << markup.post;
}
Modified: branches/quickbook-filenames/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.hpp 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
@@ -142,7 +142,7 @@
, macro(macro)
, actions(actions) {}
- void operator()(iterator first, iterator last) const;
+ void operator()(char) const;
collector& out;
string_symbols const& macro;
Modified: branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
@@ -101,7 +101,7 @@
top_level, blocks, paragraph_separator,
code, code_line, blank_line, hr,
list, list_item, element,
- escape,
+ nested_char, escape,
inline_code,
template_,
code_block, macro,
@@ -381,7 +381,8 @@
;
local.simple_markup =
- ( cl::chset<>("*/_=") [local.simple_markup.mark = ph::arg1]
+ cl::chset<>("*/_=") [local.simple_markup.mark = ph::arg1]
+ >> cl::eps_p(cl::graph_p) // graph_p must follow first mark
>> lookback
[ cl::anychar_p
>> ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark))
@@ -392,10 +393,17 @@
// by space or punctuation or the
// mark character or a the start.
]
- >> cl::graph_p // graph_p must follow first mark
- >> *(cl::anychar_p - local.simple_markup_end(local.simple_markup.mark))
- >> cl::f_ch_p(local.simple_markup.mark)
- ) [actions.simple_markup]
+ >> actions.values.save()
+ [
+ actions.scoped_output()
+ [
+ (*( ~cl::eps_p(local.simple_markup_end(local.simple_markup.mark))
+ >> local.nested_char
+ )) [actions.docinfo_value(ph::arg1, ph::arg2)]
+ ]
+ >> cl::f_ch_p(local.simple_markup.mark)
+ [actions.simple_markup]
+ ]
;
local.simple_markup_end
@@ -452,6 +460,19 @@
]
;
+ local.nested_char =
+ cl::str_p("\\n") [actions.break_]
+ | "\\ " // ignore an escaped space
+ | '\\' >> cl::punct_p [actions.raw_char]
+ | "\\u" >> cl::repeat_p(4)
+ [cl::chset<>("0-9a-fA-F")]
+ [actions.escape_unicode]
+ | "\\U" >> cl::repeat_p(8)
+ [cl::chset<>("0-9a-fA-F")]
+ [actions.escape_unicode]
+ | cl::anychar_p [actions.plain_char]
+ ;
+
local.escape =
cl::str_p("\\n") [actions.break_]
| cl::str_p("\\ ") // ignore an escaped space
@@ -540,13 +561,12 @@
;
phrase_end =
- ']' |
- cl::if_p(var(actions.no_eols))
- [
- cl::eol_p >> *cl::blank_p >> cl::eol_p
- // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
+ ']'
+ | cl::eps_p(var(actions.no_eols))
+ >> cl::eol_p >> *cl::blank_p >> cl::eol_p
+ ; // Make sure that we don't go
+ // past a single block, except
+ // when preformatted.
comment =
"[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
Modified: branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold (original)
+++ branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
@@ -31,5 +31,20 @@
<para>
_Should not underline escaped markup_. _or this escaped_ markup form.
</para>
+ <para>
+ <literal>Matti Meikäläinen</literal>
+ </para>
+ <para>
+ <literal>replaced</literal>
+ </para>
+ <para>
+ <emphasis role="underline">replaced</emphasis>
+ </para>
+ <para>
+ <literal>_macro_</literal>
+ </para>
+ <para>
+ /not italic/
+ </para>
</section>
</article>
Modified: branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook (original)
+++ branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook 2011-02-27 10:37:47 EST (Sun, 27 Feb 2011)
@@ -2,6 +2,8 @@
[quickbook 1.5]
]
+[def _macro_ replaced]
+
[section Simple Markup]
/italic/ *bold* _underline_ =teletype=
@@ -21,4 +23,14 @@
_Should not underline '''escaped''' markup_.
_or this '''escaped_ markup''' form.
+=Matti Meik\u00E4l\u00E4inen=
+
+=_macro_=
+
+__macro__
+
+=_mac\ ro_=
+
+/not italic\/
+
[endsect]
\ No newline at end of file
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