Skip to content

Commit

Permalink
Fix pathing in markdown documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreese committed Jul 31, 2020
1 parent 875d272 commit 3a7a895
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/commands/document.go
Expand Up @@ -181,6 +181,10 @@ func getDocumentation(path string, severity string, outputDirectory string) ([]D
}
relDir := filepath.Dir(relPath)

// Markdown specification notes that all pathing should be represented
// with a forward slash.
relDir = strings.ReplaceAll(relDir, string(os.PathSeparator), "/")

regoWithoutComments := getRegoWithoutComments(policy.Contents)

document := Document{
Expand Down
3 changes: 3 additions & 0 deletions internal/rego/rego.go
Expand Up @@ -185,6 +185,9 @@ func readFilesContents(filePaths []string) (map[string]string, error) {
return nil, fmt.Errorf("read file: %w", err)
}

// Many YAML parsers do not like rendering out CRLF when writing the YAML to disk.
// This causes ConstraintTemplates to be rendered with the line breaks as text,
// rather than the actual line break.
filesContents[filePath] = strings.ReplaceAll(string(data), "\r", "")
}

Expand Down

0 comments on commit 3a7a895

Please sign in to comment.