diff --git a/block.hpp b/block.hpp index 7ea556f..7d034c7 100644 --- a/block.hpp +++ b/block.hpp @@ -33,6 +33,10 @@ namespace quickbook std::string content; }; + struct block_separator + { + }; + struct list_item { file_position position; diff --git a/block_actions.cpp b/block_actions.cpp index 706a12f..51eaec1 100644 --- a/block_actions.cpp +++ b/block_actions.cpp @@ -36,16 +36,30 @@ namespace quickbook } } + block_formatted process(quickbook::state& state, block_formatted const& x) + { + state.paragraph_output(); + return x; + } + block_formatted process(quickbook::state& state, paragraph const& x) { + state.paragraph_output(); block_formatted r; r.type="paragraph"; r.content = x.content; return r; } + nothing process(quickbook::state& state, block_separator const&) + { + state.paragraph_output(); + } + begin_section2 process(quickbook::state& state, begin_section const& x) { + state.paragraph_output(); + // TODO: This uses the generated title. state.section_id.value = x.id ? x.id->value : @@ -82,6 +96,8 @@ namespace quickbook end_section2 process(quickbook::state& state, end_section const& x) { + state.paragraph_output(); + if (state.section_level <= state.min_section_level) { detail::outerr(x.position.file,x.position.line) @@ -110,6 +126,8 @@ namespace quickbook heading2 process(quickbook::state& state, heading const& x) { + state.paragraph_output(); + heading2 r; // TODO: Is this right? @@ -151,6 +169,8 @@ namespace quickbook nothing process(quickbook::state& state, def_macro const& x) { + state.paragraph_output(); + state.macro.add( x.macro_identifier.begin() , x.macro_identifier.end() @@ -160,6 +180,8 @@ namespace quickbook nothing process(quickbook::state& state, define_template const& x) { + state.paragraph_output(); + if(!state.templates.add(x)) { detail::outerr(x.body.position.file, x.body.position.line) << "Template Redefinition: " << x.id << std::endl; @@ -171,6 +193,8 @@ namespace quickbook table2 process(quickbook::state& state, table const& x) { + state.paragraph_output(); + table2 r; if(!x.title.empty()) r.title = x.title; @@ -207,6 +231,13 @@ namespace quickbook return r; } + variablelist process(quickbook::state& state, variablelist const& x) + { + state.paragraph_output(); + + return x; + } + namespace { int load_snippets( @@ -305,6 +336,8 @@ namespace quickbook xinclude2 process(quickbook::state& state, xinclude const& x) { + state.paragraph_output(); + xinclude2 r; r.path = calculate_relative_path(detail::escape_uri(x.path), state).string(); return r; @@ -312,6 +345,8 @@ namespace quickbook nothing process(quickbook::state& state, include const& x) { + state.paragraph_output(); + fs::path filein = include_search(state.filename.parent_path(), x.path); raw_string doc_id; @@ -369,6 +404,8 @@ namespace quickbook nothing process(quickbook::state& state, import const& x) { + state.paragraph_output(); + fs::path path = include_search(state.filename.parent_path(), x.path); std::string ext = path.extension(); std::vector storage; diff --git a/block_actions.hpp b/block_actions.hpp index 6495d79..f517c3d 100644 --- a/block_actions.hpp +++ b/block_actions.hpp @@ -15,14 +15,16 @@ namespace quickbook { - // TODO: Just generate formatted. + block_formatted process(quickbook::state&, block_formatted const&); block_formatted process(quickbook::state&, paragraph const&); + nothing process(quickbook::state&, block_separator const&); begin_section2 process(quickbook::state&, begin_section const&); end_section2 process(quickbook::state&, end_section const&); heading2 process(quickbook::state&, heading const&); nothing process(quickbook::state&, def_macro const&); nothing process(quickbook::state&, define_template const&); table2 process(quickbook::state&, table const&); + variablelist process(quickbook::state&, variablelist const&); xinclude2 process(quickbook::state&, xinclude const&); nothing process(quickbook::state&, import const&); nothing process(quickbook::state&, include const&); diff --git a/block_grammar.cpp b/block_grammar.cpp index 2d148dd..ab1187a 100644 --- a/block_grammar.cpp +++ b/block_grammar.cpp @@ -20,6 +20,7 @@ #include "code.hpp" #include "misc_rules.hpp" #include "parse_utils.hpp" +#include "state.hpp" namespace quickbook { @@ -33,7 +34,8 @@ namespace quickbook qi::rule& code = store_.create(); qi::rule& list = store_.create(); qi::rule& hr = store_.create(); - qi::rule& paragraph = store_.create(); + qi::rule& paragraph = store_.create(); + qi::rule& block_separator = store_.create(); block_start = blocks >> blank @@ -44,9 +46,9 @@ namespace quickbook | code [actions.process] | list [actions.process] | hr [actions.process] - | comment >> +eol - | paragraph [actions.process] + | block_separator [actions.process] | eol + | paragraph ) ; @@ -124,27 +126,29 @@ namespace quickbook ] >> qi::attr(quickbook::hr()) ; - qi::rule& paragraph_content = store_.create(); qi::rule& paragraph_end = store_.create(); qi::symbols<>& paragraph_end_markups = store_.create(); paragraph = - paragraph_content [member_assign(&quickbook::paragraph::content)] - ; - - paragraph_content = - qi::eps [actions.phrase_push] - >> *( common + +( common | (qi::char_ - // Make sure we don't go past paragraph_end // a single block. ) [actions.process] ) - >> qi::eps [actions.phrase_pop] - >> (&qi::lit('[') | +eol) ; paragraph_end = - '[' >> space >> paragraph_end_markups >> hard_space | eol >> *qi::blank >> qi::eol + '[' >> space >> paragraph_end_markups >> hard_space | block_separator + ; + + // Define block_seperator using qi::eol/qi::blank rather than 'eol' + // because we don't want any comments in the blank line. + + block_separator = + qi::attr(quickbook::block_separator()) + >> qi::omit + [ qi::eol >> *qi::blank >> qi::eol + ] ; paragraph_end_markups = @@ -180,20 +184,23 @@ namespace quickbook // Block contents - qi::rule& inside_paragraph2 = store_.create(); + qi::rule& inside_paragraph2 = store_.create(); inside_paragraph = - qi::eps [actions.phrase_push] - >> inside_paragraph2 [actions.process] - >> *( +eol - >> inside_paragraph2 [actions.process] + qi::eps [actions.block_push][actions.phrase_push] + >> ( + inside_paragraph2 [actions.process] + % block_separator [actions.process] ) - >> qi::eps [actions.phrase_pop] + >> qi::attr(quickbook::block_separator()) + [actions.process] + >> qi::eps [actions.phrase_pop][actions.block_pop] ; inside_paragraph2 = - phrase_attr [member_assign(&quickbook::formatted::content)] - [member_assign(&quickbook::formatted::type, "paragraph")] + *( common + | (qi::char_ - phrase_end) [actions.process] + ) ; phrase_attr = diff --git a/block_list.cpp b/block_list.cpp index ead682b..ea57d6a 100644 --- a/block_list.cpp +++ b/block_list.cpp @@ -44,6 +44,8 @@ namespace quickbook list2 process(quickbook::state& state, quickbook::list const& list) { + state.paragraph_output(); + list::const_iterator it = list.begin(), end = list.end(); BOOST_ASSERT(it != end); diff --git a/phrase_actions.cpp b/phrase_actions.cpp index 750d914..7406625 100644 --- a/phrase_actions.cpp +++ b/phrase_actions.cpp @@ -82,6 +82,8 @@ namespace quickbook } boost::variant process(quickbook::state& state, code const& x) { + if(x.flow == x.block) state.paragraph_output(); + std::string program = x.content; if(x.flow == x.block || x.flow == x.inline_block) { diff --git a/process.cpp b/process.cpp index e60a281..3ab9add 100644 --- a/process.cpp +++ b/process.cpp @@ -65,6 +65,7 @@ namespace quickbook template void process_action::operator()(image const&) const; template void process_action::operator()
(hr const&) const; template void process_action::operator()(paragraph const&) const; + template void process_action::operator()(block_separator const&) const; template void process_action::operator()(list const&) const; template void process_action::operator()(begin_section const&) const; template void process_action::operator()(end_section const&) const; diff --git a/state.cpp b/state.cpp index f277f99..adbf865 100644 --- a/state.cpp +++ b/state.cpp @@ -13,6 +13,7 @@ #include "actions.hpp" #include "state.hpp" #include "quickbook.hpp" +#include "block.hpp" #if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310)) #pragma warning(disable:4355) @@ -95,4 +96,19 @@ namespace quickbook block.pop(); templates.pop(); } + + void state::paragraph_output() + { + std::string paragraph; + phrase.swap(paragraph); + + if(!paragraph.empty()) { + actions a(*this); + + quickbook::paragraph p; + p.content = paragraph; + + a.process(p); + } + } } diff --git a/state.hpp b/state.hpp index d819b7c..7ec3901 100644 --- a/state.hpp +++ b/state.hpp @@ -75,6 +75,9 @@ namespace quickbook // push/pop the states and the streams void push(); void pop(); + + // + void paragraph_output(); }; } diff --git a/test/code-block-teletype.gold b/test/code-block-teletype.gold index ffa7b2a..43ec8ca 100644 --- a/test/code-block-teletype.gold +++ b/test/code-block-teletype.gold @@ -5,8 +5,6 @@ Code Block Teletype 1 - -
<link linkend="code_block_teletype_1.a_code_block">A code block</link> diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 6c323b8..c8ceaa5 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -1541,8 +1541,6 @@ escape (no processing/formatting) highlighted according to the current Source Mode: - - #include <iostream> @@ -1553,9 +1551,7 @@ escape (no processing/formatting) return 0; } - - - + import cgi def cookForHtml(text): @@ -1563,8 +1559,6 @@ escape (no processing/formatting) return cgi.escape(text) - - Macros that are already defined are expanded in source code. Example: @@ -2849,8 +2843,6 @@ for the journey to old age.]]]
<link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link> - -
Section contributed by Julio M. Merino Vidal