|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69176 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-22 15:38:45
Author: danieljames
Date: 2011-02-22 15:38:41 EST (Tue, 22 Feb 2011)
New Revision: 69176
URL: http://svn.boost.org/trac/boost/changeset/69176
Log:
Clean up paragraphs a little.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 22 ++++++++--------------
branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 18 +++---------------
branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 2 +-
branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp | 2 +-
branches/quickbook-filenames/tools/quickbook/src/block_tags.hpp | 3 ++-
branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 23 ++++++++++++-----------
branches/quickbook-filenames/tools/quickbook/src/markups.cpp | 1 +
7 files changed, 28 insertions(+), 43 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-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -217,30 +217,24 @@
assert(!values.is());
}
- void implicit_paragraph_action::operator()() const
+ void paragraph_action::operator()() const
{
if(actions.suppress) return;
std::string str;
- phrase.swap(str);
-
- // TODO: Use spirit to do this?
+ actions.phrase.swap(str);
std::string::const_iterator
pos = str.begin(),
end = str.end();
- while(pos != end && (
- *pos == ' ' || *pos == '\t' || *pos == '\n' || *pos == '\r'))
- {
- ++pos;
- }
+ while(pos != end && cl::space_p.test(*pos)) ++pos;
if(pos != end) {
- out << pre << str;
- // TODO: Is this right place?
- actions.output_pre(out);
- out << post;
+ detail::markup markup = detail::markups[block_tags::paragraph];
+ actions.out << markup.pre << str;
+ actions.output_pre(actions.out);
+ actions.out << markup.post;
}
}
@@ -1229,7 +1223,7 @@
}
if(symbol->body.is_block || !block.empty()) {
- actions.inside_paragraph();
+ actions.paragraph(); // For paragraphs before the template call.
actions.out << block;
actions.phrase << phrase;
}
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-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -146,30 +146,18 @@
quickbook::actions& actions;
};
- struct implicit_paragraph_action
+ struct paragraph_action
{
// implicit paragraphs
// doesn't output the paragraph if it's only whitespace.
- implicit_paragraph_action(
- collector& out,
- collector& phrase,
- std::string const& pre,
- std::string const& post,
+ paragraph_action(
quickbook::actions& actions)
- : out(out)
- , phrase(phrase)
- , pre(pre)
- , post(post)
- , actions(actions) {}
+ : actions(actions) {}
void operator()() const;
void operator()(iterator first, iterator last) const { (*this)(); }
- collector& out;
- collector& phrase;
- std::string pre;
- std::string post;
quickbook::actions& actions;
};
Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-02-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -73,7 +73,7 @@
, code(out, phrase, *this)
, code_block(phrase, phrase, *this)
, inline_code(phrase, *this)
- , inside_paragraph(out, phrase, paragraph_pre, paragraph_post, *this)
+ , paragraph(*this)
, hr(out, hr_, *this)
, space_char(phrase)
, plain_char(phrase, *this)
Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp 2011-02-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -117,7 +117,7 @@
code_action code;
code_action code_block;
inline_code_action inline_code;
- implicit_paragraph_action inside_paragraph;
+ paragraph_action paragraph;
markup_action hr;
space space_char;
plain_char_action plain_char;
Modified: branches/quickbook-filenames/tools/quickbook/src/block_tags.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/block_tags.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/block_tags.hpp 2011-02-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -21,7 +21,8 @@
(warning)(caution)(important)(note)(tip)
(macro_definition)(template_definition)
(variable_list)(table)
- (xinclude)(import)(include)
+ (xinclude)(import)(include)
+ (paragraph)
)
QUICKBOOK_VALUE_TAGS(table_tags, 0x250,
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-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -163,7 +163,7 @@
local.paragraph_separator
= cl::eol_p
>> *cl::blank_p
- >> cl::eol_p [actions.inside_paragraph]
+ >> cl::eol_p [actions.paragraph]
;
local.hr =
@@ -176,7 +176,7 @@
= '[' >> space
>> local.element
>> cl::eps_p(local.check_element(element_info::in_block))
- [actions.inside_paragraph]
+ [actions.paragraph]
[actions.values.reset()]
>> ( actions.values.list(detail::var(local.element_tag))
[ local.element_rule
@@ -375,14 +375,15 @@
inside_paragraph =
actions.scoped_output()
- [
- actions.values.save()
- [
- (*( common
- | (cl::anychar_p - phrase_end) [actions.plain_char]
- | (+eol) [actions.inside_paragraph]
- )) [actions.inside_paragraph]
- ] [actions.out_value]
+ [ actions.values.save()
+ [
+ ( *( common
+ | (cl::anychar_p - phrase_end)
+ [actions.plain_char]
+ | local.paragraph_separator
+ [actions.paragraph]
+ ) ) [actions.paragraph]
+ ] [actions.out_value]
]
;
@@ -406,7 +407,7 @@
= '[' >> space
>> local.element
>> cl::eps_p(local.check_element(element_info::in_conditional))
- [actions.inside_paragraph]
+ [actions.paragraph]
[actions.values.reset()]
>> ( actions.values.list(detail::var(local.element_tag))
[ local.element_rule
Modified: branches/quickbook-filenames/tools/quickbook/src/markups.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/markups.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/markups.cpp 2011-02-22 15:38:41 EST (Tue, 22 Feb 2011)
@@ -99,6 +99,7 @@
void initialise_markups()
{
markup init_markups[] = {
+ { block_tags::paragraph, paragraph_pre, paragraph_post },
{ block_tags::blurb, blurb_pre, blurb_post },
{ block_tags::blockquote, blockquote_pre, blockquote_post },
{ block_tags::preformatted, preformatted_pre, preformatted_post },
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