extensions.go 622 B

1234567891011121314151617181920212223242526272829303132
  1. // Package files provides utility functions over document/template files.
  2. package files
  3. import (
  4. "path/filepath"
  5. "strings"
  6. )
  7. // HasKnownMarkdownExt returns true if file has a known Markdown extension.
  8. func HasKnownMarkdownExt(file string) bool {
  9. ext := strings.ToLower(filepath.Ext(file))
  10. switch ext {
  11. case ".md", ".markdown":
  12. return true
  13. }
  14. return false
  15. }
  16. // HasKnownHTMLExt returns true if file has a known HTML extension.
  17. func HasKnownHTMLExt(file string) bool {
  18. ext := strings.ToLower(filepath.Ext(file))
  19. switch ext {
  20. case ".html", ".htm", ".xhtml", ".xhtm", ".xht":
  21. return true
  22. }
  23. return false
  24. }