-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preprocessor: add ellipsis sanitiser
Some commands have long output that is largely uninteresting to the user. In such situations, it is typical to trim that output and "summarise" with '...'. The ellipsis sanitiser does just that. It takes an optional Start field which indicates from which line number the ellipsis should start. Preprocessor-No-Write-Cache: true Signed-off-by: Paul Jolly <[email protected]> Change-Id: Ia285f810eb880b2e9b09833d82ab3b91bd0710a9 Dispatch-Trailer: {"type":"trybot","CL":1176701,"patchset":7,"ref":"refs/changes/01/1176701/7","targetBranch":"alpha"}
- Loading branch information
Showing
4 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
internal/cmd/preprocessor/cmd/testdata/execute_ellipsis_sanitiser.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Ensure that the ellipsis sanitiser works. | ||
|
||
unquote content/dir/en.md | ||
|
||
# Run the preprocessor | ||
exec preprocessor execute | ||
|
||
# Verify that the target files matche the source contents | ||
cmp hugo/content/en/dir/index.md golden/hugo/content/en/dir/index.md | ||
|
||
-- hugo/.keep -- | ||
-- content/dir/site.cue -- | ||
package site | ||
|
||
content: dir: page: { | ||
leftDelim: "{{{" | ||
rightDelim: "}}}" | ||
|
||
sanitisers: [ | ||
{ | ||
kind: "ellipsisSanitiser" | ||
command: "seq 1 5" | ||
}, | ||
{ | ||
kind: "ellipsisSanitiser" | ||
start: 5 | ||
command: "seq 1 10" | ||
}, | ||
] | ||
} | ||
-- content/dir/en.md -- | ||
>--- | ||
>title: JSON Superset | ||
>--- | ||
> | ||
>{{{with script "en" "zero"}}} | ||
>seq 1 5 | ||
>{{{end}}} | ||
> | ||
>{{{with script "en" "five"}}} | ||
>seq 1 10 | ||
>{{{end}}} | ||
-- golden/hugo/content/en/dir/index.md -- | ||
--- | ||
title: JSON Superset | ||
--- | ||
|
||
```text { title="TERMINAL" codeToCopy="c2VxIDEgNQo=" } | ||
$ seq 1 5 | ||
... | ||
``` | ||
|
||
```text { title="TERMINAL" codeToCopy="c2VxIDEgMTAK" } | ||
$ seq 1 10 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
... | ||
``` |