11defmodule IEx.ANSIDocs do
22 @ moduledoc false
33
4+ @ bullets [ ?* , ?- ]
5+
46 @ doc """
57 Prints the head of the documentation (i.e. the function signature)
68 """
@@ -64,7 +66,7 @@ defmodule IEx.ANSIDocs do
6466 defp process ( [ line | rest ] , indent ) do
6567 { stripped , count } = strip_spaces ( line , 0 )
6668 case stripped do
67- "* " <> item ->
69+ << bullet , ?\s , item :: binary >> when bullet in @ bullets ->
6870 process_list ( item , rest , count , indent )
6971 _ ->
7072 process_text ( rest , [ line ] , indent , false )
@@ -117,7 +119,7 @@ defmodule IEx.ANSIDocs do
117119 end
118120 end
119121
120- defp process_list_next ( [ "* " <> _ | _ ] = rest , _count , _done , acc ) do
122+ defp process_list_next ( [ << bullet , ?\s , _ :: binary >> | _ ] = rest , _count , _done , acc ) when bullet in @ bullets do
121123 { Enum . reverse ( acc ) , rest , false }
122124 end
123125
@@ -129,7 +131,7 @@ defmodule IEx.ANSIDocs do
129131 { Enum . reverse ( acc ) , rest , done }
130132 end
131133
132- defp list_next ( "* " <> _ , 0 ) , do: :done
134+ defp list_next ( << bullet , ?\s , _ :: binary >> , 0 ) when bullet in @ bullets , do: :done
133135 defp list_next ( line , 0 ) , do: chop ( line , 2 )
134136 defp list_next ( " " <> line , acc ) , do: list_next ( line , acc - 1 )
135137 defp list_next ( line , _acc ) , do: line
@@ -151,7 +153,7 @@ defmodule IEx.ANSIDocs do
151153 defp process_text ( [ line | rest ] , para , indent , true ) do
152154 { stripped , count } = strip_spaces ( line , 0 )
153155 case stripped do
154- "* " <> item ->
156+ << bullet , ?\s , item :: binary >> when bullet in @ bullets ->
155157 write_text ( Enum . reverse ( para ) , indent , true )
156158 process_list ( item , rest , count , indent )
157159 _ ->
0 commit comments