|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67324 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2010-12-19 08:26:58
Author: danieljames
Date: 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
New Revision: 67324
URL: http://svn.boost.org/trac/boost/changeset/67324
Log:
Smarter anchor support.
Added:
trunk/tools/quickbook/test/anchor.gold (contents, props changed)
trunk/tools/quickbook/test/anchor.quickbook (contents, props changed)
Text files modified:
trunk/tools/quickbook/src/actions.cpp | 132 ++++++++++++++++++++++---
trunk/tools/quickbook/src/actions.hpp | 183 +++++++++++++++++++++++++++---------
trunk/tools/quickbook/src/actions_class.cpp | 199 ++++++++++++++++++++-------------------
trunk/tools/quickbook/src/actions_class.hpp | 7 +
trunk/tools/quickbook/src/block_grammar.cpp | 35 ++++--
trunk/tools/quickbook/src/syntax_highlight.cpp | 6
trunk/tools/quickbook/src/syntax_highlight.hpp | 2
trunk/tools/quickbook/test/Jamfile.v2 | 1
trunk/tools/quickbook/test/link.gold | 19 ++-
9 files changed, 396 insertions(+), 188 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -47,6 +47,8 @@
// Handles line-breaks (DEPRECATED!!!)
void break_action::operator()(iterator first, iterator) const
{
+ actions.output_pre(phrase);
+
position const pos = first.get_position();
detail::outwarn(pos.file,pos.line) << "in column:" << pos.column << ", "
<< "[br] and \\n are deprecated" << ".\n";
@@ -63,11 +65,15 @@
void tagged_action::operator()(std::string const& str) const
{
+ actions.output_pre(out);
+
out << pre << str << post;
}
void phrase_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(phrase);
+
std::string str;
phrase.swap(str);
out << pre << str << post;
@@ -91,7 +97,10 @@
}
if(pos != end) {
- out << pre << str << post;
+ out << pre << str;
+ // TODO: Is this right place?
+ actions.output_pre(out);
+ out << post;
}
}
@@ -100,27 +109,37 @@
std::string str;
phrase.swap(str);
+ std::string anchor;
+
if (qbk_version_n < 103) // version 1.2 and below
{
- out << "<anchor id=\""
- << section_id << '.'
- << detail::make_identifier(str.begin(), str.end())
- << "\" />"
- << pre << str << post
- ;
+ anchor = section_id + '.' +
+ detail::make_identifier(str.begin(), str.end());
}
- else // version 1.3 and above
+ else
{
std::string id =
!element_id.empty() ? element_id :
qbk_version_n >= 106 ? detail::make_identifier(first, last) :
detail::make_identifier(str.begin(), str.end());
- std::string anchor =
+ anchor =
fully_qualified_id(library_id, qualified_section_id, id);
+ }
- out << "<anchor id=\"" << anchor << "\"/>"
- << pre
+ actions.output_pre(out);
+ actions.anchors.swap(actions.saved_anchors);
+ 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>"
@@ -147,8 +166,12 @@
std::string anchor =
fully_qualified_id(library_id, qualified_section_id, id);
+ actions.output_pre(out);
+ actions.anchors.swap(actions.saved_anchors);
+ actions.anchors.push_back(anchor);
+ actions.output_pre(out);
+
out
- << "<anchor id=\"" << anchor << "\"/>"
<< "<bridgehead renderas=\"sect" << level_ << "\">"
<< "<link linkend=\"" << anchor << "\">"
<< str
@@ -159,6 +182,7 @@
void simple_phrase_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(out);
out << pre;
std::string str(first, last);
if (std::string const* ptr = find(macro, str.c_str()))
@@ -175,6 +199,10 @@
void cond_phrase_action_pre::operator()(iterator first, iterator last) const
{
+ // TODO: It would probably be better to save the anchors and restore
+ // them if the phrase isn't used.
+ actions.output_pre(out);
+
std::string str(first, last);
conditions.push_back(find(macro, str.c_str()));
out.push(); // save the stream
@@ -187,6 +215,8 @@
if (first == last || !symbol_found)
{
+ // clear any anchors defined in the conditional phrase.
+ actions.anchors.clear();
out.pop(); // restore the stream
}
else
@@ -218,6 +248,11 @@
void list_format_action::operator()(iterator first, iterator last) const
{
+ // I think this will only have an effect on the first item,
+ // it would have been called when outputting the previous
+ // item on other items. But might as well call it every time.
+ actions.output_pre(out);
+
int new_indent = 0;
while (first != last && (*first == ' ' || *first == '\t'))
{
@@ -315,14 +350,13 @@
void anchor_action::operator()(iterator first, iterator last) const
{
- out << "<anchor id=\"";
- while (first != last)
- detail::print_char(*first++, out.get());
- out << "\" />\n";
+ actions.anchors.push_back(std::string(first, last));
}
void do_macro_action::operator()(std::string const& str) const
{
+ actions.output_pre(phrase);
+
if (str == quickbook_get_date)
{
char strdate[64];
@@ -343,7 +377,6 @@
void space::operator()(char ch) const
{
-
detail::print_space(ch, out.get());
}
@@ -360,6 +393,7 @@
void post_escape_back::operator()(iterator first, iterator last) const
{
+ escape_actions.output_pre(escape_actions.phrase);
out << escape_actions.phrase.str();
escape_actions.phrase.pop(); // restore the stream
}
@@ -376,6 +410,8 @@
iterator last_(program.end(), program.end());
first_.set_position(first.get_position());
+ // TODO: Shouldn't phrase be empty here? Why would it be output
+ // after the code block?
std::string save;
phrase.swap(save);
@@ -388,6 +424,7 @@
// We must not place a \n after the <programlisting> tag
// otherwise PDF output starts code blocks with a blank line:
//
+ actions.output_pre(out);
out << "<programlisting>";
out << str;
out << "</programlisting>\n";
@@ -403,6 +440,7 @@
out.swap(save);
+ actions.output_pre(out);
out << "<code>";
out << str;
out << "</code>";
@@ -410,26 +448,32 @@
void raw_char_action::operator()(char ch) const
{
+ actions.output_pre(phrase);
phrase << ch;
}
void raw_char_action::operator()(iterator first, iterator /*last*/) const
{
+ actions.output_pre(phrase);
phrase << *first;
}
void plain_char_action::operator()(char ch) const
{
+ actions.output_pre(phrase);
detail::print_char(ch, phrase.get());
}
void plain_char_action::operator()(iterator first, iterator /*last*/) const
{
+ actions.output_pre(phrase);
detail::print_char(*first, phrase.get());
}
void escape_unicode_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(phrase);
+
while(first != last && *first == '0') ++first;
// Just ignore \u0000
@@ -462,6 +506,8 @@
void image_action::operator()(iterator, iterator) const
{
+ actions.output_pre(phrase);
+
fs::path const img_path(image_fileref);
attribute_map::iterator it = attributes.find("alt");
@@ -994,6 +1040,8 @@
void link_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(phrase);
+
iterator save = first;
phrase << tag;
while (first != last)
@@ -1126,7 +1174,7 @@
}
void begin_section_action::operator()(iterator first, iterator last) const
- {
+ {
section_id = element_id.empty() ?
detail::make_identifier(first, last) :
element_id;
@@ -1138,6 +1186,8 @@
qualified_section_id += section_id;
++section_level;
+ actions.output_pre(out);
+
if (qbk_version_n < 103) // version 1.2 and below
{
out << "\n<section id=\""
@@ -1151,6 +1201,9 @@
std::string str;
phrase.swap(str);
+ actions.anchors.swap(actions.saved_anchors);
+ actions.output_pre(out);
+
if (qbk_version_n < 103) // version 1.2 and below
{
out << "<title>" << str << "</title>\n";
@@ -1169,6 +1222,8 @@
void end_section_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(out);
+
if (section_level <= min_section_level)
{
position const pos = first.get_position();
@@ -1236,6 +1291,8 @@
void xinclude_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(out);
+
fs::path path = calculate_relative_path(first, last, actions);
out << "\n<xi:include href=\"";
detail::print_string(detail::escape_uri(path.string()), out.get());
@@ -1275,6 +1332,8 @@
void import_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(actions.out);
+
fs::path path = include_search(actions.filename.parent_path(), std::string(first,last));
std::string ext = path.extension();
std::vector<template_symbol> storage;
@@ -1297,6 +1356,8 @@
void include_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(actions.out);
+
fs::path filein = include_search(actions.filename.parent_path(), std::string(first,last));
std::string doc_type, doc_id;
docinfo_string doc_dirname, doc_last_revision;
@@ -1367,14 +1428,49 @@
void phrase_to_string_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(phrase);
+
out.clear();
phrase.swap(out);
}
void phrase_to_docinfo_action::operator()(iterator first, iterator last) const
{
+ actions.output_pre(phrase);
+
out.encoded.clear();
phrase.swap(out.encoded);
out.raw = std::string(first, last);
}
+
+ void inner_phrase_action_pre::operator()(iterator, iterator) const
+ {
+ actions.saved_anchors.clear();
+ actions.saved_anchors.swap(actions.anchors);
+ }
+
+ void inner_phrase_action_post::operator()(iterator, iterator) const
+ {
+ actions.output_pre(actions.phrase);
+ }
+
+ void pre_output_action::operator()(collector& tgt) const
+ {
+ for(quickbook::actions::string_list::iterator
+ it = actions.anchors.begin(),
+ end = actions.anchors.end();
+ it != end; ++it)
+ {
+ tgt << "<anchor id=\"";
+ detail::print_string(*it, tgt.get());
+ tgt << "\"/>\n";
+ }
+
+ actions.anchors.clear();
+ }
+
+ void pre_output_action::operator()(iterator, iterator) const
+ {
+ (*this)(actions.out);
+ }
}
Modified: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp (original)
+++ trunk/tools/quickbook/src/actions.hpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -91,16 +91,19 @@
tagged_action(
collector& out,
std::string const& pre,
- std::string const& post)
+ std::string const& post,
+ quickbook::actions& actions)
: out(out)
, pre(pre)
- , post(post) {}
+ , post(post)
+ , actions(actions) {}
void operator()(std::string const&) const;
collector& out;
std::string pre;
std::string post;
+ quickbook::actions& actions;
};
struct phrase_action
@@ -112,11 +115,13 @@
collector& out,
collector& phrase,
std::string const& pre,
- std::string const& post)
+ std::string const& post,
+ quickbook::actions& actions)
: out(out)
, phrase(phrase)
, pre(pre)
- , post(post) {}
+ , post(post)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -124,6 +129,7 @@
collector& phrase;
std::string pre;
std::string post;
+ quickbook::actions& actions;
};
struct implicit_paragraph_action
@@ -135,11 +141,13 @@
collector& out,
collector& phrase,
std::string const& pre,
- std::string const& post)
+ std::string const& post,
+ quickbook::actions& actions)
: out(out)
, phrase(phrase)
, pre(pre)
- , post(post) {}
+ , post(post)
+ , actions(actions) {}
void operator()() const;
void operator()(iterator first, iterator last) const { (*this)(); }
@@ -148,6 +156,7 @@
collector& phrase;
std::string pre;
std::string post;
+ quickbook::actions& actions;
};
struct header_action
@@ -162,7 +171,8 @@
std::string const& section_id,
std::string const& qualified_section_id,
std::string const& pre,
- std::string const& post)
+ std::string const& post,
+ quickbook::actions& actions)
: out(out)
, phrase(phrase)
, element_id(element_id)
@@ -170,7 +180,8 @@
, section_id(section_id)
, qualified_section_id(qualified_section_id)
, pre(pre)
- , post(post) {}
+ , post(post)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -182,6 +193,7 @@
std::string const& qualified_section_id;
std::string pre;
std::string post;
+ quickbook::actions& actions;
};
struct generic_header_action
@@ -195,14 +207,16 @@
std::string const& library_id,
std::string const& section_id,
std::string const& qualified_section_id,
- int const& section_level)
+ int const& section_level,
+ quickbook::actions& actions)
: out(out)
, phrase(phrase)
, element_id(element_id)
, library_id(library_id)
, section_id(section_id)
, qualified_section_id(qualified_section_id)
- , section_level(section_level) {}
+ , section_level(section_level)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -213,6 +227,7 @@
std::string const& section_id;
std::string const& qualified_section_id;
int const& section_level;
+ quickbook::actions& actions;
};
struct simple_phrase_action
@@ -223,11 +238,13 @@
collector& out
, std::string const& pre
, std::string const& post
- , string_symbols const& macro)
+ , string_symbols const& macro
+ , quickbook::actions& actions)
: out(out)
, pre(pre)
, post(post)
- , macro(macro) {}
+ , macro(macro)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -235,6 +252,7 @@
std::string pre;
std::string post;
string_symbols const& macro;
+ quickbook::actions& actions;
};
struct cond_phrase_action_pre
@@ -244,16 +262,19 @@
cond_phrase_action_pre(
collector& out
, std::vector<bool>& conditions
- , string_symbols const& macro)
+ , string_symbols const& macro
+ , quickbook::actions& actions)
: out(out)
, conditions(conditions)
- , macro(macro) {}
+ , macro(macro)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
collector& out;
std::vector<bool>& conditions;
string_symbols const& macro;
+ quickbook::actions& actions;
};
struct cond_phrase_action_post
@@ -263,16 +284,19 @@
cond_phrase_action_post(
collector& out
, std::vector<bool>& conditions
- , string_symbols const& macro)
+ , string_symbols const& macro
+ , quickbook::actions& actions)
: out(out)
, conditions(conditions)
- , macro(macro) {}
+ , macro(macro)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
collector& out;
std::vector<bool>& conditions;
string_symbols const& macro;
+ quickbook::actions& actions;
};
struct list_action
@@ -284,11 +308,13 @@
collector& out
, collector& list_buffer
, int& list_indent
- , std::stack<mark_type>& list_marks)
+ , std::stack<mark_type>& list_marks
+ , quickbook::actions& actions)
: out(out)
, list_buffer(list_buffer)
, list_indent(list_indent)
- , list_marks(list_marks) {}
+ , list_marks(list_marks)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -296,6 +322,7 @@
collector& list_buffer;
int& list_indent;
std::stack<mark_type>& list_marks;
+ quickbook::actions& actions;
};
struct list_format_action
@@ -307,11 +334,13 @@
collector& out
, int& list_indent
, std::stack<mark_type>& list_marks
- , int& error_count)
+ , int& error_count
+ , quickbook::actions& actions)
: out(out)
, list_indent(list_indent)
, list_marks(list_marks)
- , error_count(error_count) {}
+ , error_count(error_count)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -319,6 +348,7 @@
int& list_indent;
std::stack<mark_type>& list_marks;
int& error_count;
+ quickbook::actions& actions;
};
struct span
@@ -350,12 +380,12 @@
{
// Handles anchors
- anchor_action(collector& out)
- : out(out) {}
+ anchor_action(quickbook::actions& actions)
+ : actions(actions) {}
void operator()(iterator first, iterator last) const;
- collector& out;
+ quickbook::actions& actions;
};
extern char const* quickbook_get_date;
@@ -365,11 +395,13 @@
{
// Handles macro substitutions
- do_macro_action(collector& phrase)
- : phrase(phrase) {}
+ do_macro_action(collector& phrase, quickbook::actions& actions)
+ : phrase(phrase)
+ , actions(actions) {}
void operator()(std::string const& str) const;
collector& phrase;
+ quickbook::actions& actions;
};
struct space
@@ -417,13 +449,15 @@
// Prints a single raw (unprocessed) char.
// Allows '<', '>'... etc.
- raw_char_action(collector& phrase)
- : phrase(phrase) {}
+ raw_char_action(collector& phrase, quickbook::actions& actions)
+ : phrase(phrase)
+ , actions(actions) {}
void operator()(char ch) const;
void operator()(iterator first, iterator /*last*/) const;
collector& phrase;
+ quickbook::actions& actions;
};
struct plain_char_action
@@ -431,21 +465,26 @@
// Prints a single plain char.
// Converts '<' to "<"... etc See utils.hpp
- plain_char_action(collector& phrase)
- : phrase(phrase) {}
+ plain_char_action(collector& phrase, quickbook::actions& actions)
+ : phrase(phrase)
+ , actions(actions) {}
void operator()(char ch) const;
void operator()(iterator first, iterator /*last*/) const;
collector& phrase;
+ quickbook::actions& actions;
};
struct escape_unicode_action
{
- escape_unicode_action(collector& phrase) : phrase(phrase) {}
+ escape_unicode_action(collector& phrase, quickbook::actions& actions)
+ : phrase(phrase)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
collector& phrase;
+ quickbook::actions& actions;
};
struct attribute_action
@@ -474,24 +513,30 @@
image_action(
collector& phrase
, attribute_map& attributes
- , std::string& image_fileref)
+ , std::string& image_fileref
+ , quickbook::actions& actions)
: phrase(phrase)
, attributes(attributes)
- , image_fileref(image_fileref) {}
+ , image_fileref(image_fileref)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
collector& phrase;
attribute_map& attributes;
std::string& image_fileref;
+ quickbook::actions& actions;
};
struct markup_action
{
// A generic markup action
- markup_action(collector& phrase, std::string const& str)
- : phrase(phrase), str(str) {}
+ markup_action(
+ collector& phrase,
+ std::string const& str,
+ quickbook::actions& actions)
+ : phrase(phrase), str(str), actions(actions) {}
template <typename T>
void operator()(T const&) const
@@ -507,6 +552,7 @@
collector& phrase;
std::string str;
+ quickbook::actions& actions;
};
struct code_action
@@ -551,12 +597,13 @@
{
// Handles line-breaks (DEPRECATED!!!)
- break_action(collector& phrase)
- : phrase(phrase) {}
+ break_action(collector& phrase, quickbook::actions& actions)
+ : phrase(phrase), actions(actions) {}
void operator()(iterator f, iterator) const;
collector& phrase;
+ quickbook::actions& actions;
};
struct macro_identifier_action
@@ -623,13 +670,17 @@
{
// Handles links (URL, XML refentry, function, class, member)
- link_action(collector& phrase, char const* tag)
- : phrase(phrase), tag(tag) {}
+ link_action(
+ collector& phrase,
+ char const* tag,
+ quickbook::actions& actions)
+ : phrase(phrase), tag(tag), actions(actions) {}
void operator()(iterator first, iterator last) const;
collector& phrase;
char const* tag;
+ quickbook::actions& actions;
};
struct variablelist_action
@@ -693,14 +744,16 @@
, std::string& section_id
, int& section_level
, std::string& qualified_section_id
- , std::string& element_id)
+ , std::string& element_id
+ , quickbook::actions& actions)
: out(out)
, phrase(phrase)
, library_id(library_id)
, section_id(section_id)
, section_level(section_level)
, qualified_section_id(qualified_section_id)
- , element_id(element_id) {}
+ , element_id(element_id)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -711,6 +764,7 @@
int& section_level;
std::string& qualified_section_id;
std::string& element_id;
+ quickbook::actions& actions;
};
struct end_section_action
@@ -720,12 +774,14 @@
, int& section_level
, int& min_section_level
, std::string& qualified_section_id
- , int& error_count)
+ , int& error_count
+ , quickbook::actions& actions)
: out(out)
, section_level(section_level)
, min_section_level(min_section_level)
, qualified_section_id(qualified_section_id)
- , error_count(error_count) {}
+ , error_count(error_count)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
@@ -734,6 +790,7 @@
int& min_section_level;
std::string& qualified_section_id;
int& error_count;
+ quickbook::actions& actions;
};
struct element_id_warning_action
@@ -805,25 +862,59 @@
struct phrase_to_string_action
{
- phrase_to_string_action(std::string& out, collector& phrase)
- : out(out) , phrase(phrase) {}
+ phrase_to_string_action(std::string& out, collector& phrase, quickbook::actions& actions)
+ : out(out) , phrase(phrase), actions(actions) {}
void operator()(iterator first, iterator last) const;
std::string& out;
collector& phrase;
+ quickbook::actions& actions;
};
struct phrase_to_docinfo_action
{
- phrase_to_docinfo_action(docinfo_string& out, collector& phrase)
+ phrase_to_docinfo_action(docinfo_string& out, collector& phrase, quickbook::actions& actions)
: out(out)
- , phrase(phrase) {}
+ , phrase(phrase)
+ , actions(actions) {}
void operator()(iterator first, iterator last) const;
docinfo_string& out;
collector& phrase;
+ quickbook::actions& actions;
+ };
+
+ struct inner_phrase_action_pre
+ {
+ inner_phrase_action_pre(quickbook::actions& actions)
+ : actions(actions) {}
+
+ void operator()(iterator, iterator) const;
+
+ quickbook::actions& actions;
+ };
+
+ struct inner_phrase_action_post
+ {
+ inner_phrase_action_post(quickbook::actions& actions)
+ : actions(actions) {}
+
+ void operator()(iterator, iterator) const;
+
+ quickbook::actions& actions;
+ };
+
+ struct pre_output_action
+ {
+ pre_output_action(quickbook::actions& actions)
+ : actions(actions) {}
+
+ void operator()(collector& tgt) const;
+ void operator()(iterator, iterator) const;
+
+ quickbook::actions& actions;
};
}
Modified: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp (original)
+++ trunk/tools/quickbook/src/actions_class.cpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -71,123 +71,128 @@
// actions
, error(error_count)
- , extract_doc_title(doc_title, phrase)
- , extract_doc_license(doc_license, phrase)
- , extract_doc_purpose(doc_purpose, phrase)
- , extract_doc_version(doc_version, phrase)
- , extract_doc_id(doc_id_tmp, phrase)
- , extract_doc_dirname(doc_dirname, phrase)
- , extract_copyright_second(copyright.second, phrase)
- , extract_name_second(name.second, phrase)
- , extract_name_first(name.first, phrase)
- , extract_doc_last_revision(doc_last_revision, phrase)
- , extract_doc_category(doc_category, phrase)
- , extract_doc_biblioid(doc_biblioid.second, phrase)
- , extract_doc_lang(doc_lang, phrase)
+ , extract_doc_title(doc_title, phrase, *this)
+ , extract_doc_license(doc_license, phrase, *this)
+ , extract_doc_purpose(doc_purpose, phrase, *this)
+ , extract_doc_version(doc_version, phrase, *this)
+ , extract_doc_id(doc_id_tmp, phrase, *this)
+ , extract_doc_dirname(doc_dirname, phrase, *this)
+ , extract_copyright_second(copyright.second, phrase, *this)
+ , extract_name_second(name.second, phrase, *this)
+ , extract_name_first(name.first, phrase, *this)
+ , extract_doc_last_revision(doc_last_revision, phrase, *this)
+ , extract_doc_category(doc_category, phrase, *this)
+ , extract_doc_biblioid(doc_biblioid.second, phrase, *this)
+ , extract_doc_lang(doc_lang, phrase, *this)
, code(out, phrase, *this)
, code_block(phrase, phrase, *this)
, inline_code(phrase, *this)
- , inside_paragraph(out, phrase, paragraph_pre, paragraph_post)
- , h(out, phrase, element_id, doc_id, section_id, qualified_section_id, section_level)
- , h1(out, phrase, element_id, doc_id, section_id, qualified_section_id, h1_pre, h1_post)
- , h2(out, phrase, element_id, doc_id, section_id, qualified_section_id, h2_pre, h2_post)
- , h3(out, phrase, element_id, doc_id, section_id, qualified_section_id, h3_pre, h3_post)
- , h4(out, phrase, element_id, doc_id, section_id, qualified_section_id, h4_pre, h4_post)
- , h5(out, phrase, element_id, doc_id, section_id, qualified_section_id, h5_pre, h5_post)
- , h6(out, phrase, element_id, doc_id, section_id, qualified_section_id, h6_pre, h6_post)
- , hr(out, hr_)
- , blurb(out, blurb_pre, blurb_post)
- , blockquote(out, blockquote_pre, blockquote_post)
- , preformatted(out, phrase, preformatted_pre, preformatted_post)
- , warning(out, warning_pre, warning_post)
- , caution(out, caution_pre, caution_post)
- , important(out, important_pre, important_post)
- , note(out, note_pre, note_post)
- , tip(out, tip_pre, tip_post)
- , plain_char(phrase)
- , raw_char(phrase)
- , escape_unicode(phrase)
+ , 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)
+ , hr(out, hr_, *this)
+ , blurb(out, blurb_pre, blurb_post, *this)
+ , blockquote(out, blockquote_pre, blockquote_post, *this)
+ , preformatted(out, phrase, preformatted_pre, preformatted_post, *this)
+ , warning(out, warning_pre, warning_post, *this)
+ , caution(out, caution_pre, caution_post, *this)
+ , important(out, important_pre, important_post, *this)
+ , note(out, note_pre, note_post, *this)
+ , tip(out, tip_pre, tip_post, *this)
+ , space_char(phrase)
+ , plain_char(phrase, *this)
+ , raw_char(phrase, *this)
+ , escape_unicode(phrase, *this)
, attribute(attributes, attribute_name, error_count)
- , image(phrase, attributes, image_fileref)
- , cond_phrase_pre(phrase, conditions, macro)
- , cond_phrase_post(phrase, conditions, macro)
-
- , list(out, list_buffer, list_indent, list_marks)
- , list_format(list_buffer, list_indent, list_marks, error_count)
- , list_item(list_buffer, phrase, list_item_pre, list_item_post)
-
- , funcref_pre(phrase, funcref_pre_)
- , funcref_post(phrase, funcref_post_)
- , classref_pre(phrase, classref_pre_)
- , classref_post(phrase, classref_post_)
- , memberref_pre(phrase, memberref_pre_)
- , memberref_post(phrase, memberref_post_)
- , enumref_pre(phrase, enumref_pre_)
- , enumref_post(phrase, enumref_post_)
- , macroref_pre(phrase, macroref_pre_)
- , macroref_post(phrase, macroref_post_)
- , headerref_pre(phrase, headerref_pre_)
- , headerref_post(phrase, headerref_post_)
- , conceptref_pre(phrase, conceptref_pre_)
- , conceptref_post(phrase, conceptref_post_)
- , globalref_pre(phrase, globalref_pre_)
- , globalref_post(phrase, globalref_post_)
-
- , bold_pre(phrase, bold_pre_)
- , bold_post(phrase, bold_post_)
- , italic_pre(phrase, italic_pre_)
- , italic_post(phrase, italic_post_)
- , underline_pre(phrase, underline_pre_)
- , underline_post(phrase, underline_post_)
- , teletype_pre(phrase, teletype_pre_)
- , teletype_post(phrase, teletype_post_)
- , strikethrough_pre(phrase, strikethrough_pre_)
- , strikethrough_post(phrase, strikethrough_post_)
- , quote_pre(phrase, quote_pre_)
- , quote_post(phrase, quote_post_)
- , replaceable_pre(phrase, replaceable_pre_)
- , replaceable_post(phrase, replaceable_post_)
- , footnote_pre(phrase, footnote_pre_)
- , footnote_post(phrase, footnote_post_)
-
- , simple_bold(phrase, bold_pre_, bold_post_, macro)
- , simple_italic(phrase, italic_pre_, italic_post_, macro)
- , simple_underline(phrase, underline_pre_, underline_post_, macro)
- , simple_teletype(phrase, teletype_pre_, teletype_post_, macro)
- , simple_strikethrough(phrase, strikethrough_pre_, strikethrough_post_, macro)
+ , image(phrase, attributes, image_fileref, *this)
+ , cond_phrase_pre(phrase, conditions, macro, *this)
+ , cond_phrase_post(phrase, conditions, macro, *this)
+
+ , list(out, list_buffer, list_indent, list_marks, *this)
+ , list_format(list_buffer, list_indent, list_marks, error_count, *this)
+ , list_item(list_buffer, phrase, list_item_pre, list_item_post, *this)
+
+ , funcref_pre(phrase, funcref_pre_, *this)
+ , funcref_post(phrase, funcref_post_, *this)
+ , classref_pre(phrase, classref_pre_, *this)
+ , classref_post(phrase, classref_post_, *this)
+ , memberref_pre(phrase, memberref_pre_, *this)
+ , memberref_post(phrase, memberref_post_, *this)
+ , enumref_pre(phrase, enumref_pre_, *this)
+ , enumref_post(phrase, enumref_post_, *this)
+ , macroref_pre(phrase, macroref_pre_, *this)
+ , macroref_post(phrase, macroref_post_, *this)
+ , headerref_pre(phrase, headerref_pre_, *this)
+ , headerref_post(phrase, headerref_post_, *this)
+ , conceptref_pre(phrase, conceptref_pre_, *this)
+ , conceptref_post(phrase, conceptref_post_, *this)
+ , globalref_pre(phrase, globalref_pre_, *this)
+ , globalref_post(phrase, globalref_post_, *this)
+
+ , bold_pre(phrase, bold_pre_, *this)
+ , bold_post(phrase, bold_post_, *this)
+ , italic_pre(phrase, italic_pre_, *this)
+ , italic_post(phrase, italic_post_, *this)
+ , underline_pre(phrase, underline_pre_, *this)
+ , underline_post(phrase, underline_post_, *this)
+ , teletype_pre(phrase, teletype_pre_, *this)
+ , teletype_post(phrase, teletype_post_, *this)
+ , strikethrough_pre(phrase, strikethrough_pre_, *this)
+ , strikethrough_post(phrase, strikethrough_post_, *this)
+ , quote_pre(phrase, quote_pre_, *this)
+ , quote_post(phrase, quote_post_, *this)
+ , replaceable_pre(phrase, replaceable_pre_, *this)
+ , replaceable_post(phrase, replaceable_post_, *this)
+ , footnote_pre(phrase, footnote_pre_, *this)
+ , footnote_post(phrase, footnote_post_, *this)
+
+ , simple_bold(phrase, bold_pre_, bold_post_, macro, *this)
+ , simple_italic(phrase, italic_pre_, italic_post_, macro, *this)
+ , simple_underline(phrase, underline_pre_, underline_post_, macro, *this)
+ , simple_teletype(phrase, teletype_pre_, teletype_post_, macro, *this)
+ , simple_strikethrough(phrase, strikethrough_pre_, strikethrough_post_, macro, *this)
, variablelist(*this)
- , start_varlistentry(phrase, start_varlistentry_)
- , end_varlistentry(phrase, end_varlistentry_)
- , start_varlistterm(phrase, start_varlistterm_)
- , end_varlistterm(phrase, end_varlistterm_)
- , varlistitem(phrase, start_varlistitem_, end_varlistitem_)
+ , start_varlistentry(phrase, start_varlistentry_, *this)
+ , end_varlistentry(phrase, end_varlistentry_, *this)
+ , start_varlistterm(phrase, start_varlistterm_, *this)
+ , end_varlistterm(phrase, end_varlistterm_, *this)
+ , varlistitem(phrase, start_varlistitem_, end_varlistitem_, *this)
- , break_(phrase)
+ , break_(phrase, *this)
, macro_identifier(*this)
, macro_definition(*this)
- , do_macro(phrase)
+ , do_macro(phrase, *this)
, template_body(*this)
, template_arg(*this)
, do_template(*this)
- , url_pre(phrase, url_pre_)
- , url_post(phrase, url_post_)
- , link_pre(phrase, link_pre_)
- , link_post(phrase, link_post_)
+ , url_pre(phrase, url_pre_, *this)
+ , url_post(phrase, url_post_, *this)
+ , link_pre(phrase, link_pre_, *this)
+ , link_post(phrase, link_post_, *this)
, table(*this)
, start_row(phrase, table_span, table_header)
- , end_row(phrase, end_row_)
+ , end_row(phrase, end_row_, *this)
, cell(phrase, table_span)
- , anchor(out)
+ , anchor(*this)
- , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id)
- , end_section(out, section_level, min_section_level, qualified_section_id, error_count)
+ , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id, *this)
+ , end_section(out, section_level, min_section_level, qualified_section_id, error_count, *this)
, xinclude(out, *this)
, include(*this)
, import(out, *this)
- , escape_pre(phrase, escape_pre_)
- , escape_post(phrase, escape_post_)
+ , escape_pre(phrase, escape_pre_, *this)
+ , escape_post(phrase, escape_post_, *this)
+
+ , inner_phrase_pre(*this)
+ , inner_phrase_post(*this)
+ , output_pre(*this)
{
// turn off __FILENAME__ macro on debug mode = true
std::string filename_str = debug_mode ?
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -115,6 +115,8 @@
std::string image_fileref;
std::string attribute_name;
attribute_map attributes;
+ string_list anchors;
+ string_list saved_anchors;
// push/pop the states and the streams
void copy_macros_for_write();
@@ -149,6 +151,7 @@
tagged_action blurb, blockquote;
phrase_action preformatted;
tagged_action warning, caution, important, note, tip;
+ space space_char;
plain_char_action plain_char;
raw_char_action raw_char;
escape_unicode_action escape_unicode;
@@ -234,6 +237,10 @@
markup_action escape_pre;
markup_action escape_post;
+
+ inner_phrase_action_pre inner_phrase_pre;
+ inner_phrase_action_post inner_phrase_post;
+ pre_output_action output_pre;
};
}
Modified: trunk/tools/quickbook/src/block_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_grammar.cpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -34,7 +34,7 @@
start_, blocks, block_markup, code, code_line, blank_line,
paragraph, space, blank, comment, headings, h, h1, h2,
h3, h4, h5, h6, hr, blurb, blockquote, admonition,
- phrase, list, phrase_end, ordered_list, def_macro,
+ inner_phrase, phrase, list, phrase_end, ordered_list, def_macro,
macro_identifier, table, table_row, variablelist,
varlistentry, varlistterm, varlistitem, table_cell,
preformatted, list_item, begin_section, end_section,
@@ -180,7 +180,7 @@
>> hard_space
>> element_id
>> space
- >> phrase [actions.begin_section]
+ >> inner_phrase [actions.begin_section]
;
end_section =
@@ -191,13 +191,13 @@
h1 | h2 | h3 | h4 | h5 | h6 | h
;
- h = "heading" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h];
- h1 = "h1" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h1];
- h2 = "h2" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h2];
- h3 = "h3" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h3];
- h4 = "h4" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h4];
- h5 = "h5" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h5];
- h6 = "h6" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h6];
+ h = "heading" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h];
+ h1 = "h1" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h1];
+ h2 = "h2" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h2];
+ h3 = "h3" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h3];
+ h4 = "h4" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h4];
+ h5 = "h5" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h5];
+ h6 = "h6" >> hard_space >> element_id_1_6 >> space >> inner_phrase [actions.h6];
static const bool true_ = true;
static const bool false_ = false;
@@ -297,7 +297,7 @@
"variablelist"
>> (cl::eps_p(*cl::blank_p >> cl::eol_p) | hard_space)
>> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)]
- >> +eol
+ >> (+eol) [actions.output_pre]
>> *varlistentry
>> cl::eps_p [actions.variablelist]
;
@@ -354,7 +354,7 @@
>> element_id_1_5
>> (cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
>> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)]
- >> +eol
+ >> (+eol) [actions.output_pre]
>> *table_row
>> cl::eps_p [actions.table]
;
@@ -464,13 +464,20 @@
paragraph =
+( common
- | (cl::anychar_p - // Make sure we don't go past
- paragraph_end // a single block.
- ) [actions.plain_char]
+ | (cl::eps_p - paragraph_end)
+ >> ( cl::space_p [actions.space_char]
+ | cl::anychar_p [actions.plain_char]
+ )
)
>> (cl::eps_p('[') | +eol)
;
+ inner_phrase =
+ cl::eps_p [actions.inner_phrase_pre]
+ >> phrase
+ >> cl::eps_p [actions.inner_phrase_post]
+ ;
+
phrase =
*( common
| comment
Modified: trunk/tools/quickbook/src/syntax_highlight.cpp
==============================================================================
--- trunk/tools/quickbook/src/syntax_highlight.cpp (original)
+++ trunk/tools/quickbook/src/syntax_highlight.cpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -53,17 +53,17 @@
// print the code with syntax coloring
if (source_mode == "c++")
{
- cpp_p_type cpp_p(temp, escape_actions.macro, do_macro_action(temp), escape_actions);
+ cpp_p_type cpp_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions);
boost::spirit::classic::parse(first, last, cpp_p);
}
else if (source_mode == "python")
{
- python_p_type python_p(temp, escape_actions.macro, do_macro_action(temp), escape_actions);
+ python_p_type python_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions);
boost::spirit::classic::parse(first, last, python_p);
}
else if (source_mode == "teletype")
{
- teletype_p_type teletype_p(temp, escape_actions.macro, do_macro_action(temp), escape_actions);
+ teletype_p_type teletype_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions);
boost::spirit::classic::parse(first, last, teletype_p);
}
else
Modified: trunk/tools/quickbook/src/syntax_highlight.hpp
==============================================================================
--- trunk/tools/quickbook/src/syntax_highlight.hpp (original)
+++ trunk/tools/quickbook/src/syntax_highlight.hpp 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -355,7 +355,7 @@
=
*( macro
| escape
- | cl::repeat_p(1)[cl::anychar_p] [CharProcess(self.out)]
+ | cl::repeat_p(1)[cl::anychar_p] [CharProcess(self.out, self.escape_actions)]
)
;
Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -56,6 +56,7 @@
[ quickbook-test xml-escape_1_5 ]
[ quickbook-test blocks ]
[ quickbook-test newline ]
+ [ quickbook-test anchor ]
[ quickbook-test command_line_macro : : : <quickbook-test-define>__macro__=*bold* ]
[ quickbook-fail-test fail-include ]
[ quickbook-fail-test fail-import ]
Added: trunk/tools/quickbook/test/anchor.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/anchor.gold 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="anchor_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Anchor Test</title>
+ <section id="anchor_test.anchors">
+ <title>Anchors</title>
+ <para>
+ <anchor id="a1"/> A paragraph containing several anchors. <anchor id="a2"/>
+ 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">
+ <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">
+ <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">
+ <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">
+ <link linkend="anchor_test.anchors.also_this_one">Also this one</link>
+ </bridgehead>
+ <anchor id="a7"/> <anchor id="anchors.finally_this"/>
+ <bridgehead renderas="sect3">
+ Finally this
+ </bridgehead>
+ <anchor id="a8"/>
+ </section>
+ <section id="anchor_test.section_anchor">
+ <anchor id="a8"/> <title>Section Anchor</title>
+ <section id="anchor_test.nested_section">
+ <title>Nested Section</title>
+ </section>
+ <anchor id="a9"/>
+ </section>
+</article>
Added: trunk/tools/quickbook/test/anchor.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/anchor.quickbook 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -0,0 +1,32 @@
+[article Anchor Test
+]
+
+[section Anchors]
+
+[#a1] A paragraph containing several anchors. [#a2] We want to make sure
+they appear in the correct place. [#a3]
+
+[heading This heading shouldn't pick up the previous anchor]
+
+[#a4]
+
+[heading This heading should pick up the previous anchor]
+
+[#a5]
+[heading And this one]
+
+[#a6][heading Also this one]
+
+[#a7][h3 Finally this]
+
+[#a8]
+
+[endsect]
+
+[#a8]
+[section Section Anchor]
+[section Nested Section]
+[endsect]
+[/ This anchor is invalid, I'm not sure what to do with it]
+[#a9]
+[endsect]
Modified: trunk/tools/quickbook/test/link.gold
==============================================================================
--- trunk/tools/quickbook/test/link.gold (original)
+++ trunk/tools/quickbook/test/link.gold 2010-12-19 08:26:55 EST (Sun, 19 Dec 2010)
@@ -3,18 +3,19 @@
<article id="link_tests" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Link tests</title>
<section id="link_tests.different_types_of_links">
- <title>Different types of links</title> <anchor id="link-id" />
+ <title>Different types of links</title>
<para>
<ulink url="http://www.boost.org/">http://www.boost.org/> <ulink url="http://www.boost.org/">Boost</ulink>
<link linkend="link-id">link-id</link> <link linkend="link-id">Link Text</link>
- <functionname alt="foo">foo</functionname> <functionname alt="foo">link text</functionname>
- <classname alt="foo">foo</classname> <classname alt="foo">link text</classname>
- <methodname alt="foo">foo</methodname> <methodname alt="foo">link text</methodname>
- <enumname alt="foo">foo</enumname> <enumname alt="foo">link text</enumname>
- <macroname alt="foo">foo</macroname> <macroname alt="foo">link text</macroname>
- <headername alt="foo">foo</headername> <headername alt="foo">link text</headername>
- <conceptname alt="foo">foo</conceptname> <conceptname alt="foo">link text</conceptname>
- <globalname alt="foo">foo</globalname> <globalname alt="foo">link text</globalname>
+ <anchor id="link-id"/> <functionname alt="foo">foo</functionname> <functionname
+ alt="foo">link text</functionname> <classname alt="foo">foo</classname> <classname
+ alt="foo">link text</classname> <methodname alt="foo">foo</methodname> <methodname
+ alt="foo">link text</methodname> <enumname alt="foo">foo</enumname> <enumname
+ alt="foo">link text</enumname> <macroname alt="foo">foo</macroname> <macroname
+ alt="foo">link text</macroname> <headername alt="foo">foo</headername> <headername
+ alt="foo">link text</headername> <conceptname alt="foo">foo</conceptname>
+ <conceptname alt="foo">link text</conceptname> <globalname alt="foo">foo</globalname>
+ <globalname alt="foo">link text</globalname>
</para>
</section>
<section id="link_tests.side_by_side_links">
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk