Skip to content

Commit

Permalink
fix: remove end of line prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Max Große <max12.gro@gmail.com>
  • Loading branch information
maxRN committed Jul 29, 2024
1 parent 9e2f686 commit 8862885
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/dune_sexp/decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,19 @@ let until_keyword =
fun kwd ~before ~after -> loop kwd before after []
;;

let plain_string_of_block_string bs =
String.split bs ~on:'\n'
|> List.map ~f:(fun line ->
match String.length line with
| 0 -> line
| _ as length -> String.sub line ~pos:4 ~len:(length - 4))
|> String.concat ~sep:"\n"
;;

let plain_string f =
next (function
| Atom (loc, A s) | Quoted_string (loc, s) | Block_string (loc, s) -> f ~loc s
| Atom (loc, A s) | Quoted_string (loc, s) -> f ~loc s
| Block_string (loc, s) -> f ~loc (plain_string_of_block_string s)
| Template { loc; _ } | List (loc, _) ->
User_error.raise ~loc [ Pp.text "Atom or quoted string expected" ])
;;
Expand Down

0 comments on commit 8862885

Please sign in to comment.