-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
(http) highlight http headers without HTTP preamble #3019
Comments
Yes, that would be it. Not sure what the easy fix for this is though. <script src="highlight.min.js" />
<script>
let http = hljs.getLanguage("http");
// move HEADERS_AND_BODY back to the parent ruleset
http.contains = [].concat(http.contains, http.contains[0].starts.contains)
</script> Again, not sure that is a good idea though (depending on use case). I'd also perhaps be OK with disabling the inner One other possibility might be to change |
Is there some cheap/cheat way we could support this if the language is explicitly provided? I.e, if I'm sure it's http and I go through |
I'm not sure how off the top of my head... there is truly ONLY And I think you'd still want to solve the sublanguage recursion issue. |
I think it might be ok if we added a HEADER rule to the top-level (with 0 relevance because it's too conflicting with auto-detect)... so then you'd have two choices:
This might add a bit more utility while also creating a bit more confusion. IE take line 15 and pull that out into a HEADER rule that matches at the top. Thoughts? |
That sounds reasonable... if one wants autodetect to work, then one must include the preamble. Otherwise, one must be explicit that it's http. |
Well the potential point of confusion is that HEADERS + BODY will NOT work (regardless - body won't get highlighted, only headers)... that requires the preamble. The preamble is the guard that triggers "full" support. IE, Body highlighting is triggered only by the preamble. |
ah, got it. I think that seems reasonable. |
Describe the issue
It should be possible to declare http key/value pairs without requiring HTTP preamble.
For example, just:
Some-header: value
Which language seems to have the issue?
HTTP
Are you using
highlight
orhighlightAuto
?highlightAuto
...
Sample Code to Reproduce
Referer: value
Expected behavior
Should output:
Additional context
Appears to be a regression from 10.5. It used to work. Maybe #2893?
The text was updated successfully, but these errors were encountered: