Add ids to bridgeheads.

Prevents docbook from making up ever changing ids. It would be nice to
use the heading's anchor. But that causes docbook to complain that it
can't generate a title for the link.

[SVN r68595]
This commit is contained in:
Daniel James 2011-02-01 09:21:25 +00:00
parent e50fefdecb
commit 6d4dec6803
16 changed files with 67 additions and 86 deletions

View File

@ -107,6 +107,20 @@ namespace quickbook
out << post;
}
}
namespace {
void write_bridgehead(collector& out, int level,
std::string const& str, std::string const& id, std::string const& linkend)
{
out << "<bridgehead renderas=\"sect" << level << "\"";
if(!id.empty()) out << " id=\"" << id << "\"";
out << ">";
if(!linkend.empty()) out << "<link linkend=\"" << linkend << "\">";
out << str;
if(!linkend.empty()) out << "</link>";
out << "</bridgehead>";
}
}
void header_action::operator()(iterator first, iterator last) const
{
@ -138,20 +152,8 @@ namespace quickbook
actions.anchors.push_back(anchor);
actions.output_pre(out);
if (qbk_version_n < 103)
{
out << pre << str << post
;
}
else // version 1.3 and above
{
out << pre
<< "<link linkend=\"" << anchor << "\">"
<< str
<< "</link>"
<< post
;
}
std::string linkend = qbk_version_n < 103 ? std::string() : anchor;
write_bridgehead(out, level, str, anchor + "-heading", linkend);
}
void generic_header_action::operator()(iterator first, iterator last) const
@ -179,13 +181,7 @@ namespace quickbook
actions.anchors.push_back(anchor);
actions.output_pre(out);
out
<< "<bridgehead renderas=\"sect" << level_ << "\">"
<< "<link linkend=\"" << anchor << "\">"
<< str
<< "</link>"
<< "</bridgehead>"
;
write_bridgehead(out, level_, str, anchor + "-heading", anchor);
}
void simple_phrase_action::operator()(iterator first, iterator last) const

View File

@ -212,8 +212,7 @@ namespace quickbook
std::string const& library_id,
std::string const& section_id,
std::string const& qualified_section_id,
std::string const& pre,
std::string const& post,
int level,
quickbook::actions& actions)
: out(out)
, phrase(phrase)
@ -221,8 +220,7 @@ namespace quickbook
, library_id(library_id)
, section_id(section_id)
, qualified_section_id(qualified_section_id)
, pre(pre)
, post(post)
, level(level)
, actions(actions) {}
void operator()(iterator first, iterator last) const;
@ -233,8 +231,7 @@ namespace quickbook
std::string const& library_id;
std::string const& section_id;
std::string const& qualified_section_id;
std::string pre;
std::string post;
int level;
quickbook::actions& actions;
};

View File

@ -98,12 +98,12 @@ namespace quickbook
, inline_code(phrase, *this)
, inside_paragraph(out, phrase, paragraph_pre, paragraph_post, *this)
, h(out, phrase, element_id, doc_id, section_id, qualified_section_id, section_level, *this)
, h1(out, phrase, element_id, doc_id, section_id, qualified_section_id, h1_pre, h1_post, *this)
, h2(out, phrase, element_id, doc_id, section_id, qualified_section_id, h2_pre, h2_post, *this)
, h3(out, phrase, element_id, doc_id, section_id, qualified_section_id, h3_pre, h3_post, *this)
, h4(out, phrase, element_id, doc_id, section_id, qualified_section_id, h4_pre, h4_post, *this)
, h5(out, phrase, element_id, doc_id, section_id, qualified_section_id, h5_pre, h5_post, *this)
, h6(out, phrase, element_id, doc_id, section_id, qualified_section_id, h6_pre, h6_post, *this)
, h1(out, phrase, element_id, doc_id, section_id, qualified_section_id, 1, *this)
, h2(out, phrase, element_id, doc_id, section_id, qualified_section_id, 2, *this)
, h3(out, phrase, element_id, doc_id, section_id, qualified_section_id, 3, *this)
, h4(out, phrase, element_id, doc_id, section_id, qualified_section_id, 4, *this)
, h5(out, phrase, element_id, doc_id, section_id, qualified_section_id, 5, *this)
, h6(out, phrase, element_id, doc_id, section_id, qualified_section_id, 6, *this)
, hr(out, hr_, *this)
, blurb(out, blurb_pre, blurb_post, *this)
, blockquote(out, blockquote_pre, blockquote_post, *this)

View File

@ -16,18 +16,6 @@ namespace quickbook
const char* comment_post = "-->";
const char* paragraph_pre = "<para>\n";
const char* paragraph_post = "</para>\n";
const char* h1_pre = "<bridgehead renderas=\"sect1\">";
const char* h1_post = "</bridgehead>";
const char* h2_pre = "<bridgehead renderas=\"sect2\">";
const char* h2_post = "</bridgehead>";
const char* h3_pre = "<bridgehead renderas=\"sect3\">";
const char* h3_post = "</bridgehead>";
const char* h4_pre = "<bridgehead renderas=\"sect4\">";
const char* h4_post = "</bridgehead>";
const char* h5_pre = "<bridgehead renderas=\"sect5\">";
const char* h5_post = "</bridgehead>";
const char* h6_pre = "<bridgehead renderas=\"sect6\">";
const char* h6_post = "</bridgehead>";
const char* hr_ = "<para/>";
const char* blurb_pre = "<sidebar role=\"blurb\">\n";
const char* blurb_post = "</sidebar>\n";

View File

@ -10,25 +10,25 @@
We want to make sure they appear in the correct place. <anchor id="a3"/>
</para>
<anchor id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor-heading">
<link linkend="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor">This
heading shouldn't pick up the previous anchor</link>
</bridgehead>
<anchor id="a4"/> <anchor id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor-heading">
<link linkend="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor">This
heading should pick up the previous anchor</link>
</bridgehead>
<anchor id="a5"/> <anchor id="anchor_test.anchors.and_this_one"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="anchor_test.anchors.and_this_one-heading">
<link linkend="anchor_test.anchors.and_this_one">And this one</link>
</bridgehead>
<anchor id="a6"/> <anchor id="anchor_test.anchors.also_this_one"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="anchor_test.anchors.also_this_one-heading">
<link linkend="anchor_test.anchors.also_this_one">Also this one</link>
</bridgehead>
<anchor id="a7"/> <anchor id="anchors.finally_this"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="anchors.finally_this-heading">
Finally this
</bridgehead>
<anchor id="a8"/>

View File

@ -3,7 +3,7 @@
<article id="various_blocks" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Various blocks</title> <anchor id="various_blocks.blockquotes"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="various_blocks.blockquotes-heading">
<link linkend="various_blocks.blockquotes">Blockquotes</link>
</bridgehead>
<para>
@ -26,7 +26,7 @@
</para>
</blockquote>
<anchor id="various_blocks.admonitions"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="various_blocks.admonitions-heading">
<link linkend="various_blocks.admonitions">Admonitions</link>
</bridgehead>
<warning>
@ -63,7 +63,7 @@
</para>
</warning>
<anchor id="various_blocks.blurb"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="various_blocks.blurb-heading">
<link linkend="various_blocks.blurb">Blurb</link>
</bridgehead>
<sidebar role="blurb">
@ -71,7 +71,7 @@
Blurb
</para>
</sidebar> <anchor id="various_blocks.inline_blocks"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="various_blocks.inline_blocks-heading">
<link linkend="various_blocks.inline_blocks">Inline blocks</link>
</bridgehead>
<blockquote>

View File

@ -27,7 +27,7 @@ Code block line 2.
Paragraph.
</para>
<anchor id="indented_code_blocks.code_blocks_separated_by_comment"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="indented_code_blocks.code_blocks_separated_by_comment-heading">
<link linkend="indented_code_blocks.code_blocks_separated_by_comment">Code blocks
separated by comment</link>
</bridgehead>

View File

@ -2,21 +2,21 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="header" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Header</title> <anchor id="header.header_test"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="header.header_test-heading">
<link linkend="header.header_test">Header Test</link>
</bridgehead>
<para>
Testing headers without sections.
</para>
<anchor id="header._not_an_id"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="header._not_an_id-heading">
<link linkend="header._not_an_id">:Not an Id</link>
</bridgehead>
<para>
Paragraph.
</para>
<anchor id="header._not_an_id_again"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="header._not_an_id_again-heading">
<link linkend="header._not_an_id_again">:Not an Id again</link>
</bridgehead>
<para>

View File

@ -2,21 +2,21 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="header" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Header</title> <anchor id="header.header_test"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="header.header_test-heading">
<link linkend="header.header_test">Header Test</link>
</bridgehead>
<para>
Paragraph.
</para>
<anchor id="header.heading_id"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="header.heading_id-heading">
<link linkend="header.heading_id">Heading with an id</link>
</bridgehead>
<para>
Paragraph.
</para>
<anchor id="header.heading_id2"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="header.heading_id2-heading">
<link linkend="header.heading_id2">Heading with an id</link>
</bridgehead>
<para>

View File

@ -3,7 +3,7 @@
<article id="identifiers_in_quickbook_1_5" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Identifiers in quickbook 1.5</title> <anchor id="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_-heading">
<link linkend="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_">Test
heading with <code><phrase role="identifier">code</phrase></code></link>
</bridgehead>

View File

@ -3,7 +3,7 @@
<article id="identifiers_in_quickbook_1_6" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Identifiers in quickbook 1.6</title> <anchor id="identifiers_in_quickbook_1_6.test_heading_with__code_"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="identifiers_in_quickbook_1_6.test_heading_with__code_-heading">
<link linkend="identifiers_in_quickbook_1_6.test_heading_with__code_">Test heading
with <code><phrase role="identifier">code</phrase></code></link>
</bridgehead>

View File

@ -104,7 +104,7 @@
<section id="quickbook.change_log">
<title><link linkend="quickbook.change_log">Change Log</link></title> <anchor
id="quickbook.change_log.version_1_3"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="quickbook.change_log.version_1_3-heading">
<link linkend="quickbook.change_log.version_1_3">Version 1.3</link>
</bridgehead>
<itemizedlist>
@ -1707,27 +1707,27 @@ escape (no processing/formatting)
[h6 Heading 6]
<!--quickbook-escape-postfix--></programlisting>
<anchor id="quickbook.syntax.block.headings.heading_1"/>
<bridgehead renderas="sect1">
<bridgehead renderas="sect1" id="quickbook.syntax.block.headings.heading_1-heading">
<link linkend="quickbook.syntax.block.headings.heading_1">Heading 1</link>
</bridgehead>
<anchor id="quickbook.syntax.block.headings.heading_2"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="quickbook.syntax.block.headings.heading_2-heading">
<link linkend="quickbook.syntax.block.headings.heading_2">Heading 2</link>
</bridgehead>
<anchor id="quickbook.syntax.block.headings.heading_3"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="quickbook.syntax.block.headings.heading_3-heading">
<link linkend="quickbook.syntax.block.headings.heading_3">Heading 3</link>
</bridgehead>
<anchor id="quickbook.syntax.block.headings.heading_4"/>
<bridgehead renderas="sect4">
<bridgehead renderas="sect4" id="quickbook.syntax.block.headings.heading_4-heading">
<link linkend="quickbook.syntax.block.headings.heading_4">Heading 4</link>
</bridgehead>
<anchor id="quickbook.syntax.block.headings.heading_5"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.headings.heading_5-heading">
<link linkend="quickbook.syntax.block.headings.heading_5">Heading 5</link>
</bridgehead>
<anchor id="quickbook.syntax.block.headings.heading_6"/>
<bridgehead renderas="sect6">
<bridgehead renderas="sect6" id="quickbook.syntax.block.headings.heading_6-heading">
<link linkend="quickbook.syntax.block.headings.heading_6">Heading 6</link>
</bridgehead>
<para>
@ -1972,7 +1972,7 @@ Hi, my name is [name]. I am [age] years old. I am a [what].
]
<!--quickbook-escape-postfix--></programlisting>
<anchor id="quickbook.syntax.block.templates.template_identifier"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_identifier-heading">
<link linkend="quickbook.syntax.block.templates.template_identifier">Template
Identifier</link>
</bridgehead>
@ -1994,7 +1994,7 @@ Hi, my name is [name]. I am [age] years old. I am a [what].
</listitem>
</itemizedlist>
<anchor id="quickbook.syntax.block.templates.formal_template_arguments"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.formal_template_arguments-heading">
<link linkend="quickbook.syntax.block.templates.formal_template_arguments">Formal
Template Arguments</link>
</bridgehead>
@ -2014,7 +2014,7 @@ Hi, my name is [name]. I am [age] years old. I am a [what].
of the template call.
</para>
<anchor id="quickbook.syntax.block.templates.template_body"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_body-heading">
<link linkend="quickbook.syntax.block.templates.template_body">Template
Body</link>
</bridgehead>
@ -2041,7 +2041,7 @@ replacement text...
block level elements are not allowed in phrase templates.
</para>
<anchor id="quickbook.syntax.block.templates.template_expansion"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_expansion-heading">
<link linkend="quickbook.syntax.block.templates.template_expansion">Template
Expansion</link>
</bridgehead>
@ -2084,7 +2084,7 @@ replacement text...
by the close parenthesis.
</para>
<anchor id="quickbook.syntax.block.templates.nullary_templates"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.nullary_templates-heading">
<link linkend="quickbook.syntax.block.templates.nullary_templates">Nullary
Templates</link>
</bridgehead>
@ -2177,7 +2177,7 @@ for the journey to old age.]]]
brackets, though.
</para>
<anchor id="quickbook.syntax.block.templates.simple_arguments"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.simple_arguments-heading">
<link linkend="quickbook.syntax.block.templates.simple_arguments">Simple
Arguments</link>
</bridgehead>
@ -2252,7 +2252,7 @@ for the journey to old age.]]]
what do you think man?
</para>
<anchor id="quickbook.syntax.block.templates.punctuation_templates"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.templates.punctuation_templates-heading">
<link linkend="quickbook.syntax.block.templates.punctuation_templates">Punctuation
Templates</link>
</bridgehead>
@ -2656,7 +2656,7 @@ for the journey to old age.]]]
QuickBook's import facility provides a nice solution.
</para>
<anchor id="quickbook.syntax.block.import.example"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.import.example-heading">
<link linkend="quickbook.syntax.block.import.example">Example</link>
</bridgehead>
<para>
@ -2734,7 +2734,7 @@ for the journey to old age.]]]
Some trailing text here
</para>
<anchor id="quickbook.syntax.block.import.code_snippet_markup"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.import.code_snippet_markup-heading">
<link linkend="quickbook.syntax.block.import.code_snippet_markup">Code
Snippet Markup</link>
</bridgehead>
@ -2756,7 +2756,7 @@ for the journey to old age.]]]
This too will not be visible in quickbook.
</para>
<anchor id="quickbook.syntax.block.import.special_comments"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.import.special_comments-heading">
<link linkend="quickbook.syntax.block.import.special_comments">Special
Comments</link>
</bridgehead>
@ -2779,7 +2779,7 @@ for the journey to old age.]]]
initial slash-star-tick and the final star-slash shall be ignored.
</para>
<anchor id="quickbook.syntax.block.import.callouts"/>
<bridgehead renderas="sect5">
<bridgehead renderas="sect5" id="quickbook.syntax.block.import.callouts-heading">
<link linkend="quickbook.syntax.block.import.callouts">Callouts</link>
</bridgehead>
<para>
@ -3147,7 +3147,7 @@ comment.box.end.props=]
<section id="quickbook.faq">
<title><link linkend="quickbook.faq">Frequently Asked Questions</link></title>
<anchor id="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_-heading">
<link linkend="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_">Can
I use QuickBook for non-Boost documentation?</link>
</bridgehead>

View File

@ -12,7 +12,7 @@
Hello.
</para>
<anchor id="section_in_a_template.test.just_to_test_id_generation"/>
<bridgehead renderas="sect3">
<bridgehead renderas="sect3" id="section_in_a_template.test.just_to_test_id_generation-heading">
<link linkend="section_in_a_template.test.just_to_test_id_generation">Just
to test id generation</link>
</bridgehead>

View File

@ -2,7 +2,7 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>UTF-8 test</title> <anchor id="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n-heading">
<link linkend="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n">I&#xF1;t&#xEB;rn&#xE2;ti&#xF4;n&#xE0;liz&#xE6;ti&#xF8;n</link>
</bridgehead>
<itemizedlist>

View File

@ -2,7 +2,7 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>UTF-8 test</title> <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="utf_8_test.i__t__rn__ti__n__liz__ti__n-heading">
<link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônàlizætiøn</link>
</bridgehead>
<itemizedlist>

View File

@ -2,7 +2,7 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>UTF-8 test</title> <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
<bridgehead renderas="sect2">
<bridgehead renderas="sect2" id="utf_8_test.i__t__rn__ti__n__liz__ti__n-heading">
<link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônàlizætiøn</link>
</bridgehead>
<itemizedlist>