Skip to content

Commit 759f1eb

Browse files
cci: make section heading regex configurable
1 parent 7ab7b28 commit 759f1eb

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/config/WikiConfiguration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export default class WikiConfiguration extends ConfigurationBase {
252252
defaultValue: null,
253253
displayOptions: { type: 'page' }
254254
} ),
255+
headingMatch: new Setting<string, string>( {
256+
defaultValue: '(Page|Article|Local file|File)s? \\d+ (to|through) \\d+',
257+
displayOptions: { type: 'text' }
258+
} ),
255259
collapseTop: new Setting<string, string>( {
256260
defaultValue: collapseTop,
257261
displayOptions: { type: 'code' }

src/wiki/DeputyCasePage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ export default class DeputyCasePage extends DeputyCase {
144144
}
145145

146146
// All headings (h1, h2, h3, h4, h5, h6)
147-
// TODO: l10n
148147
const headlineElement = this.parsoid ?
149148
el :
150149
el.querySelector<HTMLElement>( '.mw-headline' );
151150
// Handle DiscussionTools case (.mw-heading)
152151
return isWikiHeading( el ) &&
153152
headlineElement != null &&
154-
/(Page|Article|Local file|File)s? \d+ (to|through) \d+$/.test( headlineElement.innerText );
153+
// eslint-disable-next-line security/detect-non-literal-regexp
154+
new RegExp(
155+
window.deputy.wikiConfig.cci.headingMatch.get()
156+
).test( headlineElement.innerText );
155157
}
156158

157159
/**

0 commit comments

Comments
 (0)