package org.optaplanner.benchmark.impl.report;

public class ReportHelper {

    /**
     * Escape illegal HTML element id characters, such as a dot.
     * <p/>
     * This escape function guarantees that 2 distinct strings will result into 2 distinct escape strings
     * (presuming that both have been escaped by this method).
     * @param rawHtmlId never null
     * @return never null
     */
    public static String escapeHtmlId(String rawHtmlId) {
        return rawHtmlId
                .replaceAll("-", "--") // make '-' the escape character
                .replaceAll("\\.", "-d")
                .replaceAll(":", "-c")
                .replaceAll(";", "-s")
                .replaceAll("\\$", "-m");
    }

}

@@ -451,16 +451,132 @@
 mlId) %7B%0A
+        // Uses unicode numbers to escape, see http://unicode-table.com%0A        // Uses '-' as the escape character%0A
         
@@ -625,89 +625,362 @@
 ll(%22
--
+ 
 %22, %22-
--%22) // make '-' the escape character%0A                .replaceAll(%22%5C%5C.
+0020%22)%0A                .replaceAll(%22!%22, %22-0021%22)%0A                .replaceAll(%22#%22, %22-0023%22)%0A                .replaceAll(%22%5C%5C$%22, %22-0024%22)%0A                .replaceAll(%22,%22, %22-002C%22)%0A                .replaceAll(%22-%22, %22-002D%22)%0A                .replaceAll(%22%5C%5C.%22, %22-002E%22)%0A                .replaceAll(%22%5C%5C(%22, %22-0028%22)%0A                .replaceAll(%22%5C%5C)
 %22, %22-
-d
+0029
 %22)%0A 
@@ -1013,17 +1013,20 @@
 (%22:%22, %22-
-c
+003A
 %22)%0A     
@@ -1055,17 +1055,20 @@
 (%22;%22, %22-
-s
+003B
 %22)%0A     
@@ -1097,15 +1097,18 @@
 (%22%5C%5C
-$
+?
 %22, %22-
-m
+003F
 %22);%0A

Improve escapeHtmlId with unicode escape numbers and space and ()