Escape Markdown table cell values in compliance page template
Pipe characters and newlines in dynamic values break Markdown table structure. Add a cell template function that escapes these characters. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -12,29 +12,29 @@
|
|||||||
|
|
||||||
| Title | Type |
|
| Title | Type |
|
||||||
|-------|------|
|
|-------|------|
|
||||||
{{ range .Documents }}| {{ .Title }} | {{ .Type }} |
|
{{ range .Documents }}| {{ cell .Title }} | {{ cell .Type }} |
|
||||||
{{ end }}{{ end }}{{ if .Audits }}
|
{{ end }}{{ end }}{{ if .Audits }}
|
||||||
## Audits
|
## Audits
|
||||||
|
|
||||||
| Name | Framework | Valid From | Valid Until |
|
| Name | Framework | Valid From | Valid Until |
|
||||||
|------|-----------|------------|-------------|
|
|------|-----------|------------|-------------|
|
||||||
{{ range .Audits }}| {{ .Name }} | {{ .Framework }} | {{ .ValidFrom }} | {{ .ValidUntil }} |
|
{{ range .Audits }}| {{ cell .Name }} | {{ cell .Framework }} | {{ .ValidFrom }} | {{ .ValidUntil }} |
|
||||||
{{ end }}{{ end }}{{ if .Vendors }}
|
{{ end }}{{ end }}{{ if .Vendors }}
|
||||||
## Subprocessors
|
## Subprocessors
|
||||||
|
|
||||||
| Name | Category | Countries | Website |
|
| Name | Category | Countries | Website |
|
||||||
|------|----------|-----------|---------|
|
|------|----------|-----------|---------|
|
||||||
{{ range .Vendors }}| {{ .Name }} | {{ .Category }} | {{ .Countries }} | {{ .Website }} |
|
{{ range .Vendors }}| {{ cell .Name }} | {{ cell .Category }} | {{ cell .Countries }} | {{ cell .Website }} |
|
||||||
{{ end }}{{ end }}{{ if .References }}
|
{{ end }}{{ end }}{{ if .References }}
|
||||||
## References
|
## References
|
||||||
|
|
||||||
| Name | Description | Website |
|
| Name | Description | Website |
|
||||||
|------|-------------|---------|
|
|------|-------------|---------|
|
||||||
{{ range .References }}| {{ .Name }} | {{ .Description }} | {{ .Website }} |
|
{{ range .References }}| {{ cell .Name }} | {{ cell .Description }} | {{ cell .Website }} |
|
||||||
{{ end }}{{ end }}{{ if .ExternalLinks }}
|
{{ end }}{{ end }}{{ if .ExternalLinks }}
|
||||||
## External Links
|
## External Links
|
||||||
|
|
||||||
| Name | URL |
|
| Name | URL |
|
||||||
|------|-----|
|
|------|-----|
|
||||||
{{ range .ExternalLinks }}| {{ .Name }} | {{ .URL }} |
|
{{ range .ExternalLinks }}| {{ cell .Name }} | {{ cell .URL }} |
|
||||||
{{ end }}{{ end }}
|
{{ end }}{{ end }}
|
||||||
@@ -31,7 +31,18 @@ import (
|
|||||||
//go:embed compliance.md.tmpl
|
//go:embed compliance.md.tmpl
|
||||||
var complianceTmplContent string
|
var complianceTmplContent string
|
||||||
|
|
||||||
var complianceTmpl = template.Must(template.New("compliance").Parse(complianceTmplContent))
|
var complianceTmpl = template.Must(
|
||||||
|
template.New("compliance").
|
||||||
|
Funcs(template.FuncMap{
|
||||||
|
"cell": func(s string) string {
|
||||||
|
s = strings.ReplaceAll(s, `|`, `\|`)
|
||||||
|
s = strings.ReplaceAll(s, "\n", " ")
|
||||||
|
s = strings.ReplaceAll(s, "\r", "")
|
||||||
|
return s
|
||||||
|
},
|
||||||
|
}).
|
||||||
|
Parse(complianceTmplContent),
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
compliancePageData struct {
|
compliancePageData struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user