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

Enhancement: Support comma separated arrays in front matter #102

Closed
iranzo opened this issue Sep 15, 2021 · 11 comments
Closed

Enhancement: Support comma separated arrays in front matter #102

iranzo opened this issue Sep 15, 2021 · 11 comments
Milestone

Comments

@iranzo
Copy link

iranzo commented Sep 15, 2021

Is your feature request related to a problem? Please describe.

When using Pelican markdown files with frontmatter I get several issues:

  • Tags are added a quote all together, I guess because it expects array type with quoted items, which is not the case with Pelican
  • date and modified are quoted... again, not what Pelican expects, causing failures on rendering

Describe the solution you'd like

Allow configurable 'frontmatter' styling for 'hugo', 'pelican' or others

Describe alternatives you've considered
So far, disabling and uninstalling the extension as it was breaking the articles I've. I've tried setting date format in settings and not add quotes, but still it adds them.

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

BTW I've found the "frontMatter.taxonomy.noPropertyValueQuotes": ["modified", "date", "tags"], but I think that a dropdown to select compatibility will make it easier ;-)

@estruyf
Copy link
Owner

estruyf commented Sep 15, 2021

Thank @iranzo for reporting this. The frontMatter.taxonomy.noPropertyValueQuotes setting is exactly meant for this. As some need quotes, and others don't.

Having an optimized settings experience is on backlog #80. The dropdown would be a nice addition to it.

I did some tests, and in the projects, I use for testing it is working as expected, but it might be because of all use YAML.

What is Pelican using? Would you be able to share a sample page with the front matter and content?

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

I think that there are other things involved in the way Frontmatter processes the files:

image

Even if the quotes are not enabled to be used, seems that it tries to read those as 'hugo'-style keys/values

@estruyf
Copy link
Owner

estruyf commented Sep 15, 2021

Hugo doesn't use a style, they use YAML format, like other site generators. It is gray-matter which does the parsing.

I'll validate it against your blog content, thanks for the reference.

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

Sorry, for 'style' I meant for arrays, pelican uses comma separated words, but seems that it expects a [ and ] for specifying more than one tag

@estruyf
Copy link
Owner

estruyf commented Sep 15, 2021

There are two issues:

  1. The title contains [] - so the YAML parser thinks you're adding an array
  2. Arrays in YAML can be [] or like:
tags:
  - tag 1
  - tag 2

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

Yes, and 'neither' example 1, or example 2 are taken by pelican (I guess it should), but only parses keywords as comma-separated words

@estruyf
Copy link
Owner

estruyf commented Sep 15, 2021

The title will need to be manually escaped. I will add a title input on the panel as well soon so that it will automatically escape it for you.

Screenshot 2021-09-15 at 14 56 46

Screenshot 2021-09-15 at 14 57 10

@estruyf estruyf changed the title Enhancement: Pelican Supprot Enhancement: Support comma separated arrays in front matter Sep 15, 2021
@estruyf
Copy link
Owner

estruyf commented Sep 15, 2021

I got good news, I changed some internal logic and the new version will be able to work with comma-separated array values.

In order to support this, you'll have to do the following in your settings.json:

{
  "frontMatter.taxonomy.commaSeparatedFields": [
    "tags"
  ],
  "frontMatter.taxonomy.noPropertyValueQuotes": [
    "tags"
  ],
  "frontMatter.taxonomy.tags": [
    "Packt Publishing",
    "RHCSA",
    "RHEL",
    "book",
    "system administration",
    "foss"
  ]
}

As the comma-separated arrays are not valid YAML, you will have to let Front Matter know how to parse it. That is why the new frontMatter.taxonomy.commaSeparatedFields is introduced.

If you want to test it out, you can install the beta version of Front Matter: https://beta.frontmatter.codes - https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter-beta

Be sure to uninstall the main version, as the two cannot run or be installed at the same time.

@iranzo
Copy link
Author

iranzo commented Sep 15, 2021

Great, it seems to work fine with the tags, looking forward for the autoescape too!

Thanks a lot!

@estruyf estruyf added this to the 3.2.0 milestone Sep 15, 2021
estruyf added a commit that referenced this issue Sep 15, 2021
@estruyf estruyf closed this as completed Sep 22, 2021
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

2 participants