Skip to content

Commit b40c22f

Browse files
authored
Merge pull request #341 from gpetiot/remove-trailing-spaces-empty-lines
Remove trailing whitespaces that were added to indent empty lines
2 parents d339056 + fd9967e commit b40c22f

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#### Fixed
1414

1515
- Fix accidental redirect of stderr to stdout (#343, @Leonidas-from-XIV)
16+
- Remove trailing whitespaces that were added to indent empty lines (#341, @gpetiot)
1617

1718
#### Removed
1819

lib/output.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ let dump ppf = function
2323
| `Output s -> Fmt.pf ppf "`Output %S" s
2424
| `Ellipsis -> Fmt.pf ppf "`Ellipsis"
2525

26-
let pp ?(pad = 0) ppf = function
26+
let pp ?(pad = 0) ?syntax ppf = function
27+
| `Output "" when syntax <> Some Syntax.Cram -> Fmt.pf ppf "\n"
2728
| `Output s -> Fmt.pf ppf "%a%s\n" pp_pad pad s
2829
| `Ellipsis -> Fmt.pf ppf "%a...\n" pp_pad pad
2930

lib/output.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ val merge : [ `Output of string ] list -> t list -> t list
2828
(** [merge output test] merges any [`Ellipsis] items from [test] into
2929
[output]. *)
3030

31-
val pp : ?pad:int -> t Fmt.t
31+
val pp : ?pad:int -> ?syntax:Syntax.t -> t Fmt.t
3232
(** [pp] is the pretty-printer for test outputs. [pad] is the size of
3333
the optional whitespace left-padding (by default it is 0). *)
3434

lib/test/mdx_test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ let run_cram_tests ?syntax t ?root ppf temp_file pad tests =
115115
| `Ellipsis -> Output.pp ~pad ppf `Ellipsis
116116
| `Output line ->
117117
let line = ansi_color_strip line in
118-
Output.pp ~pad ppf (`Output line))
118+
Output.pp ?syntax ~pad ppf (`Output line))
119119
output;
120120
Cram.pp_exit_code ~pad ppf n)
121121
tests;

test/bin/mdx-test/expect/empty-lines/test-case.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This shell block contains an empty line within a padded block:
55

66
```
77

8+
```sh
9+
$ echo "Hello..." && echo "" && echo "world!"
10+
```
11+
812
This toplevel block contains an empty line within a padded block:
913

1014
```ocaml

test/bin/mdx-test/expect/empty-lines/test-case.md.expected

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ This shell block contains an empty line within a padded block:
22

33
```sh
44
$ echo ''
5-
5+
6+
```
7+
8+
```sh
9+
$ echo "Hello..." && echo "" && echo "world!"
10+
Hello...
11+
12+
world!
613
```
714

815
This toplevel block contains an empty line within a padded block:

test/bin/mdx-test/misc/environment-variable-unset/test-case.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Environment variables can be unset in an shell and bash blocks.
77

88
```sh unset-VAR
99
$ echo $VAR
10-
10+
1111
```

0 commit comments

Comments
 (0)