obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

Question: Not adding aliases to YAML

Open kalico1 opened this issue 1 year ago • 8 comments

Something seems to be overriding the "aliases" line in my list of text to insert. It reads as follows:

title: aliases: created: tags: publish: false

But every time I Lint a file, the aliases line doesn't show up. I'm not sure what part of the settings might do this, so I'm not sure what screenshot to send....let me know. Hope to learn something here. :)

kalico1 avatar Jul 27 '23 04:07 kalico1

Hey @kalico1 . My best guess is that aliases is listed as a key to remove in YAML Keys to remove. But that is just a guess.

Could you include your data.json so I can test things out and see if I can reproduce?

pjkaufman avatar Jul 27 '23 09:07 pjkaufman

Thanks. Yes, I agree that would make sense, but I have only "links" listed there.

Here's the data.json

{ "ruleConfigs": { "escape-yaml-special-characters": { "enabled": false, "try-to-escape-single-line-arrays": false }, "force-yaml-escape": { "enabled": false, "force-yaml-escape-keys": "" }, "format-tags-in-yaml": { "enabled": true }, "format-yaml-array": { "enabled": false, "alias-key": false, "tag-key": false, "default-array-style": "single-line", "default-array-keys": false, "force-single-line-array-style": "", "force-multi-line-array-style": "" }, "insert-yaml-attributes": { "enabled": true, "text-to-insert": "title:\naliases: \ncreated:\ntags: \npublish: false" }, "move-tags-to-yaml": { "enabled": true, "how-to-handle-existing-tags": "Nothing", "tags-to-ignore": "" }, "remove-yaml-keys": { "enabled": true, "yaml-keys-to-remove": "links" }, "yaml-key-sort": { "enabled": false, "yaml-key-priority-sort-order": "", "priority-keys-at-start-of-yaml": false, "yaml-sort-order-for-other-keys": "None" }, "yaml-timestamp": { "enabled": true, "date-created": true, "date-created-key": "created", "force-retention-of-create-value": false, "date-modified": false, "date-modified-key": "modified", "format": "YYYY-MM-DD HH:mm" }, "yaml-title": { "enabled": true, "title-key": "title", "mode": "filename" }, "yaml-title-alias": { "enabled": true, "preserve-existing-alias-section-style": true, "keep-alias-that-matches-the-filename": false, "use-yaml-key-to-keep-track-of-old-filename-or-heading": true }, "capitalize-headings": { "enabled": true, "style": "Title Case", "ignore-case-words": true, "ignore-words": "macOS, iOS, iPhone, iPad, JavaScript, TypeScript, AppleScript, I", "lowercase-words": "" }, "file-name-heading": { "enabled": true }, "header-increment": { "enabled": false, "start-at-h2": false }, "headings-start-line": { "enabled": false }, "remove-trailing-punctuation-in-heading": { "enabled": false, "punctuation-to-remove": ".,;:!。,;:!" }, "footnote-after-punctuation": { "enabled": false }, "move-footnotes-to-the-bottom": { "enabled": false }, "re-index-footnotes": { "enabled": false }, "auto-correct-common-misspellings": { "enabled": false, "ignore-words": "" }, "blockquote-style": { "enabled": false, "style": "space" }, "convert-bullet-list-markers": { "enabled": false }, "emphasis-style": { "enabled": false, "style": "consistent" }, "no-bare-urls": { "enabled": false }, "ordered-list-style": { "enabled": false, "number-style": "ascending", "list-end-style": "." }, "proper-ellipsis": { "enabled": false }, "quote-style": { "enabled": false, "single-quote-enabled": true, "single-quote-style": "''", "double-quote-enabled": true, "double-quote-style": "\"\"" }, "remove-consecutive-list-markers": { "enabled": false }, "remove-empty-list-markers": { "enabled": false }, "remove-hyphenated-line-breaks": { "enabled": false }, "remove-multiple-spaces": { "enabled": false }, "strong-style": { "enabled": false, "style": "consistent" }, "two-spaces-between-lines-with-content": { "enabled": false }, "unordered-list-style": { "enabled": false, "list-style": "-" }, "compact-yaml": { "enabled": true, "inner-new-lines": true }, "consecutive-blank-lines": { "enabled": false }, "convert-spaces-to-tabs": { "enabled": false, "tabsize": 4 }, "empty-line-around-blockquotes": { "enabled": false }, "empty-line-around-code-fences": { "enabled": true }, "empty-line-around-math-blocks": { "enabled": false }, "empty-line-around-tables": { "enabled": false }, "heading-blank-lines": { "enabled": true, "bottom": true, "empty-line-after-yaml": true }, "line-break-at-document-end": { "enabled": false }, "move-math-block-indicators-to-their-own-line": { "enabled": false }, "paragraph-blank-lines": { "enabled": false }, "remove-empty-lines-between-list-markers-and-checklists": { "enabled": false }, "remove-link-spacing": { "enabled": false }, "remove-space-around-characters": { "enabled": false, "include-fullwidth-forms": true, "include-cjk-symbols-and-punctuation": true, "include-dashes": true, "other-symbols": "" }, "remove-space-before-or-after-characters": { "enabled": false, "characters-to-remove-space-before": ",!?;:).’”]", "characters-to-remove-space-after": "¿¡‘“([" }, "space-after-list-markers": { "enabled": false }, "space-between-chinese-japanese-or-korean-and-english-or-numbers": { "enabled": false }, "trailing-spaces": { "enabled": false, "twp-space-line-break": false }, "add-blockquote-indentation-on-paste": { "enabled": false }, "prevent-double-checklist-indicator-on-paste": { "enabled": false }, "prevent-double-list-item-indicator-on-paste": { "enabled": false }, "proper-ellipsis-on-paste": { "enabled": false }, "remove-hyphens-on-paste": { "enabled": false }, "remove-leading-or-trailing-whitespace-on-paste": { "enabled": false }, "remove-leftover-footnotes-from-quote-on-paste": { "enabled": false }, "remove-multiple-blank-lines-on-paste": { "enabled": false } }, "lintOnSave": false, "recordLintOnSaveLogs": false, "displayChanged": true, "settingsConvertedToConfigKeyValues": true, "foldersToIgnore": [], "linterLocale": "system-default", "logLevel": 4, "lintCommands": [], "customRegexes": [], "commonStyles": { "aliasArrayStyle": "single-line", "tagArrayStyle": "single-line", "minimumNumberOfDollarSignsToBeAMathBlock": 2, "escapeCharacter": "\"", "removeUnnecessaryEscapeCharsForMultiLineArrays": false } }

