@@ -33,23 +33,20 @@ if (!res.ok) {
3333 throw new Error (` [GitHubCode] Received ${res .status } from Worker. ` );
3434}
3535
36- let content = await res .text ();
36+ const content = await res .text ();
37+ let contentLines = content .split (" \n " );
3738
3839if (lines ) {
3940 const [start, end] = lines ;
4041
41- const contentLines = content .split (" \n " );
42-
4342 if (contentLines .length < end - 1 ) {
4443 throw new Error (
4544 ` [GitHubCode] End line requested is beyond content length (${contentLines .length }). ` ,
4645 );
4746 }
4847
49- content = contentLines .slice (start - 1 , end ). join ( " \n " );
48+ contentLines = contentLines .slice (start - 1 , end );
5049} else if (tag ) {
51- const contentLines = content .split (" \n " );
52-
5350 const startTag = contentLines .findIndex ((x ) =>
5451 x .includes (` <docs-tag name="${tag }"> ` ),
5552 );
@@ -61,8 +58,12 @@ if (lines) {
6158 throw new Error (` [GitHubCode] Unable to find a region using tag "${tag }". ` );
6259 }
6360
64- content = contentLines .slice (startTag + 1 , endTag ). join ( " \n " );
61+ contentLines = contentLines .slice (startTag + 1 , endTag );
6562}
63+
64+ contentLines = contentLines .filter (
65+ (line ) => ! / <[\/ ] ? docs-tag name=". * ">/ .test (line ),
66+ );
6667---
6768
68- <Code code ={ content } lang ={ lang } />
69+ <Code code ={ contentLines . join ( " \n " ) } lang ={ lang } />
0 commit comments