@@ -270,7 +270,7 @@ defmodule Code.Formatter do
270270 { doc , state } =
271271 entries
272272 |> prepend_heredoc_line ( )
273- |> interpolation_to_algebra ( :heredoc , state , @ double_heredoc , @ double_heredoc )
273+ |> interpolation_to_algebra ( ~s [ """ ] , state , @ double_heredoc , @ double_heredoc )
274274
275275 { force_unfit ( doc ) , state }
276276
@@ -292,7 +292,7 @@ defmodule Code.Formatter do
292292 { doc , state } =
293293 entries
294294 |> prepend_heredoc_line ( )
295- |> list_interpolation_to_algebra ( :heredoc , state , @ single_heredoc , @ single_heredoc )
295+ |> list_interpolation_to_algebra ( ~s [ ''' ] , state , @ single_heredoc , @ single_heredoc )
296296
297297 { force_unfit ( doc ) , state }
298298
@@ -355,7 +355,7 @@ defmodule Code.Formatter do
355355 defp quoted_to_algebra ( { :__block__ , meta , [ list ] } , _context , state ) when is_list ( list ) do
356356 case meta [ :delimiter ] do
357357 ~s[ '''] ->
358- string = list |> List . to_string ( ) |> escape_heredoc ( )
358+ string = list |> List . to_string ( ) |> escape_heredoc ( ~s [ ''' ] )
359359 { @ single_heredoc |> concat ( string ) |> concat ( @ single_heredoc ) |> force_unfit ( ) , state }
360360
361361 ~s[ '] ->
@@ -369,7 +369,7 @@ defmodule Code.Formatter do
369369
370370 defp quoted_to_algebra ( { :__block__ , meta , [ string ] } , _context , state ) when is_binary ( string ) do
371371 if meta [ :delimiter ] == ~s[ """] do
372- string = escape_heredoc ( string )
372+ string = escape_heredoc ( string , ~s [ """ ] )
373373 { @ double_heredoc |> concat ( string ) |> concat ( @ double_heredoc ) |> force_unfit ( ) , state }
374374 else
375375 string = escape_string ( string , @ double_quote )
@@ -1339,7 +1339,7 @@ defmodule Code.Formatter do
13391339 { doc , state } =
13401340 entries
13411341 |> prepend_heredoc_line ( )
1342- |> interpolation_to_algebra ( :heredoc , state , doc , closing_delimiter )
1342+ |> interpolation_to_algebra ( opening_delimiter , state , doc , closing_delimiter )
13431343
13441344 { force_unfit ( doc ) , state }
13451345 else
@@ -1548,11 +1548,13 @@ defmodule Code.Formatter do
15481548 end
15491549 end
15501550
1551- defp escape_heredoc ( string ) do
1551+ defp escape_heredoc ( string , escape ) do
1552+ string = String . replace ( string , escape , "\\ " <> escape )
15521553 heredoc_to_algebra ( [ "" | String . split ( string , "\n " ) ] )
15531554 end
15541555
1555- defp escape_string ( string , :heredoc ) do
1556+ defp escape_string ( string , << _ , _ , _ >> = escape ) do
1557+ string = String . replace ( string , escape , "\\ " <> escape )
15561558 heredoc_to_algebra ( String . split ( string , "\n " ) )
15571559 end
15581560
0 commit comments