@@ -96,14 +96,26 @@ export class JsdocParserUtil {
9696
9797 const CODE_FENCE = / ^ \s * ` ` ` (? ! .* ` ` ` ) / ;
9898 let inCode = false ;
99- function readLine ( line : string ) {
99+ let inExample = false ; // first line with @example , end line with empty string or string or */
100+ let nbLines = 0 ;
101+ function readLine ( line : string , index : number ) {
100102 line = line . replace ( / ^ \s * \* ? ? / , '' ) ;
101103 line = line . replace ( / \s * $ / , '' ) ;
102104
103105 if ( CODE_FENCE . test ( line ) ) {
104106 inCode = ! inCode ;
105107 }
106108
109+ if ( line . indexOf ( '@example' ) !== - 1 ) {
110+ inExample = true ;
111+ line = '```html' ;
112+ }
113+
114+ if ( inExample && line === '' ) {
115+ inExample = false ;
116+ line = '```' ;
117+ }
118+
107119 if ( ! inCode ) {
108120 const tag = / ^ @ ( \S + ) / . exec ( line ) ;
109121 const SeeTag = / ^ @ s e e / . exec ( line ) ;
@@ -123,6 +135,8 @@ export class JsdocParserUtil {
123135 text = text . replace ( / ^ \s * \/ \* + / , '' ) ;
124136 text = text . replace ( / \* + \/ \s * $ / , '' ) ;
125137
138+ nbLines = text . split ( / \r \n ? | \n / ) . length ;
139+
126140 text . split ( / \r \n ? | \n / ) . forEach ( readLine ) ;
127141
128142 return comment ;
@@ -272,8 +286,15 @@ export class JsdocParserUtil {
272286 case SyntaxKind . JSDocLink :
273287 if ( JSDocNode . name ) {
274288 let text = JSDocNode . name . escapedText ;
275- if ( text === undefined && JSDocNode . name . left && JSDocNode . name . right ) {
276- text = JSDocNode . name . left . escapedText + '.' + JSDocNode . name . right . escapedText ;
289+ if (
290+ text === undefined &&
291+ JSDocNode . name . left &&
292+ JSDocNode . name . right
293+ ) {
294+ text =
295+ JSDocNode . name . left . escapedText +
296+ '.' +
297+ JSDocNode . name . right . escapedText ;
277298 }
278299 rawDescription += JSDocNode . text + '{@link ' + text + '}' ;
279300 }
0 commit comments