Merged
Conversation
mholt
reviewed
May 16, 2020
|
This is beautiful. 😍 |
Owner
|
Very nice! Please add a test file per the instructions in lexers/README.md. Overall looks pretty good, I'll come back with some suggestions shortly. |
alecthomas
approved these changes
May 16, 2020
| ) | ||
|
|
||
| // CaddyfileCommon are the rules common to both of the lexer variants | ||
| var CaddyfileCommon = Rules{ |
Owner
There was a problem hiding this comment.
No need to make this or the other intermediate values public.
Owner
|
LGTM, merged. Any followups just send a new PR. |
Owner
|
Thanks! |
Contributor
Author
|
Thank you @alecthomas!! I already made a PR to update the Caddy website with this caddyserver/website#41 I definitely will have a followup PR soon, I noticed a few edgecases that aren't well covered. |
mrsdizzie
pushed a commit
to mrsdizzie/chroma
that referenced
this pull request
Jul 15, 2020
Might be useful for alecthomas#363.
mrsdizzie
pushed a commit
to mrsdizzie/chroma
that referenced
this pull request
Jul 15, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #338
So, I definitely have no idea what I'm doing 😄
I spent most of the day hacking on this, seems like it's in decent shape, but who knows. There's probably a much better way to approach it, but this is what I came up with after trying to resolve a ton of edge cases.
I was testing it doing a spam of:
and
$ go build && ./chroma --trace -l caddyfile CaddyfileI implemented two lexers here because we have two main usecases - displaying a full Caddyfile config, and showing just partials (matchers and directives) in documentation and such.
I'm not certain which token types to pick, I just kinda with what sorta made sense and made it look pretty in the output 🤷♂️
I'd very much appreciate any tips/feedback on this. 🎉
Here's a couple somewhat representative config examples and screenshots. Caddyfiles are very rarely this long or complicated, but these show most of the tricky elements.
{ debug } example.com, fake.org { root * /srv route { # Add trailing slash for directory requests @canonicalPath { file { try_files {path}/index.php } not path */ } redir @canonicalPath {path}/ 308 # If the requested file does not exist, try index files @indexFiles { file { try_files {path} {path}/index.php index.php split_path .php } } rewrite @indexFiles {http.matchers.file.relative} # Proxy PHP files to the FastCGI responder @phpFiles { path *.php } reverse_proxy @phpFiles unix//var/run/php7.4-fpm.sock { transport fastcgi { split .php } } } @encode_exts { path / *.html *.js *.css *.svg } header { X-Content-Type-Options nosniff X-XSS-Protection "1; mode=block" X-Robots-Tag none Content-Security-Policy "frame-ancestors 'self'" X-Frame-Options DENY Referrer-Policy same-origin } @singleLine not path /matcher respond @singleLine "Awesome." file_server }Another:
Screenshots:

Another:
