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

Obsidian: Front Matter Template does not publish "double quotes" to Obsidian YAML #3981

Open
MasssiveJuice08 opened this issue May 21, 2024 · 5 comments

Comments

@MasssiveJuice08
Copy link

Issue

"Double quotation" speech marks entered into the Omnivore plugin's custom frontmatter do not get entered into Obsidian YAML frontmatter.

I have my custom frontmatter template I have the following three lines:

dg-metatags:
 description: "{{{description}}}"
 "og:image": "https://i.imgur.com/LmCg5HX.png"

Expected behaviour:

  1. the contents of "{{{description}}}" should be published in the YAML as being surrounded by "double quotations".
  2. "og:image": "https://i.imgur.com/LmCg5HX.png" should be published in the YAML as-is.

Actual behaviour:

  1. Article {{{description}}} is rendered without double quotations in YAML
  2. "og:image": "https://i.imgur.com/LmCg5HX.png" is published as og:image: https://i.imgur.com/LmCg5HX.png without double quotations in YAML

Example

For an article whose {{{description}}} is "A Short History of Morrowind" the frontmatter is published in Obsidian by Omnivore like so:

dg-metatags:
 description: A Short History of Morrowind
 og:image: https://i.imgur.com/LmCg5HX.png

Expected behaviour:

dg-metatags:
 description: "A Short History of Morrowind"
 "og:image": "https://i.imgur.com/LmCg5HX.png"

Frontmatter template in Obsidian:

custom frontmatter template in Omnivore plugin


Obsidian YAML frontmatter of an article without double quotations

published Obsidian frontmatter without double quotations


My full custom frontmatter template looks like this:

id: {{{id}}}
title: >
  {{{title}}}
{{#author}}
author: >
  {{{author}}}
{{/author}}
{{#labels.length}}
tags:
{{#labels}} - {{{name}}}
{{/labels}}
{{/labels.length}}
date_saved: {{{dateSaved}}}
{{#datePublished}}
date_published: {{{datePublished}}}
{{/datePublished}}
site_name: {{siteName}}
original_url: {{{omnivoreUrl}}}
dg-publish: true
dg-metatags:
 description: "{{{description}}}"
 "og:image": "https://i.imgur.com/LmCg5HX.png"
@jacksonh
Copy link
Contributor

I don't think that will work because what if the description has quotes in it?

@MasssiveJuice08
Copy link
Author

Fair point, although article descriptions can be manually changed in Omnivore, so as long as I change these to be YAML compliant then that shouldn't be an issue.


Would this be the reason why the quotation marks aren't being used? In data.json they are being escaped as special characters \"

data.json file showing quotations being escaped

@jacksonh
Copy link
Contributor

I don't think thats the issue, i suspect its because we validate in a YAML library and then spit out the validated YAML. But let me verify that with @sywhb

One question: why do you need the quotes? Without white space isn't og:image evaluated to the same thing in YAML as "og:image" or are they treated as different properties?

@MasssiveJuice08
Copy link
Author

One question: why do you need the quotes? Without white space isn't og:image evaluated to the same thing in YAML as "og:image" or are they treated as different properties?

I think I might not actually need the double quotations. I'm publishing my vault online using Obsidian-Digital-Garden, and I'm just following the docs here on setting metatags for a page, and the example screenshot shows the aforementioned YAML lines as being surrounded by double quotes. However, I tested on Omnivore article pages which have been published on my site and the metatags all render just fine. The page I actually used as an example in my first post even works – History of Morrowind - The Unofficial Elder Scrolls Pages (UESP).

So for my specific use case, this issue is resolved. It might be useful to keep open though for any other possible use-cases where you'd want the Omnivore frontmatter template to publish double quotations.

@sywhb
Copy link
Contributor

sywhb commented May 22, 2024

"og:image"

Yeah, that's right. We use the library provided by Obsidian to parse YAML file first to validate it and it will remove the outer quotation marks unless the value is a multiline string or some other cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants