|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63389 - trunk/tools/inspect
From: daniel_james_at_[hidden]
Date: 2010-06-27 12:39:38
Author: danieljames
Date: 2010-06-27 12:39:36 EDT (Sun, 27 Jun 2010)
New Revision: 63389
URL: http://svn.boost.org/trac/boost/changeset/63389
Log:
Don't complain about an id immediately followed by a name.
Some documentation uses markup of the form:
{{{
<div id="foo"><h1><a name="foo"></a>Foo</h1>
...
</div>
}}}
This was appearing as a duplicate bookmark, but it's valid. So allow an
`id` immediately followed by an identical `name`. Could allow some
problematic markup but it's the best I could come up with without
a html parser.
Text files modified:
trunk/tools/inspect/link_check.cpp | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
Modified: trunk/tools/inspect/link_check.cpp
==============================================================================
--- trunk/tools/inspect/link_check.cpp (original)
+++ trunk/tools/inspect/link_check.cpp 2010-06-27 12:39:36 EDT (Sun, 27 Jun 2010)
@@ -20,7 +20,7 @@
namespace
{
boost::regex html_bookmark_regex(
- "<([^\\s<>]*)\\s*[^<>]*\\s+(?:NAME|ID)\\s*=\\s*(['\"])(.*?)\\2"
+ "<([^\\s<>]*)\\s*[^<>]*\\s+(NAME|ID)\\s*=\\s*(['\"])(.*?)\\3"
"|<!--.*?-->",
boost::regbase::normal | boost::regbase::icase);
boost::regex html_url_regex(
@@ -149,20 +149,29 @@
if(!is_css(full_path))
{
+ string previous_id;
+
while( boost::regex_search( a_start, a_end, a_what, html_bookmark_regex, a_flags) )
{
// a_what[0] contains the whole string iterators.
// a_what[1] contains the tag iterators.
- // a_what[3] contains the bookmark iterators.
+ // a_what[2] contains the attribute name.
+ // a_what[4] contains the bookmark iterators.
- if (a_what[3].matched)
+ if (a_what[4].matched)
{
string tag( a_what[1].first, a_what[1].second );
boost::algorithm::to_lower(tag);
+ string attribute( a_what[2].first, a_what[2].second );
+ boost::algorithm::to_lower(attribute);
+ string bookmark( a_what[4].first, a_what[4].second );
+
+ bool name_following_id = ( attribute == "name" && previous_id == bookmark );
+ if ( tag != "meta" && attribute == "id" ) previous_id = bookmark;
+ else previous_id.clear();
- if ( tag != "meta" )
+ if ( tag != "meta" && !name_following_id )
{
- string bookmark( a_what[3].first, a_what[3].second );
bookmarks.insert( bookmark );
// std::cout << "******************* " << bookmark << '\n';
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