Show stage labels as literal Markdown text
This commit is contained in:
@@ -48,11 +48,11 @@ func Markdown(snapshot Snapshot, secrets ...string) []byte {
|
||||
|
||||
fmt.Fprintln(&b, "## Work-unit errors")
|
||||
fmt.Fprintln(&b)
|
||||
writeMatrix(&b, snapshot, safe, false)
|
||||
writeMatrix(&b, snapshot, r, false)
|
||||
fmt.Fprintln(&b)
|
||||
fmt.Fprintln(&b, "## Recoveries")
|
||||
fmt.Fprintln(&b)
|
||||
writeMatrix(&b, snapshot, safe, true)
|
||||
writeMatrix(&b, snapshot, r, true)
|
||||
fmt.Fprintln(&b)
|
||||
fmt.Fprintln(&b, "Legend: `—` = not started; `n*` = interrupted with n recorded errors or recoveries. Completed error cells are 0 or 1.")
|
||||
fmt.Fprintln(&b)
|
||||
@@ -71,7 +71,7 @@ func showCount(value *int) string {
|
||||
return fmt.Sprint(*value)
|
||||
}
|
||||
|
||||
func writeMatrix(b *strings.Builder, snapshot Snapshot, safe func(string) string, recovery bool) {
|
||||
func writeMatrix(b *strings.Builder, snapshot Snapshot, redactor redaction.Redactor, recovery bool) {
|
||||
if len(snapshot.StageNames) == 0 || len(snapshot.WorkUnits) == 0 {
|
||||
fmt.Fprintln(b, "No work units.")
|
||||
return
|
||||
@@ -79,7 +79,7 @@ func writeMatrix(b *strings.Builder, snapshot Snapshot, safe func(string) string
|
||||
columns := snapshot.StageNames
|
||||
fmt.Fprint(b, "| Chunk |")
|
||||
for _, name := range columns {
|
||||
fmt.Fprintf(b, " %s |", safe(name))
|
||||
fmt.Fprintf(b, " %s |", stageCellEscaper.Replace(html.EscapeString(redactor.String(name))))
|
||||
}
|
||||
fmt.Fprint(b, "\n| --- |")
|
||||
for range columns {
|
||||
@@ -120,6 +120,14 @@ func writeMatrix(b *strings.Builder, snapshot Snapshot, safe func(string) string
|
||||
}
|
||||
}
|
||||
|
||||
// Encode input backslashes so they cannot interfere with Markdown escapes.
|
||||
var stageCellEscaper = strings.NewReplacer(
|
||||
"\r\n", "<br>", "\r", "<br>", "\n", "<br>",
|
||||
"\\", "\", "|", "\\|", "`", "\\`",
|
||||
"[", "\\[", "]", "\\]", "*", "\\*", "_", "\\_", "~", "\\~",
|
||||
"://", "://", "www.", "www.", "@", "@",
|
||||
)
|
||||
|
||||
func writeReasons(b *strings.Builder, title string, counts map[string]int, safe func(string) string) {
|
||||
fmt.Fprintf(b, "### %s\n\n", title)
|
||||
if len(counts) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user