Skip to content

Commit

Permalink
feat: prevent dataview conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jul 29, 2022
1 parent 11a8646 commit 6125340
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugin/i18n/locales/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export default {
wikilinksDesc: "Convert Wikilinks to MDlinks, without changing the contents",
hardBreakTitle: "Markdown hard line break",
hardBreakDesc: "Add a markdown hard line break (double whitespace) after each line.",
headerDataview: "Dataview",
headerDataviewDesc: "Convert dataview to markdown.",

// ---
// # Embed # //
Expand Down
2 changes: 2 additions & 0 deletions plugin/i18n/locales/fr-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export default {
wikilinksDesc: "Convertir les liens Wikilinks en liens markdown, sans en modifier le contenu",
hardBreakTitle: "Saut de ligne strict",
hardBreakDesc: "Ajoutez un retour à la ligne Markdown (double espace) après chaque ligne.",
headerDataview: "Dataview",
headerDataviewDesc: "Convertir dataview en markdown.",

// ---
// # Embed # //
Expand Down
2 changes: 2 additions & 0 deletions plugin/i18n/locales/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export default {
wikilinksDesc: "转换wiki link为md link,不改变文件内容",
hardBreakTitle: "马克顿的硬断行",
hardBreakDesc: "在每一行之后添加一个标记性的硬断行(双倍空白)。",
headerDataview: "Dataview",
headerDataviewDesc: "Convert dataview to markdown.",

// ---
// # Embed # //
Expand Down
13 changes: 13 additions & 0 deletions plugin/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ export class MkdocsSettingsTab extends PluginSettingTab {
await this.plugin.saveSettings();
});
});

new Setting(this.containerEl)
.setName(t('headerDataview') as string)
.setDesc(t('headerDataviewDesc') as string)
.addToggle((toggle) => {
toggle
.setValue(this.plugin.settings.convertDataview)
.onChange(async (value) => {
this.plugin.settings.convertDataview = value;
await this.plugin.saveSettings();
});
});

containerEl.createEl('h5', {text: t('linkHeader') as string})
const folderNoteSettings = new Setting(containerEl)
.setName(t('folderNote') as string)
Expand Down
2 changes: 2 additions & 0 deletions plugin/settings/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface MkdocsPublicationSettings {
linkRemover: string;
hardBreak: boolean;
logNotice: boolean;
convertDataview: boolean;
}

export enum folderSettings {
Expand Down Expand Up @@ -63,4 +64,5 @@ export const DEFAULT_SETTINGS: MkdocsPublicationSettings = {
linkRemover: '',
hardBreak: false,
logNotice: false,
convertDataview: true,
}
2 changes: 1 addition & 1 deletion plugin/src/convertText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function convertDataviewQueries(text: string, path: string, settings: Mkdo
const dataviewRegex = /```dataview(.+?)```/gsm;
const dvApi = getAPI();
const matches = text.matchAll(dataviewRegex);
if (!matches) return;
if (!matches || !settings.convertDataview) return;
for (const queryBlock of matches){
try {
const block = queryBlock[0];
Expand Down

0 comments on commit 6125340

Please sign in to comment.