Skip to content

Commit 85cc1ef

Browse files
src/HtmlMaker.cpp: fixing a bug in formatting the html
1 parent ecf9408 commit 85cc1ef

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/HtmlMaker.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <algorithm>
2121
#include <chrono>
2222
#include <fstream>
23-
#include <sstream>
2423
#include <regex>
24+
#include <sstream>
2525

2626
void
2727
HtmlMaker::put_data(const std::string &placeholder, const std::string &data) {
@@ -41,11 +41,11 @@ HtmlMaker::put_data(const std::string &placeholder, const std::string &data) {
4141
void
4242
HtmlMaker::put_comment(std::string &comment_begin, std::string &comment_end,
4343
const bool done) {
44-
if (!done) { // put html comments if analysis was skipped
44+
if (!done) { // put html comments if analysis was skipped
4545
put_data(comment_begin, "<!--");
4646
put_data(comment_end, "-->");
4747
}
48-
else { // otherwise delete placeholder
48+
else { // otherwise delete placeholder
4949
put_data(comment_begin, "");
5050
put_data(comment_end, "");
5151
}
@@ -54,20 +54,22 @@ HtmlMaker::put_comment(std::string &comment_begin, std::string &comment_end,
5454
void
5555
HtmlMaker::put_file_details(const FalcoConfig &falco_config) {
5656
using namespace std::string_literals;
57-
static const auto left_tag = "\\{\\{"s;
58-
static const auto right_tag = "\\}\\}"s;
57+
static constexpr auto left_tag = "\\{\\{";
58+
static constexpr auto right_tag = "\\}\\}";
5959

60+
const auto filename_formatted = falco_config.filename_stripped;
6061
std::regex filename_re(left_tag + "filename"s + right_tag);
61-
std::regex_replace(html_boilerplate, filename_re,
62-
falco_config.filename_stripped);
62+
html_boilerplate =
63+
std::regex_replace(html_boilerplate, filename_re, filename_formatted);
6364

6465
using system_clock = std::chrono::system_clock;
6566
auto time_unformatted = system_clock::to_time_t(system_clock::now());
6667
std::string time_formatted = std::string(ctime(&time_unformatted));
6768

6869
std::regex date_re(left_tag + "date"s + right_tag);
69-
std::regex_replace(html_boilerplate, date_re, time_formatted);
70+
html_boilerplate =
71+
std::regex_replace(html_boilerplate, date_re, time_formatted);
7072

7173
std::regex version_re(left_tag + "version"s + right_tag);
72-
std::regex_replace(html_boilerplate, version_re, VERSION);
74+
html_boilerplate = std::regex_replace(html_boilerplate, version_re, VERSION);
7375
}

0 commit comments

Comments
 (0)