octiconImg returns an img tag for an Octicon that works with GitHub's light/dark theme. Uses picture element with prefers-color-scheme for automatic theme switching. References icons from the repo's pkg/octicons/icons directory. Optional pathPrefix for files in subdirectories (e.g., "../" for docs/)
(name string, pathPrefix ...string)
| 133 | // References icons from the repo's pkg/octicons/icons directory. |
| 134 | // Optional pathPrefix for files in subdirectories (e.g., "../" for docs/). |
| 135 | func octiconImg(name string, pathPrefix ...string) string { |
| 136 | if name == "" { |
| 137 | return "" |
| 138 | } |
| 139 | prefix := "" |
| 140 | if len(pathPrefix) > 0 { |
| 141 | prefix = pathPrefix[0] |
| 142 | } |
| 143 | // Use picture element with media queries for light/dark mode support |
| 144 | // GitHub renders these correctly in markdown |
| 145 | lightIcon := fmt.Sprintf("%spkg/octicons/icons/%s-light.png", prefix, name) |
| 146 | darkIcon := fmt.Sprintf("%spkg/octicons/icons/%s-dark.png", prefix, name) |
| 147 | return fmt.Sprintf(`<picture><source media="(prefers-color-scheme: dark)" srcset="%s"><source media="(prefers-color-scheme: light)" srcset="%s"><img src="%s" width="20" height="20" alt="%s"></picture>`, darkIcon, lightIcon, lightIcon, name) |
| 148 | } |
| 149 | |
| 150 | func generateToolsetsDoc(i *inventory.Inventory) string { |
| 151 | var buf strings.Builder |
no outgoing calls
no test coverage detected