@@ -20,13 +20,15 @@ type BuildConciergeDraftReportActionParams = {
2020 reportID : string ;
2121} ;
2222
23- type MarkdownRange = {
23+ type TextRange = {
2424 start : number ;
2525 end : number ;
2626} ;
2727
2828const CODE_BLOCK_DELIMITER = '```' ;
2929const INLINE_CODE_DELIMITER = '`' ;
30+ const BOLD_DELIMITER = '**' ;
31+ const STRIKETHROUGH_DELIMITER = '~~' ;
3032
3133function isEscaped ( text : string , index : number ) : boolean {
3234 let slashCount = 0 ;
@@ -40,8 +42,8 @@ function isEscaped(text: string, index: number): boolean {
4042 return slashCount % 2 !== 0 ;
4143}
4244
43- function getCodeRanges ( text : string ) : { ranges : MarkdownRange [ ] ; unclosedCodeBlockStart : number | null } {
44- const ranges : MarkdownRange [ ] = [ ] ;
45+ function getCodeRanges ( text : string ) : { ranges : TextRange [ ] ; unclosedCodeBlockStart : number | null } {
46+ const ranges : TextRange [ ] = [ ] ;
4547 let unclosedCodeBlockStart : number | null = null ;
4648
4749 for ( let pos = 0 ; pos <= text . length - CODE_BLOCK_DELIMITER . length ; pos ++ ) {
@@ -88,7 +90,7 @@ function getCodeRanges(text: string): {ranges: MarkdownRange[]; unclosedCodeBloc
8890 return { ranges, unclosedCodeBlockStart} ;
8991}
9092
91- function stripUnpairedLastLineDelimiter ( text : string , delimiter : string , ignoredRanges : MarkdownRange [ ] = [ ] ) : string {
93+ function stripUnpairedLastLineDelimiter ( text : string , delimiter : string , ignoredRanges : TextRange [ ] = [ ] ) : string {
9294 const lastNewline = text . lastIndexOf ( '\n' ) ;
9395 const lastLineStart = lastNewline + 1 ;
9496 const delimiterIndexes : number [ ] = [ ] ;
@@ -110,7 +112,7 @@ function stripUnpairedLastLineDelimiter(text: string, delimiter: string, ignored
110112 return text ;
111113}
112114
113- function normalizeDelimiterForExpensiMark ( text : string , delimiter : string , replacement : string , ignoredRanges : MarkdownRange [ ] = [ ] ) : string {
115+ function normalizeDelimiterForExpensiMark ( text : string , delimiter : string , replacement : string , ignoredRanges : TextRange [ ] = [ ] ) : string {
114116 let result = '' ;
115117
116118 for ( let pos = 0 ; pos < text . length ; pos ++ ) {
@@ -168,14 +170,14 @@ function stripIncompleteMarkdown(markdown: string): string {
168170 }
169171
170172 codeRanges = getCodeRanges ( result ) . ranges ;
171- result = stripUnpairedLastLineDelimiter ( result , '**' , codeRanges ) ;
173+ result = stripUnpairedLastLineDelimiter ( result , BOLD_DELIMITER , codeRanges ) ;
172174 codeRanges = getCodeRanges ( result ) . ranges ;
173- result = normalizeDelimiterForExpensiMark ( result , '**' , '*' , codeRanges ) ;
175+ result = normalizeDelimiterForExpensiMark ( result , BOLD_DELIMITER , '*' , codeRanges ) ;
174176
175177 codeRanges = getCodeRanges ( result ) . ranges ;
176- result = stripUnpairedLastLineDelimiter ( result , '~~' , codeRanges ) ;
178+ result = stripUnpairedLastLineDelimiter ( result , STRIKETHROUGH_DELIMITER , codeRanges ) ;
177179 codeRanges = getCodeRanges ( result ) . ranges ;
178- result = normalizeDelimiterForExpensiMark ( result , '~~' , '~' , codeRanges ) ;
180+ result = normalizeDelimiterForExpensiMark ( result , STRIKETHROUGH_DELIMITER , '~' , codeRanges ) ;
179181
180182 return result ;
181183}
0 commit comments