Skip to content

Adding escape character for dots in YAML keys #87

@serkodev

Description

@serkodev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions