diff --git a/src/main.cpp b/src/main.cpp index f937f76..4e252ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,9 +111,18 @@ int main(int argc, char *argv[]) for (const auto &match : search::search(filepath, regex, opts)) { - cout << match.filepath << ", " << match.headline << ", " - << match.page << ": " << match.context.first - << match.text << match.context.second << '\n'; + cout << match.filepath; + if (!match.headline.empty()) + { + + cout << ", " << match.headline; + } + if (!match.page.empty()) + { + cout << ", " << match.page; + } + cout << ": " << match.context.first << match.text + << match.context.second << '\n'; } } }