diff --git a/build/cheatsheet.md b/build/cheatsheet.md
index 21d8787..1fabce6 100644
--- a/build/cheatsheet.md
+++ b/build/cheatsheet.md
@@ -22,8 +22,7 @@ Complete rules assign a single value.
-Input:
-```json
+```json title="input.json"
{
"user": {
"role": "admin",
@@ -60,8 +59,7 @@ Partial rules generate and assign a set of values to a variable. ([Try It](https
-Input:
-```json
+```json title="input.json"
{
"user": {
"teams": [
@@ -70,7 +68,6 @@ Input:
]
}
}
-
```
@@ -127,8 +124,7 @@ Check conditions on many elements. ([Try It](https://play.openpolicyagent.org/?s
-Input:
-```json
+```json title="input.json"
{
"userID": "u123",
"paths": [
@@ -164,8 +160,7 @@ Statements in rules are joined with logical AND. ([Try It](https://play.openpoli
-Input:
-```json
+```json title="input.json"
{
"email": "joe@example.com"
}
@@ -193,8 +188,7 @@ Express OR with multiple rules, functions or the in keyword. ([Try It](https://p
-Input:
-```json
+```json title="input.json"
{
"email": "opa@example.com",
"name": "anna",
diff --git a/main.go b/main.go
index bb1a20d..720d56a 100644
--- a/main.go
+++ b/main.go
@@ -180,7 +180,11 @@ func main() {
panic(err)
}
- mdTemplate, err := template.New("md").Parse(string(mdTemplateBs))
+ mdTemplate, err := template.New("md").
+ Funcs(template.FuncMap{
+ "trim": strings.TrimSpace,
+ }).
+ Parse(string(mdTemplateBs))
if err != nil {
panic(err)
}
diff --git a/templates/doc.md b/templates/doc.md
index 17dadbc..07cc2f5 100644
--- a/templates/doc.md
+++ b/templates/doc.md
@@ -23,9 +23,8 @@ import rego.v1
{{ end }}
{{ if ne .Input "" }}
-Input:
-```json
-{{ .Input }}
+```json title="input.json"
+{{ .Input | trim }}
```
{{ end }}