parent
aff762eee4
commit
e9e100e881
37
block.hpp
37
block.hpp
@ -10,6 +10,7 @@
|
||||
#if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
|
||||
#define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
|
||||
|
||||
#include "./detail/quickbook.hpp"
|
||||
#include "./detail/utils.hpp"
|
||||
#include "./phrase.hpp"
|
||||
#include <boost/spirit/include/classic_core.hpp>
|
||||
@ -22,7 +23,6 @@
|
||||
namespace quickbook
|
||||
{
|
||||
using namespace boost::spirit::classic;
|
||||
extern unsigned qbk_version_n;
|
||||
|
||||
template <typename Actions, bool skip_initial_spaces = false>
|
||||
struct block_grammar : grammar<block_grammar<Actions> >
|
||||
@ -122,19 +122,32 @@ namespace quickbook
|
||||
| eps_p [actions.error]
|
||||
)
|
||||
;
|
||||
|
||||
element_id =
|
||||
':'
|
||||
>>
|
||||
(
|
||||
if_p(qbk_since(105u)) [space]
|
||||
>> (+(alnum_p | '_')) [assign_a(actions.element_id)]
|
||||
| eps_p [actions.element_id_warning]
|
||||
[assign_a(actions.element_id)]
|
||||
)
|
||||
| eps_p [assign_a(actions.element_id)]
|
||||
;
|
||||
|
||||
element_id_1_5 =
|
||||
if_p(qbk_since(105u)) [
|
||||
element_id
|
||||
]
|
||||
.else_p [
|
||||
eps_p [assign_a(actions.element_id)]
|
||||
]
|
||||
;
|
||||
|
||||
begin_section =
|
||||
"section"
|
||||
>> hard_space
|
||||
>> ( ':' >>
|
||||
(
|
||||
if_p(qbk_since(105u)) [space]
|
||||
>> (+(alnum_p | '_')) [assign_a(actions.element_id)]
|
||||
| eps_p [actions.section_warning]
|
||||
[assign_a(actions.element_id)]
|
||||
)
|
||||
| eps_p [assign_a(actions.element_id)]
|
||||
)
|
||||
>> element_id
|
||||
>> phrase [actions.begin_section]
|
||||
;
|
||||
|
||||
@ -290,6 +303,8 @@ namespace quickbook
|
||||
table =
|
||||
"table"
|
||||
>> (eps_p(*blank_p >> eol_p) | hard_space)
|
||||
>> element_id_1_5
|
||||
>> (eps_p(*blank_p >> eol_p) | space)
|
||||
>> (*(anychar_p - eol)) [assign_a(actions.table_title)]
|
||||
>> +eol
|
||||
>> *table_row
|
||||
@ -426,7 +441,7 @@ namespace quickbook
|
||||
xinclude, include, hard_space, eol, paragraph_end,
|
||||
template_, template_id, template_formal_arg,
|
||||
template_body, identifier, dummy_block, import,
|
||||
inside_paragraph;
|
||||
inside_paragraph, element_id, element_id_1_5;
|
||||
|
||||
symbols<> paragraph_end_markups;
|
||||
|
||||
|
@ -819,10 +819,19 @@ namespace quickbook
|
||||
std::string::iterator first = actions.table_title.begin();
|
||||
std::string::iterator last = actions.table_title.end();
|
||||
bool has_title = first != last;
|
||||
|
||||
std::string table_id;
|
||||
if(qbk_version_n >= 105) {
|
||||
if(!actions.element_id.empty()) table_id = actions.element_id;
|
||||
else if(has_title) table_id = detail::make_identifier(first, last);
|
||||
}
|
||||
|
||||
if (has_title)
|
||||
{
|
||||
actions.out << "<table frame=\"all\">\n";
|
||||
actions.out << "<table frame=\"all\"";
|
||||
if(!table_id.empty())
|
||||
actions.out << " id=\"" << table_id << "\"";
|
||||
actions.out << ">\n";
|
||||
actions.out << "<title>";
|
||||
while (first != last)
|
||||
detail::print_char(*first++, actions.out.get());
|
||||
@ -830,7 +839,10 @@ namespace quickbook
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.out << "<informaltable frame=\"all\">\n";
|
||||
actions.out << "<informaltable frame=\"all\"";
|
||||
if(!table_id.empty())
|
||||
actions.out << " id=\"" << table_id << "\"";
|
||||
actions.out << ">\n";
|
||||
}
|
||||
|
||||
actions.out << "<tgroup cols=\"" << actions.table_span << "\">\n";
|
||||
@ -965,10 +977,10 @@ namespace quickbook
|
||||
}
|
||||
}
|
||||
|
||||
void section_warning_action::operator()(iterator first, iterator) const
|
||||
void element_id_warning_action::operator()(iterator first, iterator) const
|
||||
{
|
||||
boost::spirit::classic::file_position const pos = first.get_position();
|
||||
detail::outwarn(pos.file,pos.line) << "Empty section id after 'section:'.\n";
|
||||
detail::outwarn(pos.file,pos.line) << "Empty id.\n";
|
||||
}
|
||||
|
||||
fs::path path_difference(fs::path const& outdir, fs::path const& path)
|
||||
|
@ -709,7 +709,7 @@ namespace quickbook
|
||||
int& error_count;
|
||||
};
|
||||
|
||||
struct section_warning_action
|
||||
struct element_id_warning_action
|
||||
{
|
||||
void operator()(iterator first, iterator last) const;
|
||||
};
|
||||
|
@ -192,7 +192,7 @@ namespace quickbook
|
||||
|
||||
begin_section_action begin_section;
|
||||
end_section_action end_section;
|
||||
section_warning_action section_warning;
|
||||
element_id_warning_action element_id_warning;
|
||||
xinclude_action xinclude;
|
||||
include_action include;
|
||||
import_action import;
|
||||
|
@ -27,6 +27,7 @@ test-suite quickbook.test :
|
||||
[ quickbook-test import ]
|
||||
[ quickbook-test section_1_4 ]
|
||||
[ quickbook-test section_1_5 ]
|
||||
[ quickbook-test table_1_5 ]
|
||||
[ quickbook-fail-test fail-include ]
|
||||
[ quickbook-fail-test fail-import ]
|
||||
[ quickbook-fail-test fail-template-arguments1 ]
|
||||
|
Loading…
Reference in New Issue
Block a user