Skip to content

Commit

Permalink
Fix #193: add ignoreMainTheoremCalloutWithoutTitle setting
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Nov 22, 2023
1 parent 3a00b42 commit 206e46d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class MathIndex {
*/
public updateNames(file: TFile) {
const settings = resolveSettings(undefined, this.plugin, file);

let blockOrdinal = 1;
let block: Indexable | undefined;

Expand Down Expand Up @@ -322,7 +322,9 @@ export class MathIndex {
if (mainTheorem) {
const resolvedSettings = Object.assign({}, settings, mainTheorem.$settings);
(resolvedSettings as ResolvedMathSettings)._index = mainTheorem.$index;
page.$refName = this.formatMathLink(file, resolvedSettings, "noteMathLinkFormat");

if (!resolvedSettings.ignoreMainTheoremCalloutWithoutTitle || mainTheorem.$theoremSubtitle)
page.$refName = this.formatMathLink(file, resolvedSettings, "noteMathLinkFormat");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/settings/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export class MathContextSettingsHelper extends SettingsHelper<MathContextSetting
'Format for a note that has its "main" theorem callout',
`When a theorem callout is set as main by a markdown comment "%% main %%", this format will be used for links to the note containing that theorem callout.`
);
this.addToggleSetting('ignoreMainTheoremCalloutWithoutTitle', 'Ignore a "main" theorem callout without its own title');

this.addHeading('Equations - numbering', ['equation-heading']);

Expand Down
2 changes: 2 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface MathContextSettings {
numberDefault: string;
refFormat: TheoremRefFormat;
noteMathLinkFormat: TheoremRefFormat;
ignoreMainTheoremCalloutWithoutTitle: boolean;
inferEqNumberPrefix: boolean;
inferEqNumberPrefixFromProperty: string;
inferEqNumberPrefixParseSep: string;
Expand Down Expand Up @@ -197,6 +198,7 @@ export const DEFAULT_SETTINGS: Required<MathContextSettings> = {
numberDefault: "auto",
refFormat: "[type] [number] ([title])",
noteMathLinkFormat: "[title] if title exists, [type] [number] otherwise",
ignoreMainTheoremCalloutWithoutTitle: false,
inferEqNumberPrefix: true,
inferEqNumberPrefixFromProperty: "",
inferEqNumberPrefixParseSep: "-.",
Expand Down

0 comments on commit 206e46d

Please sign in to comment.