Add prefix, suffix and text field to the commentLinks.
We are planning to deprecate html option for the commentLinks.
Most common usecase for raw html matches is to make links not extend
over token boundaries or to configure the text of the link. In order
to fill the gap in functionality we are adding prefix, suffix and text
fields. The generated link will look like this:
PREFIX<a href="LINK">TEXT</a>SUFFIX
Change-Id: I0ac43e39a7484dee59928958b52cf5602abcc366
Release-Notes: Add ability to specify prefix, suffix and text fields for commentLinks of type `link`.
Forward-Compatible: checked
Google-Bug-Id: b/216788721
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 46d07df..d7ea1de 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -1713,8 +1713,11 @@
link = "#/q/$1"
[commentlink "bugzilla"]
- match = "(bug\\s+#?)(\\d+)"
- link = http://bugs.example.com/show_bug.cgi?id=$2
+ match = "(^|\\s)(bug\\s+#?)(\\d+)($|\\s)"
+ link = http://bugs.example.com/show_bug.cgi?id=$3
+ prefix = $1
+ suffix = $4
+ text = $2$3
[commentlink "tracker"]
match = ([Bb]ug:\\s+)(\\d+)
@@ -1749,6 +1752,10 @@
be updated to match text formats.
+
A common pattern to match is `bug\\s+(\\d+)`.
++
+In order to better control the visual presentation of the link `prefix`,
+`suffix` and `text` is used. With the generated link html looking like:
+`prefix<a ...>text</a>suffix`.
[[commentlink.name.link]]commentlink.<name>.link::
+
@@ -1757,6 +1764,27 @@
+
The link property is used only when the html property is not present.
+[[commentlink.name.prefix]]commentlink.<name>.prefix::
++
+The text inserted before the link. Groups in the match expression may be
+accessed as `$'n'`.
++
+The link property is used only when the html property is not present.
+
+[[commentlink.name.suffix]]commentlink.<name>.suffix::
++
+The text inserted after the link. Groups in the match expression may be
+accessed as `$'n'`.
++
+The link property is used only when the html property is not present.
+
+[[commentlink.name.text]]commentlink.<name>.text::
++
+The text content of the link. Groups in the match expression may be
+accessed as `$'n'`.
++
+The link property is used only when the html property is not present.
+
[[commentlink.name.html]]commentlink.<name>.html::
+
HTML to replace the entire matched string with. If present,