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

more detail in HTTP language #2718

Closed
Jxck opened this issue Jan 17, 2021 · 2 comments · Fixed by #2722
Closed

more detail in HTTP language #2718

Jxck opened this issue Jan 17, 2021 · 2 comments · Fixed by #2722

Comments

@Jxck
Copy link
Contributor

Jxck commented Jan 17, 2021

Motivation

in http language, request-line / response-status are less tokenized for me.

I would like to make PR if it works.

Description

request line

current request-line

GET /path HTTP/1.1

results in

<span class="token request-line">
    <span class="token property">POST</span>
    /default-endpoint HTTP/1.1
</span>

would like to be

<span class="token request-line">
    <span class="token method">POST</span>
    <span class="token string">/default-endpoint</span>
    <span class="token property">HTTP/1.1</span>
</span>

response status

current response status

HTTP/1.1 200 OK

results in

<span class="token response-status">
    HTTP/1.1
    <span class="token property">200 OK</span>
</span>

would like to be

<span class="token response-status">
    <span class="token property">HTTP/1.1</span>
    <span class="token number">200</span>
    <span class="token string">OK</span>
</span>

class name are wip, ping me if other choice fit's here.

@RunDevelopment
Copy link
Member

I would like to make PR if it works.

PRs are always welcome!

class names are wip

My suggestion for class names is the following: make the token name specific and use aliases for coloring.

Example:

<span class="token response-status">
    <span class="token http-version property">HTTP/1.1</span>
    <span class="token status-code number">200</span>
    <span class="token reason-phrase string">OK</span>
</span>

The grammar could look like this:

'response-status': {
	pattern: /.../,
	inside: {
		'http-version': {
			pattern: /^HTTP\/[\d.]+/,
			alias: 'property'
		},
		'status-code': {
			pattern: /^(\s)\d+(?=\s)/,
			lookbehind: true,
			alias: 'number'
		},
		'reason-phrase': {
			pattern: /^(\s).+/,
			lookbehind: true,
			alias: 'string'
		}
	}
}

(I borrowed those names from the HTTP 1.1 specification but you may also use other names.)

@Jxck
Copy link
Contributor Author

Jxck commented Jan 17, 2021

My suggestion for class names is the following: make the token name specific and use aliases for coloring.

it seems reasonable for me.
I'll fix request-line too refer your suggest, and make PR soon.
Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants