Skip to content

Commit 1876660

Browse files
committed
Add hyperlinks for LFTS sections
1 parent 4496720 commit 1876660

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/sections.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,31 @@ auto lwg::format_section_tag_as_link(section_map & section_db, section_tag const
177177
std::ostringstream o;
178178
const auto& num = section_db[tag];
179179
o << num << ' ';
180-
if(num.num.empty() || num.num.front() == 99 || !tag.prefix.empty()) {
181-
o << tag;
180+
std::string url;
181+
if (!tag.prefix.empty()) {
182+
std::string_view fund_ts = "fund.ts";
183+
if (tag.prefix.compare(0, fund_ts.size(), fund_ts) == 0) {
184+
std::string_view version = tag.prefix;
185+
version.remove_prefix(fund_ts.size());
186+
if (version.empty())
187+
version = "v1";
188+
else // Should be in the form "fund.ts.v2"
189+
version.remove_prefix(1);
190+
assert(version.size() == 2 && version[0] == 'v');
191+
url = "https://cplusplus.github.io/fundamentals-ts/";
192+
url += version;
193+
url += ".html#";
194+
url += tag.name;
195+
}
182196
}
183-
else {
184-
o << "<a href=\"https://wg21.link/" << tag.name << "\">[" << tag.name << "]</a>";
197+
else if (!num.num.empty() && num.num.front() != 99) {
198+
url = "https://wg21.link/" + tag.name;
185199
}
200+
201+
if (url.empty())
202+
o << tag;
203+
else
204+
o << "<a href=\"" << url << "\">" << tag << "</a>";
186205
return o.str();
187206
}
188207

0 commit comments

Comments
 (0)