Skip to content

Commit

Permalink
fix: warned about future removal of !!!-style syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Feb 8, 2022
1 parent bf379bf commit cc183a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ Mermaid graphs are supported by Admonitions, but with some caveats:

## Non-code block Admonitions

> :heavy_exclamation_mark: This syntax will be removed in a future version!
>
> It is no longer possible to enable this syntax. Legacy support will continue until version **7.0.0**.
Please note: An additional non-code block syntax can be seen in the [Microsoft Document Syntax](#microsoft-document-syntax) section.

As of version 6.0.0, there is a new setting: Enable Non-codeblock Admonitions.
Expand Down Expand Up @@ -622,7 +626,9 @@ Admonitions with no content are hidden by default.
### Enable Non-codeblock Admonitions

> :heavy_exclamation_mark: This syntax will be removed in a future version!
>
>
> It is no longer possible to enable this setting. Legacy support will continue until version **7.0.0**.
>
> It is recommended to use the [Microsoft Document Syntax](#microsoft-document-syntax) instead.
Enabled use of `!!! ad-<type>` style admonitions. No longer supported, will be removed in a future version.
Expand Down
1 change: 1 addition & 0 deletions src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface AdmonitionSettings {
defaultCollapseType: "open" | "closed";
syncLinks: boolean;
version: string;
warnedAboutNC: boolean;
enableMarkdownProcessor: boolean;
injectColor: boolean;
parseTitles: boolean;
Expand Down
20 changes: 13 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const DEFAULT_APP_SETTINGS: AdmonitionSettings = {
syntaxHighlight: false,
copyButton: false,
version: "",
warnedAboutNC: false,
autoCollapse: false,
defaultCollapseType: "open",
syncLinks: true,
Expand Down Expand Up @@ -149,13 +150,8 @@ export default class ObsidianAdmonition extends Plugin {
}

async loadSettings() {
let data = Object.assign(
{},
DEFAULT_APP_SETTINGS,
await this.loadData()
);

this.data = data;
const loaded: AdmonitionSettings = await this.loadData();
this.data = Object.assign({}, DEFAULT_APP_SETTINGS, loaded);

if (
this.data.userAdmonitions &&
Expand All @@ -180,6 +176,16 @@ export default class ObsidianAdmonition extends Plugin {
}
}

if (loaded != null && !this.data.warnedAboutNC) {
if (Number(this.data.version.split(".")[0]) < 7) {
new Notice(
"Admonitions: Use of the !!!-style Admonitions will be removed in a future version.\n\nPlease update them to the MSDoc-style syntax.",
0
);
}
this.data.warnedAboutNC = true;
}

this.admonitions = {
...ADMONITION_MAP,
...this.data.userAdmonitions
Expand Down

0 comments on commit cc183a8

Please sign in to comment.