@@ -6,13 +6,19 @@ import { convertNonPrintableChars } from '../text-utils';
66import { RemoteQuery } from './remote-query' ;
77import { AnalysisAlert , AnalysisRawResults , AnalysisResults , CodeSnippet , FileLink , getAnalysisResultCount , HighlightedRegion } from './shared/analysis-result' ;
88
9+ export type MarkdownLinkType = 'local' | 'gist' ;
10+
911// Each array item is a line of the markdown file.
1012export type MarkdownFile = string [ ] ;
1113
1214/**
1315 * Generates markdown files with variant analysis results.
1416 */
15- export function generateMarkdown ( query : RemoteQuery , analysesResults : AnalysisResults [ ] ) : MarkdownFile [ ] {
17+ export function generateMarkdown (
18+ query : RemoteQuery ,
19+ analysesResults : AnalysisResults [ ] ,
20+ linkType : MarkdownLinkType
21+ ) : MarkdownFile [ ] {
1622 const files : MarkdownFile [ ] = [ ] ;
1723 // Generate summary file with links to individual files
1824 const summaryLines : MarkdownFile = generateMarkdownSummary ( query ) ;
@@ -24,7 +30,7 @@ export function generateMarkdown(query: RemoteQuery, analysesResults: AnalysisRe
2430
2531 // Append nwo and results count to the summary table
2632 const nwo = analysisResult . nwo ;
27- const link = createGistRelativeLink ( nwo ) ;
33+ const link = createRelativeLink ( nwo , linkType ) ;
2834 summaryLines . push ( `| ${ nwo } | [${ resultsCount } result(s)](${ link } ) |` ) ;
2935
3036 // Generate individual markdown file for each repository
@@ -290,13 +296,18 @@ function buildExpandableMarkdownSection(title: string, contents: MarkdownFile):
290296 return expandableLines ;
291297}
292298
293- /**
294- * Creates anchor link to a file in the gist. This is of the form:
295- * '#file-<name>-<file-extension>'
296- *
297- * TODO: Make sure these names align with the actual file names once we upload them to a gist.
298- */
299- function createGistRelativeLink ( nwo : string ) : string {
299+ function createRelativeLink ( nwo : string , linkType : MarkdownLinkType ) : string {
300300 const [ owner , repo ] = nwo . split ( '/' ) ;
301- return `#file-${ owner } -${ repo } -md` ;
301+
302+ switch ( linkType ) {
303+ case 'local' :
304+ return `./${ owner } -${ repo } .md` ;
305+
306+ case 'gist' :
307+ // Creates anchor link to a file in the gist. This is of the form:
308+ // '#file-<name>-<file-extension>'
309+ //
310+ // TODO: Make sure these names align with the actual file names once we upload them to a gist.
311+ return `#file-${ owner } -${ repo } -md` ;
312+ }
302313}
0 commit comments