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

Lazy yaml support #49

Merged
merged 8 commits into from
Aug 11, 2018
Merged

Lazy yaml support #49

merged 8 commits into from
Aug 11, 2018

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Aug 11, 2018

This PR will add lazyYAML constructor option to support lazy YAML format.

Motivation

Directives like to specify color code are sometimes looking like not working. A major cause is that YAML parser recognizes # as a comment by following YAML 1.2 spec.

backgroundColor: linear-gradient(to bottom, #fff, #000)

As you can see from this highlight, YAML parser will recognize a string until reached #, and it treats fff, #000) as comment.

Wrapping by quotes is a way of around this mis-recognize, but we recieved some negative feedbacks from user of private alpha test.

Logic

We use a heuristic logic to parse YAML when Marpit class is initialized by lazyYAML: true.

When you are using only supported directives by a plain format like a pair of {key}:{value}, we treat a written text after semicolon as value directly.

If we detect unknown key or allowed YAML special char, we will fallback a parser to strict YAML.

@yhatt yhatt merged commit 17804a4 into master Aug 11, 2018
@yhatt yhatt deleted the lazy-yaml branch August 11, 2018 13:36
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

Successfully merging this pull request may close these issues.

1 participant