@@ -38,13 +38,21 @@ type ReferenceDirectoryWithFilterProps = {
38
38
* @returns One-line description
39
39
*/
40
40
const getOneLineDescription = ( description : string ) : string => {
41
- // Matches until the first ., ?, !, ।, or 。 followed by a space
42
- const fullStopRegex = / .* ?(?: \. \s | \? \s | ! \s | । \s | 。 \s ) / ;
43
- const cleanedDescription = description
44
- . replace ( / < [ ^ > ] * > ? / gm, "" )
45
- . replace ( / \n / g, " " ) ;
46
- const [ oneLineDescription ] = cleanedDescription . match ( fullStopRegex ) ?? [ ] ;
47
- return `${ oneLineDescription ?. trim ( ) ?? cleanedDescription } ` ;
41
+ // Matches first paragraph tag, remove HTML tags, then trim to first fullstop
42
+ const firstParagraphRegex = / ^ < p > ( .* ?) < \/ p > / ;
43
+ let [ oneLineDescription ] = description . replace ( / \n / g, " " ) . trim ( )
44
+ . match ( firstParagraphRegex ) ?? [ ] ;
45
+
46
+ if ( oneLineDescription ) {
47
+ oneLineDescription = oneLineDescription
48
+ . replace ( / ^ < p > | < \/ p > $ / g, "" )
49
+ . replace ( / < \/ ? c o d e > / g, "" )
50
+ . replace ( / < v a r > ( \d + ?) < s u p > ( \d + ?) < \/ s u p > < \/ v a r > / g, "$1^$2" )
51
+ . replace ( / < a h r e f = " .* ?" > | < \/ a > / g, "" )
52
+ . split ( / \. \s | \? \s | ! \s | । \s | 。 / ) [ 0 ] ;
53
+ }
54
+
55
+ return oneLineDescription ?? "" ;
48
56
} ;
49
57
50
58
export const ReferenceDirectoryWithFilter = ( {
0 commit comments