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 option removes multi-line content after literal operator | #1082

Open
2 of 3 tasks
CharmedSatyr opened this issue Apr 30, 2024 · 4 comments
Open
2 of 3 tasks
Labels
bug Something isn't working help wanted Extra attention is needed yaml YAML related issues or features

Comments

@CharmedSatyr
Copy link

CharmedSatyr commented Apr 30, 2024

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

Describe the Bug

When the YAML Key Sort option Sorts the YAML keys based on the order and priority specified. and a YAML Sort Order for Other Keys order is enabled, nested content after a literal operator | is removed.

This is a problem for me because I'm using Obsidian Custom Sort, which recommends syntax with a sorting-spec key followed by a literal operator.

How to Reproduce

  1. Enable Settings > Linter > Sorts the YAML keys based on the order and priority specified.
  2. Set YAML Sort Order for Other Keys to Ascending Alphabetical or Descending Alphabetical.
  3. Add front matter with a literal operator and nested content.
  4. Run the linter.
  5. The nested lines after the | will be removed.

Example

---
sorting-spec: |
  order-desc: a-z
---

order-desc: a-z will be removed.

Expected Behavior

Nested content after a literal operator should not be removed.

Device

  • Desktop
  • Mobile
@CharmedSatyr CharmedSatyr added the bug Something isn't working label Apr 30, 2024
@pjkaufman
Copy link
Collaborator

Hey @CharmedSatyr . I believe this is a known issue. I don't think the Linter currently supports that syntax for YAML values, but I am open to changes to add that kind of support to the Linter.

@pjkaufman pjkaufman added help wanted Extra attention is needed yaml YAML related issues or features labels Apr 30, 2024
@CharmedSatyr
Copy link
Author

Thanks @pjkaufman. There is a note in the option about blank lines being removed and nested keys not being sorted. However, for me, it is unexpected behavior that the linter would delete (potentially lots of) non-blank lines of properly formatted front matter. This ticket does feel like a bug rather than feature request for that reason.

@pjkaufman
Copy link
Collaborator

Hey @CharmedSatyr , this is a bug, but it has come up before if I recall and the issue was using a syntax that the Linter currently does not properly handle. There have been discussions on how to fix this, but none of them have yielded any fruit for now. So this is something where I am looking for help from other devs to contribute a fix for this issue as this literal operator is not currently handled by the Linter.

@pjkaufman
Copy link
Collaborator

For context, the prior report of this bug was #992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed yaml YAML related issues or features
Projects
None yet
Development

No branches or pull requests

2 participants