Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: YAML Key Sort Does Not Work when There is Trailing Whitespace after a Colon in Config Values #1202

Closed
1 of 3 tasks
MrJohnWilkinson opened this issue Oct 21, 2024 · 12 comments · Fixed by #1209
Closed
1 of 3 tasks
Assignees
Labels
bug Something isn't working reproducible resolution/update-made A change has been made that should resolve this issue or request yaml YAML related issues or features

Comments

@MrJohnWilkinson
Copy link

MrJohnWilkinson commented Oct 21, 2024

  • I have verified that I am on the latest version of the Linter

Describe the Bug

I put in the keys, i run the lint, orders do change, but not as they should

How to Reproduce

Steps to reproduce the behavior:

  1. Have existing frontmatter of

pr-type:
pr-urgency:
pr-okr:
pr-completed-date:
related-companies:
pr-priority:
modified: 2024-10-21 09:58
stakeholders:
pr-pipeline-stage:
pr-size:
template: "[[Pro New Project Outcome Template]]"
pr-due-date:
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'

  1. run lint on current file with settings

related-companies:
stakeholders:
pr-priority:
pr-pipeline-stage:
pr-size:
pr-type:
pr-okr:
pr-due-date:
pr-urgency:
pr-completed-date:
template:
created-date:
modified:

  1. give this result

pr-type:
pr-okr:
pr-completed-date:
related-companies:
stakeholders:
template: "[[Pro New Project Outcome Template]]"
pr-priority:
pr-pipeline-stage:
pr-size:
pr-due-date:
pr-urgency:
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'
modified: 2024-10-21 09:58

Running linter
rules before regular rules: 0.09999990463256836 ms
Running Custom Regex
custom regex rules: 0.10000002384185791 ms
Running YAML Key Sort
yaml-key-sort: 1.100000023841858 ms

pr-type:
pr-okr:
pr-completed-date:
related-companies:
stakeholders:
template: "[[Pro New Project Outcome Template]]"
pr-priority:
pr-pipeline-stage:
pr-size:
pr-due-date:
pr-urgency:
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'
modified: 2024-10-21 09:58

<% await tp.file.move("/CRM/Projects/" + tp.file.title) %>

Navigation

![[🪧 Navigation Template]]

Related discussions

TABLE WITHOUT ID
    file.link AS "Meeting",
    interaction-date AS "Interaction Date",
    companies AS "Companies",
    attendees AS "Attendees"
FROM "CRM/Meetings"
WHERE contains(related-projects, this.file.link)
SORT file.link DESC

[[Project Prioritisation Matrix]]

Project Name Urgency (U) Importance (I) Size (S) Priority Score
Project A
Project B
Project C

Notes

Reference Links

  • [[Kanban - My Projects]]

rules after regular rules: 2 ms
rules running: 2.399999976158142 ms

Device

  • Desktop
  • Mobile
@MrJohnWilkinson MrJohnWilkinson added the bug Something isn't working label Oct 21, 2024
@pjkaufman
Copy link
Collaborator

Hey @MrJohnWilkinson . I am going to need your data.json in order to work on this. Also, did you put the file contents inside three back ticks ("`")? It looks like the provided example is not a code block.

@MrJohnWilkinson
Copy link
Author

Thanks. Everything you need should be below

Cheers

Content before running linter

---
stakeholders: 
pr-type: 
date-created: Thursday, August 22nd 2024, 6:41:04 pm
pr-pipeline-stage: 
pr-priority: 
modified: Tuesday, October 22nd 2024, 10:58:16 am
pr-size: 
pr-urgency: 
pr-okr: 
pr-due-date: 
pr-completed-date: 
template: "[[Pro New Project Outcome Template]]"
related-companies: 
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'
---
<% await tp.file.move("/CRM/Projects/" + tp.file.title) %>

## Navigation
![[🪧 Navigation Template]]

## Related discussions
```dataview
TABLE WITHOUT ID
    file.link AS "Meeting",
    interaction-date AS "Interaction Date",
    companies AS "Companies",
    attendees AS "Attendees"
FROM "CRM/Meetings"
WHERE contains(related-projects, this.file.link)
SORT file.link DESC
```

[[Project Prioritisation Matrix]]

|Project Name|Urgency (U)|Importance (I)|Size (S)|Priority Score|
|---|---|---|---|---|
|Project A|||||
|Project B|||||
|Project C|||||


## Notes


## Reference Links
- [[Kanban - My Projects]]
- 




content after running linter

---
stakeholders: 
pr-type: 
date-created: Thursday, August 22nd 2024, 6:41:04 pm
pr-completed-date: 
related-companies: 
pr-pipeline-stage: 
pr-priority: 
pr-size: 
pr-urgency: 
pr-okr: 
pr-due-date: 
template: "[[Pro New Project Outcome Template]]"
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'
modified: Tuesday, October 22nd 2024, 10:58:16 am
---
<% await tp.file.move("/CRM/Projects/" + tp.file.title) %>

## Navigation
![[🪧 Navigation Template]]

## Related discussions
```dataview
TABLE WITHOUT ID
    file.link AS "Meeting",
    interaction-date AS "Interaction Date",
    companies AS "Companies",
    attendees AS "Attendees"
FROM "CRM/Meetings"
WHERE contains(related-projects, this.file.link)
SORT file.link DESC
```

[[Project Prioritisation Matrix]]

|Project Name|Urgency (U)|Importance (I)|Size (S)|Priority Score|
|---|---|---|---|---|
|Project A|||||
|Project B|||||
|Project C|||||


## Notes


## Reference Links
- [[Kanban - My Projects]]
- 




Linter yaml-key-sort setting

related-companies: 
stakeholders: 
pr-pipeline-stage:
pr-priority:
pr-size:
pr-urgency:
pr-type: 
pr-okr:
pr-due-date:
pr-completed-date: 
template:
created-date:
modified:

Linter log

Running linter
rules before regular rules: 0 ms
Running Custom Regex
custom regex rules: 0.10000000009313226 ms
Running YAML Key Sort
yaml-key-sort: 1.2999999998137355 ms
---
stakeholders: 
pr-type: 
date-created: Thursday, August 22nd 2024, 6:41:04 pm
pr-completed-date: 
related-companies: 
pr-pipeline-stage: 
pr-priority: 
pr-size: 
pr-urgency: 
pr-okr: 
pr-due-date: 
template: "[[Pro New Project Outcome Template]]"
created-date: '[[<% tp.file.creation_date("YYYY-MM-DD") %>]]'
modified: Tuesday, October 22nd 2024, 10:58:16 am
---
<% await tp.file.move("/CRM/Projects/" + tp.file.title) %>

## Navigation
![[🪧 Navigation Template]]

## Related discussions
```dataview
TABLE WITHOUT ID
    file.link AS "Meeting",
    interaction-date AS "Interaction Date",
    companies AS "Companies",
    attendees AS "Attendees"
FROM "CRM/Meetings"
WHERE contains(related-projects, this.file.link)
SORT file.link DESC
```

[[Project Prioritisation Matrix]]

|Project Name|Urgency (U)|Importance (I)|Size (S)|Priority Score|
|---|---|---|---|---|
|Project A|||||
|Project B|||||
|Project C|||||


## Notes


## Reference Links
- [[Kanban - My Projects]]
- 





rules after regular rules: 1.6000000000931323 ms
rules running: 1.7999999998137355 ms

and the data.json file

{
  "ruleConfigs": {
    "add-blank-line-after-yaml": {
      "enabled": false
    },
    "dedupe-yaml-array-values": {
      "enabled": false,
      "dedupe-alias-key": true,
      "dedupe-tag-key": true,
      "dedupe-array-keys": true,
      "ignore-keys": ""
    },
    "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": false
    },
    "format-yaml-array": {
      "enabled": false,
      "alias-key": false,
      "tag-key": false,
      "default-array-style": "multi-line",
      "default-array-keys": false,
      "force-single-line-array-style": "",
      "force-multi-line-array-style": ""
    },
    "insert-yaml-attributes": {
      "enabled": false,
      "text-to-insert": "related-companies: \nstakeholders: \npr-priority:\npr-pipeline-stage:\npr-size:\npr-type: \npr-okr: \npr-due-date:\npr-urgency:\npr-completed-date: \ntemplate: \ncreated-date:\nmodified: "
    },
    "move-tags-to-yaml": {
      "enabled": false,
      "how-to-handle-existing-tags": "Nothing",
      "tags-to-ignore": ""
    },
    "remove-yaml-keys": {
      "enabled": false,
      "yaml-keys-to-remove": ""
    },
    "sort-yaml-array-values": {
      "enabled": false,
      "sort-alias-key": true,
      "sort-tag-key": true,
      "sort-array-keys": true,
      "ignore-keys": "",
      "sort-order": "Ascending Alphabetical"
    },
    "yaml-key-sort": {
      "enabled": true,
      "yaml-key-priority-sort-order": "related-companies: \nstakeholders: \npr-pipeline-stage:\npr-priority:\npr-size:\npr-urgency:\npr-type: \npr-okr:\npr-due-date:\npr-completed-date: \ntemplate:\ncreated-date:\nmodified:",
      "priority-keys-at-start-of-yaml": false,
      "yaml-sort-order-for-other-keys": "None"
    },
    "yaml-timestamp": {
      "enabled": false,
      "date-created": true,
      "date-created-key": "date-created",
      "date-created-source-of-truth": "file system",
      "date-modified": true,
      "date-modified-key": "modified",
      "date-modified-source-of-truth": "file system",
      "format": "dddd, MMMM Do YYYY, h:mm:ss a",
      "convert-to-utc": false,
      "update-on-file-contents-updated": "never"
    },
    "yaml-title": {
      "enabled": false,
      "title-key": "title",
      "mode": "first-h1-or-filename-if-h1-missing"
    },
    "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,
      "alias-helper-key": "linter-yaml-title-alias"
    },
    "capitalize-headings": {
      "enabled": false,
      "style": "Title Case",
      "ignore-case-words": true,
      "ignore-words": "macOS, iOS, iPhone, iPad, JavaScript, TypeScript, AppleScript, I",
      "lowercase-words": "a, an, the, aboard, about, abt., above, abreast, absent, across, after, against, along, aloft, alongside, amid, amidst, mid, midst, among, amongst, anti, apropos, around, round, as, aslant, astride, at, atop, ontop, bar, barring, before, B4, behind, below, beneath, neath, beside, besides, between, 'tween, beyond, but, by, chez, circa, c., ca., come, concerning, contra, counting, cum, despite, spite, down, during, effective, ere, except, excepting, excluding, failing, following, for, from, in, including, inside, into, less, like, minus, modulo, mod, near, nearer, nearest, next, notwithstanding, of, o', off, offshore, on, onto, opposite, out, outside, over, o'er, pace, past, pending, per, plus, post, pre, pro, qua, re, regarding, respecting, sans, save, saving, short, since, sub, than, through, thru, throughout, thruout, till, times, to, t', touching, toward, towards, under, underneath, unlike, until, unto, up, upon, versus, vs., v., via, vice, vis-à-vis, wanting, with, w/, w., c̄, within, w/i, without, 'thout, w/o, abroad, adrift, aft, afterward, afterwards, ahead, apart, ashore, aside, away, back, backward, backwards, beforehand, downhill, downstage, downstairs, downstream, downward, downwards, downwind, east, eastward, eastwards, forth, forward, forwards, heavenward, heavenwards, hence, henceforth, here, hereby, herein, hereof, hereto, herewith, home, homeward, homewards, indoors, inward, inwards, leftward, leftwards, north, northeast, northward, northwards, northwest, now, onward, onwards, outdoors, outward, outwards, overboard, overhead, overland, overseas, rightward, rightwards, seaward, seawards, skywards, skyward, south, southeast, southwards, southward, southwest, then, thence, thenceforth, there, thereby, therein, thereof, thereto, therewith, together, underfoot, underground, uphill, upstage, upstairs, upstream, upward, upwards, upwind, west, westward, westwards, when, whence, where, whereby, wherein, whereto, wherewith, although, because, considering, given, granted, if, lest, once, provided, providing, seeing, so, supposing, though, unless, whenever, whereas, wherever, while, whilst, ago, according to, as regards, counter to, instead of, owing to, pertaining to, at the behest of, at the expense of, at the hands of, at risk of, at the risk of, at variance with, by dint of, by means of, by virtue of, by way of, for the sake of, for sake of, for lack of, for want of, from want of, in accordance with, in addition to, in case of, in charge of, in compliance with, in conformity with, in contact with, in exchange for, in favor of, in front of, in lieu of, in light of, in the light of, in line with, in place of, in point of, in quest of, in relation to, in regard to, with regard to, in respect to, with respect to, in return for, in search of, in step with, in touch with, in terms of, in the name of, in view of, on account of, on behalf of, on grounds of, on the grounds of, on the part of, on top of, with a view to, with the exception of, à la, a la, as soon as, as well as, close to, due to, far from, in case, other than, prior to, pursuant to, regardless of, subsequent to, as long as, as much as, as far as, by the time, in as much as, inasmuch, in order to, in order that, even, provide that, if only, whether, whose, whoever, why, how, or not, whatever, what, both, and, or, not only, but also, either, neither, nor, just, rather, no sooner, such, that, yet, is, it"
    },
    "file-name-heading": {
      "enabled": false
    },
    "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": "",
      "skip-words-with-multiple-capitals": false,
      "extra-auto-correct-files": []
    },
    "blockquote-style": {
      "enabled": false,
      "style": "space"
    },
    "convert-bullet-list-markers": {
      "enabled": false
    },
    "default-language-for-code-fences": {
      "enabled": false,
      "default-language": ""
    },
    "emphasis-style": {
      "enabled": false,
      "style": "consistent"
    },
    "no-bare-urls": {
      "enabled": false,
      "no-bare-uris": 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,
      "line-break-indicator": "  "
    },
    "unordered-list-style": {
      "enabled": false,
      "list-style": "consistent"
    },
    "compact-yaml": {
      "enabled": false,
      "inner-new-lines": false
    },
    "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": false
    },
    "empty-line-around-horizontal-rules": {
      "enabled": false
    },
    "empty-line-around-math-blocks": {
      "enabled": false
    },
    "empty-line-around-tables": {
      "enabled": false
    },
    "heading-blank-lines": {
      "enabled": false,
      "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,
      "english-symbols-punctuation-before": "-+;:'\"°%$)]",
      "english-symbols-punctuation-after": "-+'\"([¥$"
    },
    "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": true,
  "displayChanged": true,
  "lintOnFileChange": false,
  "displayLintOnFileChangeNotice": false,
  "settingsConvertedToConfigKeyValues": true,
  "foldersToIgnore": [
    ""
  ],
  "filesToIgnore": [],
  "linterLocale": "system-default",
  "logLevel": "DEBUG",
  "lintCommands": [],
  "customRegexes": [],
  "commonStyles": {
    "aliasArrayStyle": "single-line",
    "tagArrayStyle": "single-line",
    "minimumNumberOfDollarSignsToBeAMathBlock": 2,
    "escapeCharacter": "\"",
    "removeUnnecessaryEscapeCharsForMultiLineArrays": false
  }
}

@pjkaufman
Copy link
Collaborator

I think I see the issue, but I need to double check. It looks like the keys in the settings you provided have a colon at the end of them, but keys should not have a colon in them.

@pjkaufman
Copy link
Collaborator

Yeah. Currently there is nothing in place to handle the specified keys have a colon at the end of them. They also should not have any spaces whitespace after the end of the name except the newline character. So it looks like if you remove the ending colons and spaces if there are any from those values and it should work.

Is there a better way I can present this setting to make it easier to input value to sort by? I am guessing something more akin to what is present for custom commands or custom regex.

@pjkaufman
Copy link
Collaborator

I do think the issue is the whitespace after a couple of the values. I can make a couple of changes that should make it play nice, but I am guessing making the change to where the settings are input will likely make it easier for people in the long run.

@MrJohnWilkinson
Copy link
Author

MrJohnWilkinson commented Oct 26, 2024 via email

@MrJohnWilkinson
Copy link
Author

MrJohnWilkinson commented Oct 26, 2024 via email

@pjkaufman
Copy link
Collaborator

Thanks for the update! I am working on an automatic fix for that whitespace issue. I may even update how that setting is displayed and whatnot to help keep bad input from being added.

@MrJohnWilkinson
Copy link
Author

MrJohnWilkinson commented Oct 26, 2024 via email

@pjkaufman pjkaufman self-assigned this Oct 27, 2024
@pjkaufman pjkaufman added reproducible yaml YAML related issues or features labels Oct 27, 2024
@pjkaufman pjkaufman moved this from Backlog to In Progress in Obsidian Linter Oct 27, 2024
@pjkaufman pjkaufman changed the title Bug: yaml key sort is broken Bug: YAML Key Sort Does Not Work when There is Trailing Whitespace after a Colon in Config Values Oct 27, 2024
@pjkaufman
Copy link
Collaborator

I believe I have a fix. It will hopefully get added soon. I just need to verify all the CI checks pass.

@pjkaufman
Copy link
Collaborator

The change has been merged and should go out with the next release. Please let us know if the issue persists on master or in the next release.

@pjkaufman pjkaufman added the resolution/update-made A change has been made that should resolve this issue or request label Oct 27, 2024
@MrJohnWilkinson
Copy link
Author

MrJohnWilkinson commented Oct 27, 2024 via email

@pjkaufman pjkaufman moved this from In Next Release to Released in Obsidian Linter Dec 24, 2024
@pjkaufman pjkaufman moved this from Released to Previous Release in Obsidian Linter Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible resolution/update-made A change has been made that should resolve this issue or request yaml YAML related issues or features
Projects
Status: Previous Release
Development

Successfully merging a pull request may close this issue.

2 participants