FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Major updates to Caddyfile lexer by francislavoie · Pull Request #932 · alecthomas/chroma · GitHub

Repository navigation

Major updates to Caddyfile lexer - #932

Merged
alecthomas merged 3 commits into
alecthomas:masterfrom
francislavoie:caddyfile-updates
Feb 20, 2024
Merged

alecthomas merged 3 commits into
alecthomas:masterfrom
francislavoie:caddyfile-updates

Conversation

Copy link
Copy Markdown
Contributor

Since I've last touched the lexer in #363 #365 we've had plenty of minor syntax adjustments to the Caddyfile. Took me a long time to get in the headspace to want to tackle updating the lexer, it's quite complicated!

We use this lexer for the official Caddy docs https://caddyserver.com/docs/caddyfile/concepts where Caddy itself serves its own syntax via Markdown. It's awesome that Caddy can highlight its own code 😁

I went through every page in the docs we have to find all the edgecases that were broken in one way or another. I used a go.mod replace in Caddy to point to my checkout of Chroma which I was editing, and used https://github.com/cespare/reflex to watch for my file changes and rebuild+restart Caddy so I could just refresh my browser to see effect of my changes to the lexer. I used this crazy command to do this (had to cross through 3 different git repos with cd 😂)

$ (cd ../../../chroma/ && reflex -s -g 'lexers/caddyfile.go' -- sh -c 'cd ../caddy/cmd/caddy && go build && cd ../../../website/ && ../caddy/cmd/caddy/caddy run')

Added lots more contrived config examples to the caddyfile.actual test to cover most of the changes I've made.

I'm not satisfied with the heredoc (see #929) because I'd like to be able to parse the placeholders (LiteralStringEscape) inside the heredoc text, but I'd probably need to write a custom Mutator to do that and that felt daunting. But good enough for now I think.

francislavoie commented Feb 20, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

lexers/caddyfile.go:11:5: G101: Potential hardcoded credentials (gosec)

😂 what the heck, I guess I'll throw a // nolint on that

alecthomas merged commit 381050b into alecthomas:master Feb 20, 2024

Copy link
Copy Markdown
Owner

Go home linter, you're drunk.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL