Replaced more characters for tag anchors, prepend t_ to tag anchors.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-05-20 12:45:58 +02:00
parent 32040c277c
commit 02aae04cf5
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 13 additions and 9 deletions

View File

@ -54,7 +54,7 @@ void export_adoc(const vector<Database::entry> &entries, ostream &out)
out << "== " << day << endl << endl; out << "== " << day << endl << endl;
} }
out << "[[dt" << datetime << "]]\n"; out << "[[dt_" << datetime << "]]\n";
out << ".link:" << entry.uri; out << ".link:" << entry.uri;
if (!entry.title.empty()) if (!entry.title.empty())
{ {
@ -95,7 +95,7 @@ void export_adoc(const vector<Database::entry> &entries, ostream &out)
alltags.insert({ tag, { entry } }); alltags.insert({ tag, { entry } });
} }
out << "xref:" << replace_in_tags(tag) << "[" << tag << ']'; out << "xref:t_" << replace_in_tags(tag) << "[" << tag << ']';
if (tag != *(entry.tags.rbegin())) if (tag != *(entry.tags.rbegin()))
{ {
out << ", "; out << ", ";
@ -143,11 +143,11 @@ void export_adoc(const vector<Database::entry> &entries, ostream &out)
for (const auto &tag : sortedtags) for (const auto &tag : sortedtags)
{ {
out << "=== [[" << replace_in_tags(tag.first) << "]]" out << "=== [[t_" << replace_in_tags(tag.first) << "]]"
<< tag.first << endl; << tag.first << endl;
for (const Database::entry &entry : tag.second) for (const Database::entry &entry : tag.second)
{ {
out << endl << "* xref:dt" out << endl << "* xref:dt_"
<< timepoint_to_string(entry.datetime) << timepoint_to_string(entry.datetime)
<< '[' << entry.title << ']' << endl; << '[' << entry.title << ']' << endl;
} }
@ -166,7 +166,11 @@ const string replace_in_tags(string text)
// TODO: Find a better solution. // TODO: Find a better solution.
const std::map<const string, const string> searchreplace = const std::map<const string, const string> searchreplace =
{ {
{ " ", "-" }, { " ", "-" }, { "§", "-" },
{ "$", "-" }, { "%", "-" },
{ "&", "-" }, { "/", "-" },
{ "=", "-" }, { "^", "-" },
{ "!", "-" }, { "?", "-" },
{ "", "0" }, { "", "0" }, { "", "0" }, { "", "0" },
{ "", "1" }, { "¹", "1" }, { "", "1" }, { "¹", "1" },
{ "", "2" }, { "²", "2" }, { "", "2" }, { "²", "2" },

View File

@ -57,15 +57,15 @@ SCENARIO ("The AsciiDoc export works correctly")
":TOC: +right\n\n"); ":TOC: +right\n\n");
const regex re_dates const regex re_dates
("== 1970-01-01\n\n" ("== 1970-01-01\n\n"
"\\[\\[dt1970-01-01T\\d{2}:\\d{2}:\\d{2}\\]\\]\n" "\\[\\[dt_1970-01-01T\\d{2}:\\d{2}:\\d{2}\\]\\]\n"
"\\.link:https://example\\.com/page\\.html\\[Nice title\\]\n" "\\.link:https://example\\.com/page\\.html\\[Nice title\\]\n"
"_\\d{2}:\\d{2}:\\d{2}_\n" "_\\d{2}:\\d{2}:\\d{2}_\n"
"| xref:tag1\\[tag1\\], xref:tag2\\[tag2\\]\n\n" "| xref:t_tag1\\[tag1\\], xref:t_tag2\\[tag2\\]\n\n"
"Good description\\.\n"); "Good description\\.\n");
const regex re_tags const regex re_tags
("== Tags\n\n" ("== Tags\n\n"
"=== \\[\\[tag1\\]\\]tag1\n\n" "=== \\[\\[t_tag1\\]\\]tag1\n\n"
"\\* xref:dt1970-01-01T\\d{2}:\\d{2}:\\d{2}" "\\* xref:dt_1970-01-01T\\d{2}:\\d{2}:\\d{2}"
"\\[Nice title\\]\n\n"); "\\[Nice title\\]\n\n");
for (const regex &re : { re_header, re_dates, re_tags }) for (const regex &re : { re_header, re_dates, re_tags })