@@ -69,6 +69,18 @@ defmodule Reach.Visualize.Source do
6969
7070 def highlight_line ( _ , _ ) , do: nil
7171
72+ def highlight_line ( file , line , fallback ) when is_binary ( fallback ) do
73+ case highlight_line ( file , line ) do
74+ source when is_binary ( source ) ->
75+ if String . trim ( source ) == "" , do: highlight_fallback ( fallback , file ) , else: source
76+
77+ _missing_source ->
78+ highlight_fallback ( fallback , file )
79+ end
80+ end
81+
82+ def highlight_line ( file , line , _fallback ) , do: highlight_line ( file , line )
83+
7284 def highlight_lines ( file , from , to ) when is_binary ( file ) do
7385 case cached_file_lines ( file ) do
7486 nil ->
@@ -168,6 +180,10 @@ defmodule Reach.Visualize.Source do
168180 def source_file? ( nil ) , do: false
169181 def source_file? ( file ) , do: Path . extname ( file ) in @ source_extensions
170182
183+ defp highlight_fallback ( fallback , file ) do
184+ highlight_source ( fallback , lang_for_file ( file ) ) || escape_html ( fallback )
185+ end
186+
171187 defp escape_html ( source ) do
172188 source
173189 |> String . replace ( "&" , "&" )
0 commit comments