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

Bug: Removes front matter list of arrays when there is a comment.

Open android272 opened this issue 1 year ago • 2 comments

Describe the Bug

List of arrays is removed from Yaml frontmatter when there is a comment. I thought the liter was removing the list of arrays at first but then for some reason I manually removed the comment and the list of arrays did not get removed. I don't see comments anywhere in the settings so maybe the ability to keep/remove comments in frontmatter shold be added.

How to Reproduce

This section of front matter is added to my recipe notes

---
Ingredients: # [`<free text for ingredient>`,`<amount>`, `<unit>`, `<form>`, `<note>`]
  - [Watermelon, 80 g, cubed, note]
  - [sugar, 20 g]
---

No logs with error set.

{
  "ruleConfigs": {
    "escape-yaml-special-characters": {
      "enabled": true,
      "try-to-escape-single-line-arrays": true
    },
    "force-yaml-escape": {
      "enabled": false,
      "force-yaml-escape-keys": ""
    },
    "format-tags-in-yaml": {
      "enabled": true
    },
    "format-yaml-array": {
      "enabled": true,
      "alias-key": true,
      "tag-key": true,
      "default-array-style": "single-line",
      "default-array-keys": true,
      "force-single-line-array-style": "",
      "force-multi-line-array-style": ""
    },
    "insert-yaml-attributes": {
      "enabled": true,
      "text-to-insert": "Aliases: []"
    },
    "move-tags-to-yaml": {
      "enabled": false,
      "how-to-handle-existing-tags": "Nothing",
      "tags-to-ignore": "Prayer\nGratitude/"
    },
    "remove-yaml-keys": {
      "enabled": false,
      "yaml-keys-to-remove": "Date\nTime"
    },
    "yaml-key-sort": {
      "enabled": true,
      "yaml-key-priority-sort-order": "",
      "priority-keys-at-start-of-yaml": true,
      "yaml-sort-order-for-other-keys": "Ascending Alphabetical"
    },
    "yaml-timestamp": {
      "enabled": true,
      "date-created": true,
      "date-created-key": "date created",
      "force-retention-of-create-value": false,
      "date-modified": true,
      "date-modified-key": "date modified",
      "format": "YYYY-MM-DD, h:mm:ss a"
    },
    "yaml-title": {
      "enabled": false,
      "title-key": "title"
    },
    "yaml-title-alias": {
      "enabled": false,
      "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": "via, a, an, the, and, or, but, for, nor, so, yet, at, by, in, of, on, to, up, as, is, if, it, for, to, with, without, into, onto, per"
    },
    "file-name-heading": {
      "enabled": false
    },
    "header-increment": {
      "enabled": false,
      "start-at-h2": false
    },
    "headings-start-line": {
      "enabled": true
    },
    "remove-trailing-punctuation-in-heading": {
      "enabled": true,
      "punctuation-to-remove": ".,;:!。,;:!"
    },
    "footnote-after-punctuation": {
      "enabled": true
    },
    "move-footnotes-to-the-bottom": {
      "enabled": true
    },
    "re-index-footnotes": {
      "enabled": true
    },
    "auto-correct-common-misspellings": {
      "enabled": false,
      "ignore-words": ""
    },
    "convert-bullet-list-markers": {
      "enabled": true
    },
    "emphasis-style": {
      "enabled": false,
      "style": "consistent"
    },
    "no-bare-urls": {
      "enabled": false
    },
    "ordered-list-style": {
      "enabled": true,
      "number-style": "ascending",
      "list-end-style": "."
    },
    "proper-ellipsis": {
      "enabled": true
    },
    "remove-consecutive-list-markers": {
      "enabled": true
    },
    "remove-empty-list-markers": {
      "enabled": true
    },
    "remove-hyphenated-line-breaks": {
      "enabled": true
    },
    "remove-multiple-spaces": {
      "enabled": true
    },
    "strong-style": {
      "enabled": false,
      "style": "consistent"
    },
    "two-spaces-between-lines-with-content": {
      "enabled": false
    },
    "unordered-list-style": {
      "enabled": true,
      "list-style": "-"
    },
    "compact-yaml": {
      "enabled": true,
      "inner-new-lines": true
    },
    "consecutive-blank-lines": {
      "enabled": true
    },
    "convert-spaces-to-tabs": {
      "enabled": false,
      "tabsize": 4
    },
    "empty-line-around-blockquotes": {
      "enabled": true
    },
    "empty-line-around-code-fences": {
      "enabled": true
    },
    "empty-line-around-math-blocks": {
      "enabled": true
    },
    "empty-line-around-tables": {
      "enabled": true
    },
    "heading-blank-lines": {
      "enabled": true,
      "bottom": false,
      "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": true
    },
    "remove-link-spacing": {
      "enabled": true
    },
    "remove-space-around-characters": {
      "enabled": false,
      "include-fullwidth-forms": true,
      "include-cjk-symbols-and-punctuation": true,
      "include-dashes": true,
      "other-symbols": ""
    },
    "space-after-list-markers": {
      "enabled": true
    },
    "space-between-chinese-japanese-or-korean-and-english-or-numbers": {
      "enabled": true
    },
    "trailing-spaces": {
      "enabled": true,
      "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": true
    },
    "remove-hyphens-on-paste": {
      "enabled": true
    },
    "remove-leading-or-trailing-whitespace-on-paste": {
      "enabled": true
    },
    "remove-leftover-footnotes-from-quote-on-paste": {
      "enabled": false
    },
    "remove-multiple-blank-lines-on-paste": {
      "enabled": true
    }
  },
  "lintOnSave": true,
  "recordLintOnSaveLogs": true,
  "displayChanged": true,
  "settingsConvertedToConfigKeyValues": true,
  "foldersToIgnore": [
    "Extras/Templates"
  ],
  "linterLocale": "system-default",
  "logLevel": 4,
  "lintCommands": [],
  "customRegexes": [],
  "commonStyles": {
    "aliasArrayStyle": "single string to multi-line",
    "tagArrayStyle": "single string to multi-line",
    "minimumNumberOfDollarSignsToBeAMathBlock": 2,
    "escapeCharacter": "\""
  }
}

Expected Behavior

I expected the comment and the list of arrays to remain.

---
Ingredients: # [`<free text for ingredient>`,`<amount>`, `<unit>`, `<form>`, `<note>`]
  - [Watermelon, 80 g, cubed, note]
  - [sugar, 20 g]
---

Device

  • [x] Desktop
  • [x] Mobile

android272 avatar May 10 '23 20:05 android272

Thanks for the input @android272 . The scenario in question is like formatting the arrays. It does not currently use a parser and the current parser we use would remove the comment and have other issues with the YAML which is why it is not currently in use. The recommended fix for now is to move the comment to the line prior to the key like so:

---
# [`<free text for ingredient>`,`<amount>`, `<unit>`, `<form>`, `<note>`]
Ingredients:
  - [Watermelon, 80 g, cubed, note]
  - [sugar, 20 g]
---

This is something that I would like to be able to fix eventually, but have not found a good way of doing so at this time.

pjkaufman avatar May 10 '23 21:05 pjkaufman

Thanks, that's what I did when I discovered that it was the comment that was causing my issue.

android272 avatar May 12 '23 01:05 android272