@@ -230,6 +230,20 @@ void AppendWebSnippet(string url, string snippetKey)
230230 continue ;
231231 }
232232
233+ if ( SnippetKey . ExtractStartCommentWebSnippet ( line , out url , out snippetKey ) )
234+ {
235+ AppendWebSnippet ( url , snippetKey ) ;
236+
237+ index ++ ;
238+
239+ lines . RemoveUntil (
240+ index ,
241+ "<!-- endSnippet -->" ,
242+ relativePath ,
243+ line ) ;
244+ continue ;
245+ }
246+
233247 if ( line . Current . TrimStart ( ) == "<!-- toc -->" )
234248 {
235249 tocLine = line ;
@@ -302,34 +316,46 @@ void ProcessWebSnippetLine(Action<string> appendLine, List<MissingSnippet> missi
302316 {
303317 appendLine ( $ "<!-- web-snippet: { url } #{ snippetKey } -->") ;
304318 // Download file content
305- var ( success , content ) = Downloader . DownloadContent ( url ) . GetAwaiter ( ) . GetResult ( ) ;
306- if ( ! success || string . IsNullOrWhiteSpace ( content ) )
319+ try
307320 {
308- var missing = new MissingSnippet ( $ "{ url } #{ snippetKey } ", line . LineNumber , line . Path ) ;
309- missings . Add ( missing ) ;
310- appendLine ( "```" ) ;
311- appendLine ( $ "** Could not fetch or parse web-snippet '{ url } #{ snippetKey } ' **") ;
312- appendLine ( "```" ) ;
321+ var ( success , content ) = Downloader . DownloadContent ( url ) . GetAwaiter ( ) . GetResult ( ) ;
322+ if ( ! success || string . IsNullOrWhiteSpace ( content ) )
323+ {
324+ var missing = new MissingSnippet ( $ "{ url } #{ snippetKey } ", line . LineNumber , line . Path ) ;
325+ missings . Add ( missing ) ;
326+ appendLine ( "```" ) ;
327+ appendLine ( $ "** Could not fetch or parse web-snippet '{ url } #{ snippetKey } ' **") ;
328+ appendLine ( "```" ) ;
329+ appendLine ( "<!-- endSnippet -->" ) ;
330+ return ;
331+ }
332+ // Extract snippets from content
333+ using var reader = new StringReader ( content ) ;
334+ var snippets = FileSnippetExtractor . Read ( reader , url ) ;
335+ var found = snippets . FirstOrDefault ( _ => _ . Key == snippetKey ) ;
336+ if ( found == null )
337+ {
338+ var missing = new MissingSnippet ( $ "{ url } #{ snippetKey } ", line . LineNumber , line . Path ) ;
339+ missings . Add ( missing ) ;
340+ appendLine ( "```" ) ;
341+ appendLine ( $ "** Could not find snippet '{ snippetKey } ' in '{ url } ' **") ;
342+ appendLine ( "```" ) ;
343+ appendLine ( "<!-- endSnippet -->" ) ;
344+ return ;
345+ }
346+ appendSnippets ( snippetKey , [ found ] , appendLine ) ;
313347 appendLine ( "<!-- endSnippet -->" ) ;
314- return ;
348+ used . Add ( found ) ;
315349 }
316- // Extract snippets from content
317- using var reader = new StringReader ( content ) ;
318- var snippets = FileSnippetExtractor . Read ( reader , url ) ;
319- var found = snippets . FirstOrDefault ( _ => _ . Key == snippetKey ) ;
320- if ( found == null )
350+ catch
321351 {
322352 var missing = new MissingSnippet ( $ "{ url } #{ snippetKey } ", line . LineNumber , line . Path ) ;
323353 missings . Add ( missing ) ;
324354 appendLine ( "```" ) ;
325- appendLine ( $ "** Could not find snippet ' { snippetKey } ' in '{ url } ' **") ;
355+ appendLine ( $ "** Could not fetch or parse web-snippet '{ url } # { snippetKey } ' **") ;
326356 appendLine ( "```" ) ;
327357 appendLine ( "<!-- endSnippet -->" ) ;
328- return ;
329358 }
330- appendSnippets ( snippetKey , [ found ] , appendLine ) ;
331- appendLine ( "<!-- endSnippet -->" ) ;
332- used . Add ( found ) ;
333359 }
334360
335361 bool TryGetSnippets (
0 commit comments