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

I do I turn off the escaping/quoting about C# for a name field? #466

Closed
diberry opened this issue Feb 16, 2019 · 7 comments
Closed

I do I turn off the escaping/quoting about C# for a name field? #466

diberry opened this issue Feb 16, 2019 · 7 comments

Comments

@diberry
Copy link
Contributor

diberry commented Feb 16, 2019

The original TOC looks like:

- name: LUIS Documentation
  href: index.yml
- name: Overview
  expanded: true
  items:
  - name: C#
    href: what-is-luis.md

I want to manipulate the yaml so I change in into JSON with load. Then I check and manipulate (business logic) then I want to dump. The dump adds quotes around the C# which I don't want. Is there an option to turn that off?

  • name: LUIS Documentation
    href: index.yml
  • name: Overview
    expanded: true
    items:
    • name: "C#"
      href: what-is-luis.md
@puzrin
Copy link
Member

puzrin commented Feb 17, 2019

Dumper has some euristic and tries to minimize quoting/escaping automatically. But it's not ideal. This can be "improved" via PR only.

@puzrin puzrin closed this as completed Feb 17, 2019
@diberry
Copy link
Contributor Author

diberry commented Feb 17, 2019

@puzrin Can I create PR to control it through options?

@puzrin
Copy link
Member

puzrin commented Feb 17, 2019

If you can improve existing algorythm - PR will be accepted with high probability.

If you need option - it's better discuss it first to save your time (i don't understand why option needed), but note, i'm against "kludges".

At first glance, string with # is quoted, because # means comment in yaml. But probably it worth to skip if # is not prepended with space and so on. I don't remember exact condition (you will need read yaml spec to not break something else)

@diberry
Copy link
Contributor Author

diberry commented Feb 17, 2019

The Microsoft Docs system doesn't use quotes around characters and phrases that this tool is adding quotes to for escaping. The build system is separated from authoring so the author's don't have to know about escaping or quotes in the same way.

I need the markdown to not be changed from the original in order to make use of this tool's dump function.

@puzrin
Copy link
Member

puzrin commented Feb 17, 2019

This package is about YAML, not something else. Dumper MUST provide guarantee that you can load data back and it will not become broken. So, it tries to not use quoting when possible. But sometime false positives possible because algorythm is not ideal.

Just removing quotes everywhere is not acceptable because that will break spec. But you can try to improve existing euristic to reduce false positives.

@diberry
Copy link
Contributor Author

diberry commented Feb 17, 2019

@puzrin I meant yaml, sorry, too may formats in my head right now. I'll investigate the spec to see where the limitations are.

@puzrin
Copy link
Member

puzrin commented Feb 17, 2019

Keep in mind, this parser is focused on speed, it does NOT have AST and does not keep src formatting details. For example, you can write in source "C\#" or "C#", but "\" will be lost after dump if not required.

In general, this can not be fixed right without full rewrite. But specific things like quoting can be improved.

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