@@ -603,6 +603,7 @@ defmodule ExUnit.DocTest do
603603
604604 @ iex_prompt [ "iex>" , "iex(" ]
605605 @ dot_prompt [ "...>" , "...(" ]
606+ @ fences [ "```" , "~~~" ]
606607
607608 defp adjust_indent ( lines , line_no , module ) do
608609 adjust_indent ( :text , lines , line_no , [ ] , 0 , module )
@@ -668,11 +669,11 @@ defmodule ExUnit.DocTest do
668669 stripped_line = strip_indent ( line , indent )
669670
670671 cond do
671- stripped_line == "" ->
672- adjusted_lines = [ { stripped_line , line_no } | adjusted_lines ]
672+ stripped_line == "" or String . starts_with? ( stripped_line , @ fences ) ->
673+ adjusted_lines = [ { "" , line_no } | adjusted_lines ]
673674 adjust_indent ( :text , rest , line_no + 1 , adjusted_lines , 0 , module )
674675
675- String . starts_with? ( String . trim_leading ( line ) , @ iex_prompt ) ->
676+ String . starts_with? ( String . trim_leading ( stripped_line ) , @ iex_prompt ) ->
676677 adjust_indent ( :prompt , [ line | rest ] , line_no , adjusted_lines , indent , module )
677678
678679 true ->
@@ -734,14 +735,8 @@ defmodule ExUnit.DocTest do
734735 defp test_started? ( { "iex>" <> _ , _ } ) , do: true
735736 defp test_started? ( _ ) , do: false
736737
737- defp test_finished? ( { line , _ } ) do
738- case line do
739- "" -> true
740- "```" <> _ -> true
741- "~~~" <> _ -> true
742- _ -> false
743- end
744- end
738+ defp test_finished? ( { "" , _ } ) , do: true
739+ defp test_finished? ( _ ) , do: false
745740
746741 defp extract_tests ( line_no , doc , module , fun_arity ) do
747742 { lines , last_line } =
0 commit comments