Skip to content

Commit

Permalink
fix: adjust settings to add a better comprehension of regex & interna…
Browse files Browse the repository at this point in the history
…l links conversion

close #322
close #321
  • Loading branch information
Mara-Li committed Mar 5, 2024
1 parent d108e7d commit 0e97ea5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/conversion/compiler/dataview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function convertDataviewQueries(
properties: MultiProperties,
): Promise<string> {
const plugin = properties.plugin;
const app = plugin.app;
const settings = plugin.settings;
let replacedText = text;
const dataViewRegex = /```dataview\s(.+?)```/gsm;
Expand Down Expand Up @@ -201,7 +202,7 @@ async function convertDataviewLinks(
sourceFile,
frontmatter,
properties
);
);
return convertWikilinks(
md,
properties.frontmatter.general,
Expand Down
9 changes: 5 additions & 4 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"settings": {
"conversion": {
"dataview": {
"desc": "Convert dataview to markdown. Only works if Dataview is enabled.",
"desc": "Convert Dataview queries to markdown. \nOnly works if Dataview and internal link conversion are enabled.",
"title": "Dataview"
},
"desc": "Theses option won't change the content of the file in your Obsidian Vault, but will change the content of the file in GitHub.",
Expand All @@ -180,6 +180,7 @@
"title": "Folder note"
},
"internals": {
"dataview": "Mandatory if you want to convert links in dataview blocks!",
"desc": "Convert internal links to their counterpart in the repository, with relative path.",
"shareAll": "Includes all links for the \"share all\" settings, as it impossible without frontmatter to know the sharing state of a file.",
"title": "Internals links"
Expand Down Expand Up @@ -452,7 +453,7 @@
"plugin": {
"copyLink": {
"applyRegex": {
"desc": "Encapsulate with \"//\" to use regexes",
"desc": "Encapsulate between \"/\" to use regexes (ie: /regex/).",
"title": "Add a text transformation to the URL"
},
"baselink": {
Expand Down Expand Up @@ -545,7 +546,7 @@
},
"invalidRegex": "An error has occurred: {{- e}}",
"modal": {
"desc": "Replace text in the file with the given value. Enclose the text with \"//\" to use regex.",
"desc": "Replace text in the file with the given value. Enclose the text between \"/\" to use regex (ie: /regex/).",
"force": "Force push",
"keywords": "Keywords",
"name": "Use {{name}} to use the filename.",
Expand Down Expand Up @@ -584,7 +585,7 @@
"title": "Property key"
},
"regexFilePathTitle": {
"desc": "If the text is between \"//\", it will be used as a regex. Otherwise, it will be used as a string.",
"desc": "If the text is between \"/\" (ie: /regex/), it will be used as a regex. Otherwise, it will be used as a string.",
"title": {
"FolderPathTitle": "Apply edit on the folder path or the filename (automatically)",
"titleOnly": "Apply edit on the filename (automatically)"
Expand Down
11 changes: 6 additions & 5 deletions src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"settings": {
"conversion": {
"dataview": {
"desc": "Convertir les requêtes Dataview en markdown. Ne fonctionne que si Dataview est activé.",
"desc": "Convertir les requêtes Dataview en markdown. Ne fonctionne que si Dataview et la conversion des liens internes sont activés.",
"title": "Dataview"
},
"desc": "Ces options ne changent pas le contenu du fichier dans votre coffre Obsidian, mais changeront le contenu du fichier publié sur GitHub.",
Expand All @@ -180,6 +180,7 @@
"title": "Folder Note"
},
"internals": {
"dataview": "Obligatoire si vous voulez convertir les liens dans les blocs dataview !",
"desc": "Convertir les liens internes pointant vers les notes publiées vers leur homologue dans le dépôt, sous forme de chemin relatif.",
"shareAll": "Inclut tous les liens pour les paramètres \"partager tout\", car il est impossible sans frontmatter de connaître l'état de partage d'un fichier.",
"title": "Liens internes"
Expand Down Expand Up @@ -452,7 +453,7 @@
"plugin": {
"copyLink": {
"applyRegex": {
"desc": "Encapsuler avec \"//\" pour utiliser les expressions rationnelles",
"desc": "Encapsuler entre \"/\" pour utiliser les expressions rationnelles (ie: /regex/).",
"title": "Ajouter une transformation de texte à l'URL"
},
"baselink": {
Expand Down Expand Up @@ -495,7 +496,7 @@
"title": "Afficher les éditions sur le dépôt"
},
"excludedFolder": {
"desc": "Les fichiers dans ses dossiers ne seront jamais publiés, quelle que soit l'état de la clé de partage. Séparez les noms de dossier par une virgule. Les regex sont supportés en les encadrant par \"//\"",
"desc": "Les fichiers dans ses dossiers ne seront jamais publiés, quelle que soit l'état de la clé de partage. Séparez les noms de dossier par une virgule. Les regex sont supportés en les encadrant entre \"/\" (ie : /regex/).",
"title": "Dossiers exclus"
},
"fileMenu": {
Expand Down Expand Up @@ -545,7 +546,7 @@
},
"invalidRegex": "Une erreur est survenue : {{- e}}",
"modal": {
"desc": "Replace des textes dans le fichier par la valeur donnée. Vous pouvez encadrer le texte à remplacer avec \"//\" pour utiliser un regex.",
"desc": "Replace des textes dans le fichier par la valeur donnée. Vous pouvez encadrer le texte à remplacer avec \"/\" (ie : /regex/) pour utiliser un regex.",
"force": "Forcer l'envoi",
"keywords": "Mots clés",
"name": "Utiliser {{name}} pour utiliser le nom du fichier.",
Expand Down Expand Up @@ -584,7 +585,7 @@
"title": "Clé de propriété"
},
"regexFilePathTitle": {
"desc": "Si le texte est entre \"//\", il sera interprété comme une expression régulière. Sinon, il sera interprété comme du texte brut.",
"desc": "Si le texte est entre \"/\" (ie : /regex/), il sera interprété comme une expression régulière. Sinon, il sera interprété comme du texte brut.",
"title": {
"FolderPathTitle": "Éditer le titre et le chemin du dossier (automatiquement)",
"titleOnly": "Éditer le titre (automatiquement)"
Expand Down
11 changes: 6 additions & 5 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,13 @@ export class GithubPublisherSettingsTab extends PluginSettingTab {
});

const shareAll = this.settings.plugin.shareAll?.enable ? ` ${i18next.t("settings.conversion.links.internals.shareAll")}` : "";
const internalLinksDesc = document.createDocumentFragment();
internalLinksDesc.createEl("p", {text: i18next.t("settings.conversion.links.internals.desc") + shareAll, cls: "no-margin"});
internalLinksDesc.createEl("p", {text: i18next.t("settings.conversion.links.internals.dataview"), cls: "no-margin"});

new Setting(this.settingsPage)
.setName(i18next.t("settings.conversion.links.internals.title"))
.setDesc(
i18next.t("settings.conversion.links.internals.desc") + shareAll
)
.setDesc(internalLinksDesc)
.addToggle((toggle) => {
toggle
.setValue(textSettings.links.internal)
Expand Down Expand Up @@ -773,8 +774,8 @@ export class GithubPublisherSettingsTab extends PluginSettingTab {
.setDesc(i18next.t("settings.conversion.dataview.desc"))
.addToggle((toggle) => {
toggle
.setValue(textSettings.dataview && isDataviewEnabled)
.setDisabled(!isDataviewEnabled)
.setValue(textSettings.dataview && isDataviewEnabled && textSettings.links.internal)
.setDisabled(!isDataviewEnabled || !textSettings.links.internal)
.onChange(async (value) => {
textSettings.dataview = value;
await this.plugin.saveSettings();
Expand Down
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ hr.github-publisher-hr {
opacity: 0.1;
}

.github-publisher .no-margin {
margin: 0;
}

/* --------- EXPORT IMPORT --------- */

.github-publisher .setting-item.import-export {
Expand Down

0 comments on commit 0e97ea5

Please sign in to comment.