File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " planet" ,
33 "license" : " AGPL-3.0" ,
4- "version" : " 0.20.40 " ,
4+ "version" : " 0.20.41 " ,
55 "myplanet" : {
66 "latest" : " v0.33.52" ,
77 "min" : " v0.32.52"
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ export class PlanetMarkdownComponent implements OnChanges {
3939 `${ environment . parentProtocol } ://${ this . stateService . configuration . parentDomain } /` :
4040 `${ environment . couchAddress } /` ;
4141
42+ this . content = this . normalizeWhitespace ( this . content || '' ) ;
43+
4244 this . images = this . extractImageUrls ( this . content ) ;
4345 const textOnly = this . content . replace ( this . imageMarkdownRegex , '' ) ;
4446
@@ -52,6 +54,15 @@ export class PlanetMarkdownComponent implements OnChanges {
5254 }
5355 }
5456
57+ normalizeWhitespace ( content : string ) : string {
58+ // Replace excessive consecutive whitespace (tabs, newlines, spaces) with reasonable limits
59+ // Replace sequences of tabs/spaces with max 2 spaces
60+ content = content . replace ( / [ \t ] + / g, ( match ) => match . length > 2 ? ' ' : match ) ;
61+ // Replace excessive newlines (more than 2 consecutive) with just 2 newlines
62+ content = content . replace ( / \n { 3 , } / g, '\n\n' ) ;
63+ return content . trim ( ) ;
64+ }
65+
5566 extractImageUrls ( content : string ) : string [ ] {
5667 const matches : string [ ] = [ ] ;
5768 let match : RegExpExecArray | null ;
You can’t perform that action at this time.
0 commit comments