How to output simple keys regardless of length ("128 chars hardcoded limit")
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.2k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Description
- How to output YAML (from Ruby) with simple keys regardless of length?
- What is the rationale for the (hard-coded) limit of 128 chars? (Include reference to standard)
require 'psych'
%w[
https://example.com/this-url-shy-of-one-hundred-and-twenty-eight-characters-causes-libyaml-not-to-prefix-it-with-a-question-mark
https://example.com/this-url-longer-than-one-hundred-and-twenty-eight-characters-causes-libyaml-to-prefix-it-with-a-question-mark
].to_h { [it, it.length] }.to_yaml(line_width: -1).then { puts it }
---
https://example.com/this-url-shy-of-one-hundred-and-twenty-eight-characters-causes-libyaml-not-to-prefix-it-with-a-question-mark: 128
? https://example.com/this-url-longer-than-one-hundred-and-twenty-eight-characters-causes-libyaml-to-prefix-it-with-a-question-mark
: 129
https://github.com/yaml/libyaml/blob/master/src/emitter.c#L1187
yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
<snip>
if (length > 128)
return 0;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/emitter.c at yaml_emitter_check_simple_key(), especially the 128-character check, and reproduce the behavior using the Ruby/Psych example in the issue. Check the YAML standard reference relevant to simple keys and document the rationale and whether libyaml provides a way to emit these keys without the question-mark indicator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, yaml
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100