Comments ignored in metadata/attributes

Fairly simple bug: inserting comments (%%) in the metadata / attribute section breaks it.
A fairly niche thing, but in my case I use comments to specify certain sections that should not be overwritten when running scripts on my files (I think some plug ins do this too).

Steps to reproduce

Just add this metadata to any file:


aliases: [“Robust design of a future 100% renewable european energy supply system with hydrogen infrastructure”]
authors: [Dilara Gulcin Caglayan, Heidi U. Heinrichs, Martin Robinius, Detlef Stolten]
journal: “International Journal of Hydrogen Energy”
%% begin test %%
year: 2021
DOI: Redirecting
zotero tags: [:books:, unread, :hammer_and_wrench:, hydrogen]
zotero link: zotero://select/items/@Caglayan.DG.2021_RobustDesignFuture
zotero type: “journalArticle”
obsidian type: “zotero note”
model: thing
%% end test %%
region:
tags:
date: 2023-12-14

Did you follow the troubleshooting guide?

Yep. Stuff fails in the sandbox too.

Expected result

Comments should be ignored and the metadata should be rendered.

Actual result

The attributes section dies a sad death.

Environment

SYSTEM INFO:
Obsidian version: v1.4.16
Installer version: v1.4.16
Operating system: #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 5.15.0-89-generic
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 7
Plugins enabled: 7
1: Citations v0.4.5
2: Advanced Tables v0.19.1
3: Quick Latex for Obsidian v2.6.3
4: Frontmatter Tag Suggest v0.4.1
5: Tag Wrangler v0.6.1
6: Templater v1.18.3
7: Zotero Integration v3.0.12


This is not a bug. We do not and will not support comments %% in the metadata section. It’s not even valid YAML. Sorry!

Moved to help

1 Like

Fair enough!

Your use case depends on text being in certain places in your frontmatter, which is slightly risky as Obsidian in certain cases might rewrite the entire frontmatter. However, if we ignore that you could change your “flag” which has been comments, to be an actual property.

You could write this as:

---
aliases: ["Robust design of a future 100% renewable european energy supply system with hydrogen infrastructure"]  
authors: ["Dilara Gulcin Caglayan", "Heidi U. Heinrichs", "Martin Robinius", "Detlef Stolten"]  
journal: "International Journal of Hydrogen Energy"  
begin_test: true  
year: 2021  
zotero link: zotero://select/items/@Caglayan.DG.2021_RobustDesignFuture  
zotero type: "journalArticle"
obsidian type: "zotero note" 
model: thing  
end_test: true  
region:  
tags:  
date: 2023-12-14
---

The following are just invalid, and I'm not sure how to write these to make them valid...

DOI: ["[Redirecting](https://doi.org/10.1016/j.ijhydene.2020.12.197)"]
zotero tags: [![:books:](https://forum.obsidian.md/images/emoji/apple/books.png?v=12 ":books:"), unread, ![:hammer_and_wrench:](https://forum.obsidian.md/images/emoji/apple/hammer_and_wrench.png?v=12 ":hammer_and_wrench:"), hydrogen]  

The point I’m trying to make is that since you’re doing a text match, it shouldn’t be a problem to make your test both unique and at the same time be a valid property.

Adding test attributes to the metadata would solve the problem on my side, but unfortunately not on the side of the Zotero Integration plug-in I use, which requires the use of %% %%.

I think the fix is just using YAML comments (#) , since they work in the frontmatter.

I can fix that on my end, partially, but now I depend on the plug-in adding a fix to this.

As for using hyperlinks for the metadata: that was an error when I pasted the code. I apologise.

Here is the actual code:

---
aliases: ["Robust design of a future 100% renewable european energy supply system with hydrogen infrastructure"]
authors: [Dilara Gulcin Caglayan, Heidi U. Heinrichs, Martin Robinius, Detlef Stolten]
journal: "International Journal of Hydrogen Energy"
year: 2021
DOI: https://doi.org/10.1016/j.ijhydene.2020.12.197
zotero tags: [📚, unread, 🛠️, hydrogen]
zotero link: zotero://select/items/@Caglayan.DG.2021_RobustDesignFuture
zotero type: "journalArticle" 
obsidian type: "zotero note"
model:
region:
tags: 
date: 2023-12-14
---

Ok, so I might have actually found something:

I tried protecting my commands using valid YAML comments via #
But Obsidian automatically deletes them if you modify the properties in any way!

Is there an option to avoid this behaviour?
This would be a super simple fix, and would help plug-in devs using formatting languages avoid developing over complicated workarounds.

That shouldn’t have been a surprise to you, as I hinted about that before.

Come to think of it you might be better off using inline fields for the automated zotero parts. That would allow you to use the comments syntax, and Obsidian will not reformat the entries. Now the question becomes, can you generate online fields and not only properties from your generator? (To which I don’t know the answer)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.