Skip to content

Commit

Permalink
add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricedesaxe committed Jul 19, 2024
1 parent f847835 commit 7d6f295
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ func assert(condition bool, msg string) {
}
}

// The main function that runs the templCSSSort.
// Takes in flags to determine what to sort and where to sort it.
// If no flags are set, it will sort all .templ files in the current directory and its subdirectories.
// With the --stdin flag, it will read from stdin and write to stdout.
// With the --file flag, it will only sort the specified file.
// With the --dir flag, it will only sort the specified directory and its subdirectories.
func templCSSSort(flags Flags) {
start := time.Now()

Expand Down Expand Up @@ -133,6 +139,7 @@ func templCSSSort(flags Flags) {
log.Println("Done in", time.Since(start))
}

// Takes a string of content and returns a string of content with the classes sorted
func processContent(content string) (string, error) {
// find all classes in content
re := regexp.MustCompile(`class="([^"]+)"`)
Expand Down Expand Up @@ -189,6 +196,7 @@ func processContent(content string) (string, error) {
return content, nil
}

// Takes a slice of strings and returns a slice of strings with duplicates removed
func removeDuplicates(slice []string) []string {
keys := make(map[string]bool)
list := []string{}
Expand Down

0 comments on commit 7d6f295

Please sign in to comment.