mirror of
https://github.com/boostorg/quickbook.git
synced 2026-01-19 04:22:16 +00:00
Quickbook: Merge to quickbook-dev
[SVN r76636]
This commit is contained in:
@@ -412,7 +412,9 @@ namespace quickbook
|
||||
// version and the generation version are less then 103u.
|
||||
|
||||
std::string anchor = actions.ids.old_style_id(
|
||||
detail::make_identifier(content.get_encoded()),
|
||||
detail::make_identifier(
|
||||
actions.ids.replace_placeholders_with_unresolved_ids(
|
||||
content.get_encoded())),
|
||||
id_category::generated_heading);
|
||||
|
||||
write_bridgehead(actions, level,
|
||||
@@ -425,7 +427,8 @@ namespace quickbook
|
||||
detail::make_identifier(
|
||||
actions.ids.compatibility_version() >= 106 ?
|
||||
content.get_quickbook() :
|
||||
content.get_encoded()
|
||||
actions.ids.replace_placeholders_with_unresolved_ids(
|
||||
content.get_encoded())
|
||||
),
|
||||
id_category::generated_heading);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace quickbook
|
||||
|
||||
struct id_placeholder;
|
||||
struct id_data;
|
||||
std::string replace_ids(id_state& state, std::string const& xml,
|
||||
bool use_resolved_ids = true);
|
||||
std::string process_ids(id_state&, std::string const&);
|
||||
|
||||
static const std::size_t max_size = 32;
|
||||
@@ -46,6 +48,9 @@ namespace quickbook
|
||||
state_enum generation_state;
|
||||
// Placeholder's position in generation
|
||||
// process.
|
||||
std::string unresolved_id;
|
||||
// The id that would be generated without any
|
||||
// duplicate handling.
|
||||
std::string id; // The id so far.
|
||||
id_placeholder* parent; // Placeholder of the parent id.
|
||||
// Only when generation_state == child
|
||||
@@ -69,6 +74,7 @@ namespace quickbook
|
||||
id_placeholder* parent_ = 0)
|
||||
: index(index),
|
||||
generation_state(parent_ ? child : unresolved),
|
||||
unresolved_id(parent_ ? parent_->unresolved_id + '.' + id : id),
|
||||
id(id),
|
||||
parent(parent_),
|
||||
category(category),
|
||||
@@ -285,6 +291,12 @@ private:
|
||||
return state->add_placeholder(id, category)->to_string();
|
||||
}
|
||||
|
||||
std::string id_manager::replace_placeholders_with_unresolved_ids(
|
||||
std::string const& xml) const
|
||||
{
|
||||
return replace_ids(*state, xml, false);
|
||||
}
|
||||
|
||||
std::string id_manager::replace_placeholders(std::string const& xml) const
|
||||
{
|
||||
assert(!state->current_file);
|
||||
@@ -868,7 +880,6 @@ private:
|
||||
placeholder_index index_placeholders(id_state&, std::string const& xml);
|
||||
void resolve_id(id_placeholder&, allocated_ids&);
|
||||
void generate_id(id_placeholder&, allocated_ids&);
|
||||
std::string replace_ids(id_state& state, std::string const& xml);
|
||||
|
||||
std::string process_ids(id_state& state, std::string const& xml)
|
||||
{
|
||||
@@ -1081,11 +1092,13 @@ private:
|
||||
struct replace_ids_callback : xml_processor::callback
|
||||
{
|
||||
id_state& state;
|
||||
bool use_resolved_ids;
|
||||
std::string::const_iterator source_pos;
|
||||
std::string result;
|
||||
|
||||
replace_ids_callback(id_state& state)
|
||||
replace_ids_callback(id_state& state, bool resolved)
|
||||
: state(state),
|
||||
use_resolved_ids(resolved),
|
||||
source_pos(),
|
||||
result()
|
||||
{}
|
||||
@@ -1099,10 +1112,13 @@ private:
|
||||
{
|
||||
if (id_placeholder* p = state.get_placeholder(value))
|
||||
{
|
||||
assert(p->check_state(id_placeholder::generated));
|
||||
assert(!use_resolved_ids ||
|
||||
p->check_state(id_placeholder::generated));
|
||||
std::string const& id = use_resolved_ids ?
|
||||
p->id : p->unresolved_id;
|
||||
|
||||
result.append(source_pos, value.begin());
|
||||
result.append(p->id.begin(), p->id.end());
|
||||
result.append(id.begin(), id.end());
|
||||
source_pos = value.end();
|
||||
}
|
||||
}
|
||||
@@ -1114,10 +1130,11 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
std::string replace_ids(id_state& state, std::string const& xml)
|
||||
std::string replace_ids(id_state& state, std::string const& xml,
|
||||
bool use_unresolved_ids)
|
||||
{
|
||||
xml_processor processor;
|
||||
replace_ids_callback callback(state);
|
||||
replace_ids_callback callback(state, use_unresolved_ids);
|
||||
processor.parse(xml, callback);
|
||||
return callback.result;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ namespace quickbook
|
||||
std::string add_id(std::string const&, id_category);
|
||||
std::string add_anchor(std::string const&, id_category);
|
||||
|
||||
std::string replace_placeholders_with_unresolved_ids(
|
||||
std::string const&) const;
|
||||
std::string replace_placeholders(std::string const&) const;
|
||||
|
||||
unsigned compatibility_version() const;
|
||||
|
||||
@@ -37,6 +37,12 @@
|
||||
<bridgehead renderas="sect1" id="._also_not_an_id">
|
||||
:also not an id
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="._anchor_id__anchor___anchor_heading">
|
||||
<anchor id="anchor"/>Anchor heading
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="._link_linkend__anchor__link_heading__link_">
|
||||
<link linkend="anchor">Link heading</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id=".h1">
|
||||
H1
|
||||
</bridgehead>
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
[h1:notanid]
|
||||
[h1:also not an id]
|
||||
|
||||
[/ Test how ids are generated for headings containing things like anchors
|
||||
and links ]
|
||||
|
||||
[h1 [#anchor]Anchor heading]
|
||||
[h1 [link anchor Link heading]]
|
||||
|
||||
[/ Test how heading ids are generated inside sections]
|
||||
|
||||
[h1 H1]
|
||||
|
||||
@@ -45,7 +45,16 @@
|
||||
<phrase id="heading_test_1_5._also_not_an_id"/><link linkend="heading_test_1_5._also_not_an_id">:also
|
||||
not an id</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect2" id="heading_test_1_5.h13">
|
||||
<bridgehead renderas="sect1" id="heading_test_1_5.h13">
|
||||
<phrase id="heading_test_1_5._anchor_id__anchor___anchor_heading"/><link linkend="heading_test_1_5._anchor_id__anchor___anchor_heading"><anchor
|
||||
id="anchor"/>Anchor heading</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_5.h14">
|
||||
<phrase id="heading_test_1_5._link_linkend__anchor__link_heading__link_"/><link
|
||||
linkend="heading_test_1_5._link_linkend__anchor__link_heading__link_"><link linkend="anchor">Link
|
||||
heading</link></link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect2" id="heading_test_1_5.h15">
|
||||
<phrase id="heading_test_1_5.h1"/><link linkend="heading_test_1_5.h1">H1</link>
|
||||
</bridgehead>
|
||||
<section id="heading_test_1_5.s1">
|
||||
@@ -72,7 +81,7 @@
|
||||
<phrase id="heading_test_1_5.s1.h6"/><link linkend="heading_test_1_5.s1.h6">H6</link>
|
||||
</bridgehead>
|
||||
</section>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_5.h14">
|
||||
<bridgehead renderas="sect1" id="heading_test_1_5.h16">
|
||||
<phrase id="heading_test_1_5.h7"/><link linkend="heading_test_1_5.h7">H7</link>
|
||||
</bridgehead>
|
||||
</article>
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
[h1:notanid]
|
||||
[h1:also not an id]
|
||||
|
||||
[/ Test how ids are generated for headings containing things like anchors
|
||||
and links ]
|
||||
|
||||
[h1 [#anchor]Anchor heading]
|
||||
[h1 [link anchor Link heading]]
|
||||
|
||||
[/ Test how heading ids are generated inside sections]
|
||||
|
||||
[heading H1]
|
||||
|
||||
@@ -39,6 +39,14 @@
|
||||
<phrase id="heading_test_1_6.comment"/><link linkend="heading_test_1_6.comment">Comment</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h11">
|
||||
<phrase id="heading_test_1_6.anchor_anchor_heading"/><link linkend="heading_test_1_6.anchor_anchor_heading"><anchor
|
||||
id="anchor"/>Anchor heading</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h12">
|
||||
<phrase id="heading_test_1_6.link_anchor_link_heading"/><link linkend="heading_test_1_6.link_anchor_link_heading"><link
|
||||
linkend="anchor">Link heading</link></link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h13">
|
||||
<phrase id="heading_test_1_6.h1"/><link linkend="heading_test_1_6.h1">H1</link>
|
||||
</bridgehead>
|
||||
<section id="heading_test_1_6.s1">
|
||||
@@ -65,10 +73,10 @@
|
||||
<phrase id="heading_test_1_6.s1.h6"/><link linkend="heading_test_1_6.s1.h6">H6</link>
|
||||
</bridgehead>
|
||||
</section>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h12">
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h14">
|
||||
<phrase id="heading_test_1_6.h7"/><link linkend="heading_test_1_6.h7">H7</link>
|
||||
</bridgehead>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h13">
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h15">
|
||||
<phrase id="heading_test_1_6.a1"/><link linkend="heading_test_1_6.a1">H1</link>
|
||||
</bridgehead>
|
||||
<section id="heading_test_1_6.s1_0">
|
||||
@@ -95,7 +103,7 @@
|
||||
<phrase id="heading_test_1_6.s1_0.a6"/><link linkend="heading_test_1_6.s1_0.a6">H6</link>
|
||||
</bridgehead>
|
||||
</section>
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h14">
|
||||
<bridgehead renderas="sect1" id="heading_test_1_6.h16">
|
||||
<phrase id="heading_test_1_6.a7"/><link linkend="heading_test_1_6.a7">H7</link>
|
||||
</bridgehead>
|
||||
</article>
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
[h1 *Bold*]
|
||||
[h1 [/]Comment[/]]
|
||||
|
||||
[/ Test how ids are generated for headings containing things like anchors
|
||||
and links ]
|
||||
|
||||
[h1 [#anchor]Anchor heading]
|
||||
[h1 [link anchor Link heading]]
|
||||
|
||||
[/ Test how heading ids are generated inside sections]
|
||||
|
||||
[h1 H1]
|
||||
|
||||
Reference in New Issue
Block a user