aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/hilite.hh
blob: 2d5cf7c6fed4bf9c5e62aa3d52fc2d3955e57bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
///@file

#include <regex>
#include <vector>
#include <string>

namespace nix {

/**
 * Highlight all the given matches in the given string `s` by wrapping
 * them between `prefix` and `postfix`.
 *
 * If some matches overlap, then their union will be wrapped rather
 * than the individual matches.
 */
std::string hiliteMatches(
    std::string_view s,
    std::vector<std::smatch> matches,
    std::string_view prefix,
    std::string_view postfix);

}