platers / obsidian-linter

An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.
https://platers.github.io/obsidian-linter/
MIT License
1.18k stars 80 forks source link

Bug: Paste Seems to Mess with YAML Frontmatter #653

Closed SirSpidey closed 1 year ago

SirSpidey commented 1 year ago

Describe the Bug

I use a textexpander plain text snippet to create the yaml metadata. When the linter extension is enabled, the yaml is reformatted to invalid yaml even when linting is not run. I haven't been able to identify which linter setting is causing the issue, if that's the problem.

How to Reproduce

Steps to reproduce the behavior:

  1. Create a note in obsidian
  2. Run a snippet or macro that outputs the yaml.
  3. See error

Although the textexpander snippet has date variables, that isn't the cause of the problem. The snippet in Raycast is just this text, and the reformatting still happens:

---
created: 
aliases: []
source: 
tags: []
updated: 
---

Expected Behavior

A clear and concise description of what you expected to happen.

Expected output if applicable:

---
created: "2023-03-17"
aliases: []
source: 
tags: []
updated: "2023-03-17T11:51:50-0400"
---

Actual behavior

The 3rd hyphen on the first line and new line are removed

--created: "2023-03-17"
aliases: []
source: 
tags: []
updated: "2023-03-17T11:52:15-0400"
---

Screenshots

If applicable, add screenshots to help explain your problem.

Device

Additional Context

Add any other context about the problem here. data.json.zip

pjkaufman commented 1 year ago

@SirSpidey , thanks for reporting this. Could you provide the macro in question or one that creates the issue and an explanation on setting that up so I can recreate the scenario? I as it stands I am not sure how to reproduce what you are stating since I do not have a setup like that personally.

SirSpidey commented 1 year ago

@pjkaufman Yeah, this is a tough one to reproduce if you don't have either app. I tried reproducing with MacOS text replacements and with a free open source package called espanso, but neither one cause the issue. I'm not sure what TextExpander and Raycast snippets do differently when they insert the snippets.

Raycast is free and an awesome new tool. So if you're so inclined 😸 , you could install it and create a snippet like the one here.

image

But if not, you can just close this issue as not reproducible.

SirSpidey commented 1 year ago

I couldn't reproduce the issue by using the old obsidian plug-in Text snippets, So TextExpander and Raycast, which use keylogger permissions (Privacy & Security -> Accessibility), must be doing something that's interpreted differently in Obsidian when your extension is enabled.

However, I did find a workaround for TextExpander that works with Linter and in other text editors: I added a carriage return to the end of first line

image

Closing as not reproducible

pjkaufman commented 1 year ago

I will note that I see this problem every once and a while when I paste a value. I need to check and see if this is something the Linter accidentally does.

pjkaufman commented 1 year ago

Looks like I can reproduce this on my personal setup. It is unclear as to why. I am going to reopen this and see about fixing it.

pjkaufman commented 1 year ago

I am guessing this is due to the logic for removing hyphens on paste.

pjkaufman commented 1 year ago

I believe that I have a fix for the problem as I am no longer seeing it. I will push up my change to fix this and it should go out with the next release.