Skip to content

Commit

Permalink
ia: gracefully handle dl comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Mar 23, 2024
1 parent 87d5c6f commit 1524994
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/modules/ia/models/CopyrightProblemsListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import decorateEditSummary from '../../../wiki/util/decorateEditSummary';
import MwApi from '../../../MwApi';
import changeTag from '../../../config/changeTag';

export interface SerializedCopyrightProblemsListingData {
basic: boolean;
i?: number;
id: string;
title: { namespace: number, title: string, fragment: null | string };
listingPage: { namespace: number, title: string, fragment: null | string };
lines: { start: number, end: number };
}

/**
* Represents a listing on a CPN page where the listing is substituted from
* the `{{article-cv}}` template.
Expand Down Expand Up @@ -326,6 +335,8 @@ export default class CopyrightProblemsListing {
* the line on which the listing appears, the `end` denotes the last line
* where there is a comment on that specific listing.
*
* Use in conjunction with `listingPage.getWikitext()` to get the lines in wikitext.
*
* @return See documentation body.
*/
async getListingWikitextLines(): Promise<{ start: number, end: number }> {
Expand All @@ -345,7 +356,7 @@ export default class CopyrightProblemsListing {
// Does not match: `*`, ``, ` `
if ( startLine != null ) {
if ( bulletList ?
!/^(\*[*:]+)/g.test( lineText ) :
!/^(\*[*:]+|:)/g.test( lineText ) :
/^[^:*]/.test( lineText )
) {
return { start: startLine, end: endLine ?? startLine };
Expand Down Expand Up @@ -465,4 +476,26 @@ export default class CopyrightProblemsListing {
await this.listingPage.getWikitext( true );
}

/**
* Serialize this listing. Used for tests.
*/
async serialize(): Promise<SerializedCopyrightProblemsListingData> {
return {
basic: this.basic,
i: this.i,
id: this.id,
title: {
namespace: this.title.namespace,
title: this.title.title,
fragment: this.title.getFragment()
},
listingPage: {
namespace: this.listingPage.title.namespace,
title: this.listingPage.title.title,
fragment: this.listingPage.title.getFragment()
},
lines: await this.getListingWikitextLines()
};
}

}

0 comments on commit 1524994

Please sign in to comment.