kalico1 avatar Jul 28 '23 02:07 kalico1

Looks like it was removed by yaml-title-alias.

pjkaufman avatar Jul 28 '23 17:07 pjkaufman

I am double checking why that might be. But I will check if that is expected or not based on its settings.

pjkaufman avatar Jul 28 '23 17:07 pjkaufman

It looks like the value is being removed since it currently is empty and there is no retention of aliases that match the file name. So when it gets to the portion of logic that checks whether or not the aliases key is empty, it finds that it is. So it removes it (see logic here).

pjkaufman avatar Jul 28 '23 17:07 pjkaufman

Feel free to give feedback about how that is working. Logic could be added to retain the existing alias section if it starts as empty and ends as empty.

pjkaufman avatar Jul 28 '23 17:07 pjkaufman

Thank you so much! I'll have a look and let you know!

kalico1 avatar Jul 30 '23 06:07 kalico1

Ok, disabling that section resulted in getting "aliases" back when linting. So that's awesome, thank you! But this means that I did not understand how to use the yaml-title-alias section in spite of reading the instructions. I'm not going to suggest that the logic should be altered based on me not grokking this, but your idea sounds like a good solution from my limited perspective. OTOH, maybe just improving the instructions would help n00bs?? Your call, you're the dev, and I bow to you! 😁

kalico1 avatar Jul 31 '23 02:07 kalico1