mirror of
https://github.com/boostorg/quickbook.git
synced 2026-01-26 18:52:26 +00:00
Rest of the block elements.
[SVN r69174]
This commit is contained in:
@@ -55,6 +55,11 @@ namespace quickbook
|
||||
void block_action(quickbook::actions&, value);
|
||||
void macro_definition_action(quickbook::actions&, value);
|
||||
void template_body_action(quickbook::actions&, value);
|
||||
void variable_list_action(quickbook::actions&, value);
|
||||
void table_action(quickbook::actions&, value);
|
||||
void xinclude_action(quickbook::actions&, value);
|
||||
void import_action(quickbook::actions&, value);
|
||||
void include_action(quickbook::actions&, value);
|
||||
|
||||
void element_action::operator()(iterator first, iterator) const
|
||||
{
|
||||
@@ -90,6 +95,16 @@ namespace quickbook
|
||||
return macro_definition_action(actions,v);
|
||||
case block_tags::template_definition:
|
||||
return template_body_action(actions,v);
|
||||
case block_tags::variable_list:
|
||||
return variable_list_action(actions, v);
|
||||
case block_tags::table:
|
||||
return table_action(actions, v);
|
||||
case block_tags::xinclude:
|
||||
return xinclude_action(actions, v);
|
||||
case block_tags::import:
|
||||
return import_action(actions, v);
|
||||
case block_tags::include:
|
||||
return include_action(actions, v);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1213,11 +1228,11 @@ namespace quickbook
|
||||
}
|
||||
}
|
||||
|
||||
void variablelist_action::operator()(iterator, iterator) const
|
||||
void variable_list_action(quickbook::actions& actions, value variable_list)
|
||||
{
|
||||
if(actions.suppress) return;
|
||||
|
||||
value_consumer values = actions.values.get();
|
||||
value_consumer values = variable_list;
|
||||
std::string title = values.consume(table_tags::title).get_quickbook();
|
||||
|
||||
actions.out << "<variablelist>\n";
|
||||
@@ -1247,11 +1262,11 @@ namespace quickbook
|
||||
actions.out << "</variablelist>\n";
|
||||
}
|
||||
|
||||
void table_action::operator()(iterator, iterator) const
|
||||
void table_action(quickbook::actions& actions, value table)
|
||||
{
|
||||
if(actions.suppress) return;
|
||||
|
||||
value_consumer values = actions.values.get();
|
||||
value_consumer values = table;
|
||||
|
||||
std::string element_id;
|
||||
if(values.is(general_tags::element_id))
|
||||
@@ -1444,14 +1459,13 @@ namespace quickbook
|
||||
return std::accumulate(file, path.end(), result, concat);
|
||||
}
|
||||
|
||||
std::string check_path(iterator first, iterator last,
|
||||
quickbook::actions& actions)
|
||||
std::string check_path(value const& path, quickbook::actions& actions)
|
||||
{
|
||||
std::string path_text(first, last);
|
||||
std::string path_text = path.get_quickbook();
|
||||
|
||||
if(path_text.find('\\') != std::string::npos)
|
||||
{
|
||||
detail::outwarn(actions.filename, first.get_position().line)
|
||||
detail::outwarn(actions.filename, path.get_position().line)
|
||||
<< "Path isn't portable: "
|
||||
<< detail::utf8(path_text)
|
||||
<< std::endl;
|
||||
@@ -1476,14 +1490,18 @@ namespace quickbook
|
||||
return path;
|
||||
}
|
||||
|
||||
void xinclude_action::operator()(iterator first, iterator last) const
|
||||
void xinclude_action(quickbook::actions& actions, value xinclude)
|
||||
{
|
||||
if(!actions.output_pre(out)) return;
|
||||
if(!actions.output_pre(actions.out)) return;
|
||||
|
||||
fs::path path = calculate_relative_path(check_path(first, last, actions), actions);
|
||||
out << "\n<xi:include href=\"";
|
||||
detail::print_string(detail::escape_uri(path.generic_string()), out.get());
|
||||
out << "\" />\n";
|
||||
value_consumer values = xinclude;
|
||||
fs::path path = calculate_relative_path(
|
||||
check_path(values.consume(), actions), actions);
|
||||
assert(!values.is());
|
||||
|
||||
actions.out << "\n<xi:include href=\"";
|
||||
detail::print_string(detail::escape_uri(path.generic_string()), actions.out.get());
|
||||
actions.out << "\" />\n";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -1516,12 +1534,15 @@ namespace quickbook
|
||||
}
|
||||
}
|
||||
|
||||
void import_action::operator()(iterator first, iterator last) const
|
||||
void import_action(quickbook::actions& actions, value import)
|
||||
{
|
||||
if(!actions.output_pre(actions.out)) return;
|
||||
|
||||
value_consumer values = import;
|
||||
fs::path path = include_search(actions.filename.parent_path(),
|
||||
check_path(first, last, actions));
|
||||
check_path(values.consume(), actions));
|
||||
assert(!values.is());
|
||||
|
||||
std::string ext = path.extension().generic_string();
|
||||
std::vector<template_symbol> storage;
|
||||
actions.error_count +=
|
||||
@@ -1540,12 +1561,16 @@ namespace quickbook
|
||||
}
|
||||
}
|
||||
|
||||
void include_action::operator()(iterator first, iterator last) const
|
||||
void include_action(quickbook::actions& actions, value include)
|
||||
{
|
||||
if(!actions.output_pre(actions.out)) return;
|
||||
|
||||
value_consumer values = include;
|
||||
value include_doc_id = values.optional_consume(general_tags::include_id);
|
||||
fs::path filein = include_search(actions.filename.parent_path(),
|
||||
check_path(first, last, actions));
|
||||
check_path(values.consume(), actions));
|
||||
assert(!values.is());
|
||||
|
||||
std::string doc_type, doc_id;
|
||||
|
||||
// swap the filenames
|
||||
@@ -1575,11 +1600,8 @@ namespace quickbook
|
||||
|
||||
// if an id is specified in this include (as in [include:id foo.qbk])
|
||||
// then use it as the doc_id.
|
||||
if (!actions.include_doc_id.empty())
|
||||
{
|
||||
actions.doc_id = actions.include_doc_id;
|
||||
actions.include_doc_id.clear();
|
||||
}
|
||||
if (!include_doc_id.is_empty())
|
||||
actions.doc_id = include_doc_id.get_quickbook();
|
||||
|
||||
// update the __FILENAME__ macro
|
||||
*boost::spirit::classic::find(actions.macro, "__FILENAME__")
|
||||
|
||||
@@ -545,30 +545,6 @@ namespace quickbook
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct variablelist_action
|
||||
{
|
||||
// Handles variable lists
|
||||
|
||||
variablelist_action(quickbook::actions& actions)
|
||||
: actions(actions) {}
|
||||
|
||||
void operator()(iterator, iterator) const;
|
||||
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct table_action
|
||||
{
|
||||
// Handles tables
|
||||
|
||||
table_action(quickbook::actions& actions)
|
||||
: actions(actions) {}
|
||||
|
||||
void operator()(iterator, iterator) const;
|
||||
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct element_id_warning_action
|
||||
{
|
||||
element_id_warning_action(quickbook::actions& actions_)
|
||||
@@ -579,42 +555,6 @@ namespace quickbook
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct xinclude_action
|
||||
{
|
||||
// Handles XML includes
|
||||
xinclude_action(collector& out_, quickbook::actions& actions_)
|
||||
: out(out_), actions(actions_) {}
|
||||
|
||||
void operator()(iterator first, iterator last) const;
|
||||
|
||||
collector& out;
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct include_action
|
||||
{
|
||||
// Handles QBK includes
|
||||
|
||||
include_action(quickbook::actions& actions_)
|
||||
: actions(actions_) {}
|
||||
|
||||
void operator()(iterator first, iterator last) const;
|
||||
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
struct import_action
|
||||
{
|
||||
// Handles import of source code files (e.g. *.cpp *.py)
|
||||
import_action(collector& out_, quickbook::actions& actions_)
|
||||
: out(out_), actions(actions_) {}
|
||||
|
||||
void operator()(iterator first, iterator last) const;
|
||||
|
||||
collector& out;
|
||||
quickbook::actions& actions;
|
||||
};
|
||||
|
||||
void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo = false);
|
||||
void post(collector& out, quickbook::actions& actions, bool ignore_docinfo = false);
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace quickbook
|
||||
, doc_type()
|
||||
, doc_title_qbk()
|
||||
, doc_id()
|
||||
, include_doc_id()
|
||||
|
||||
// main output stream
|
||||
, out(out_)
|
||||
@@ -118,8 +117,6 @@ namespace quickbook
|
||||
, simple_teletype(phrase, teletype_pre_, teletype_post_, macro, *this)
|
||||
, simple_strikethrough(phrase, strikethrough_pre_, strikethrough_post_, macro, *this)
|
||||
|
||||
, variablelist(*this)
|
||||
|
||||
, break_(phrase, *this)
|
||||
, do_macro(phrase, *this)
|
||||
, do_template(*this)
|
||||
@@ -127,13 +124,9 @@ namespace quickbook
|
||||
, url_post(phrase, url_post_, *this)
|
||||
, link_pre(phrase, link_pre_, *this)
|
||||
, link_post(phrase, link_post_, *this)
|
||||
, table(*this)
|
||||
, anchor(*this)
|
||||
|
||||
, element_id_warning(*this)
|
||||
, xinclude(out, *this)
|
||||
, include(*this)
|
||||
, import(out, *this)
|
||||
|
||||
, escape_pre(phrase, escape_pre_, *this)
|
||||
, escape_post(phrase, escape_post_, *this)
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace quickbook
|
||||
std::string doc_type;
|
||||
std::string doc_title_qbk;
|
||||
std::string doc_id;
|
||||
std::string include_doc_id;
|
||||
|
||||
// main output stream
|
||||
collector out;
|
||||
@@ -162,8 +161,6 @@ namespace quickbook
|
||||
simple_phrase_action simple_teletype;
|
||||
simple_phrase_action simple_strikethrough;
|
||||
|
||||
variablelist_action variablelist;
|
||||
|
||||
break_action break_;
|
||||
do_macro_action do_macro;
|
||||
do_template_action do_template;
|
||||
@@ -171,13 +168,9 @@ namespace quickbook
|
||||
markup_action url_post;
|
||||
link_action link_pre;
|
||||
markup_action link_post;
|
||||
table_action table;
|
||||
anchor_action anchor;
|
||||
|
||||
element_id_warning_action element_id_warning;
|
||||
xinclude_action xinclude;
|
||||
include_action include;
|
||||
import_action import;
|
||||
|
||||
markup_action escape_pre;
|
||||
markup_action escape_post;
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace quickbook
|
||||
;
|
||||
|
||||
elements.add
|
||||
("variablelist", element_info(element_info::block, &local.variablelist))
|
||||
("variablelist", element_info(element_info::block, &local.variablelist, block_tags::variable_list))
|
||||
;
|
||||
|
||||
local.variablelist =
|
||||
@@ -183,7 +183,6 @@ namespace quickbook
|
||||
>> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
|
||||
>> (+eol) [actions.output_pre]
|
||||
>> *local.varlistentry
|
||||
>> cl::eps_p [actions.variablelist]
|
||||
;
|
||||
|
||||
local.varlistentry =
|
||||
@@ -225,7 +224,7 @@ namespace quickbook
|
||||
;
|
||||
|
||||
elements.add
|
||||
("table", element_info(element_info::block, &local.table))
|
||||
("table", element_info(element_info::block, &local.table, block_tags::table))
|
||||
;
|
||||
|
||||
local.table =
|
||||
@@ -235,7 +234,6 @@ namespace quickbook
|
||||
>> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
|
||||
>> (+eol) [actions.output_pre]
|
||||
>> *local.table_row
|
||||
>> cl::eps_p [actions.table]
|
||||
;
|
||||
|
||||
local.table_row =
|
||||
@@ -266,21 +264,19 @@ namespace quickbook
|
||||
;
|
||||
|
||||
elements.add
|
||||
("xinclude", element_info(element_info::conditional_or_block, &local.xinclude))
|
||||
("import", element_info(element_info::conditional_or_block, &local.import))
|
||||
("include", element_info(element_info::conditional_or_block, &local.include))
|
||||
("xinclude", element_info(element_info::conditional_or_block, &local.xinclude, block_tags::xinclude))
|
||||
("import", element_info(element_info::conditional_or_block, &local.import, block_tags::import))
|
||||
("include", element_info(element_info::conditional_or_block, &local.include, block_tags::include))
|
||||
;
|
||||
|
||||
local.xinclude =
|
||||
space
|
||||
>> (*(cl::anychar_p - phrase_end))
|
||||
[actions.xinclude]
|
||||
>> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
|
||||
;
|
||||
|
||||
local.import =
|
||||
space
|
||||
>> (*(cl::anychar_p - phrase_end))
|
||||
[actions.import]
|
||||
>> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
|
||||
;
|
||||
|
||||
local.include =
|
||||
@@ -289,11 +285,10 @@ namespace quickbook
|
||||
!(
|
||||
':'
|
||||
>> (*((cl::alnum_p | '_') - cl::space_p))
|
||||
[cl::assign_a(actions.include_doc_id)]
|
||||
[actions.values.entry(ph::arg1, ph::arg2, general_tags::include_id)]
|
||||
>> space
|
||||
)
|
||||
>> (*(cl::anychar_p - phrase_end))
|
||||
[actions.include]
|
||||
>> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
|
||||
;
|
||||
|
||||
local.inner_phrase =
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace quickbook
|
||||
(blurb)(blockquote)(preformatted)
|
||||
(warning)(caution)(important)(note)(tip)
|
||||
(macro_definition)(template_definition)
|
||||
(variable_list)(table)
|
||||
(xinclude)(import)(include)
|
||||
)
|
||||
|
||||
QUICKBOOK_VALUE_TAGS(table_tags, 0x250,
|
||||
@@ -27,7 +29,7 @@ namespace quickbook
|
||||
)
|
||||
|
||||
QUICKBOOK_VALUE_TAGS(general_tags, 0x300,
|
||||
(element_id)
|
||||
(element_id)(include_id)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user