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

Adding escape character for dots in YAML keys #87

Open
serkodev opened this issue Aug 17, 2024 · 1 comment · May be fixed by #88
Open

Adding escape character for dots in YAML keys #87

serkodev opened this issue Aug 17, 2024 · 1 comment · May be fixed by #88
Labels
enhancement New feature or request

Comments

@serkodev
Copy link

serkodev commented Aug 17, 2024

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

Yes

In Nuxt Content, I'm trying to add a Vue component with props in YAML format, but I'm encountering an issue with keys that contain a dot (.). Here’s an example of the YAML:

::comp
---
foo.bar: 1
---
::

Currently, remark-mdc uses flat.unflatten in parseFrontMatter, which transforms parent.child keys into a nested structure, like this:

::comp
---
foo:
  bar: 1
---
::

While I understand that this feature is designed to support nested keys, in my case, I need to retain the dots in the original keys (e.g., foo.bar). Is it possible to introduce an escape character (e.g., foo\.bar) to prevent the transformation and preserve the key format?

Thanks for considering this feature!

Additional Infomation

Alternatively, another approach that may be more aligned with YAML's general behavior is to support explicit string keys. For example:

::comp
---
"foo.bar": 1
---
::

This would ensure that the key remains as a string and is not interpreted as a nested structure BUT it maybe hard to implement because need to customize to YAML parser / lexer.

@serkodev serkodev added the enhancement New feature or request label Aug 17, 2024
@serkodev serkodev linked a pull request Aug 17, 2024 that will close this issue
@serkodev
Copy link
Author

I just drafted a PR (#88) to implement escape for unflatten.

However, I need some assistance on stringifyFrontMatter and stringifyCodeBlockProps. Are any maintainers available to take a look? Your help would be greatly appreciated. Thanks!

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

Successfully merging a pull request may close this issue.

1 participant