You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

phtml.go 889B

12345678910111213141516171819202122232425262728293031323334
  1. package circular
  2. import (
  3. "strings"
  4. . "github.com/alecthomas/chroma" // nolint
  5. "github.com/alecthomas/chroma/lexers/h"
  6. "github.com/alecthomas/chroma/lexers/internal"
  7. )
  8. // PHTML lexer is PHP in HTML.
  9. var PHTML = internal.Register(DelegatingLexer(h.HTML, MustNewLexer(
  10. &Config{
  11. Name: "PHTML",
  12. Aliases: []string{"phtml"},
  13. Filenames: []string{"*.phtml"},
  14. MimeTypes: []string{"application/x-php", "application/x-httpd-php", "application/x-httpd-php3", "application/x-httpd-php4", "application/x-httpd-php5"},
  15. DotAll: true,
  16. CaseInsensitive: true,
  17. EnsureNL: true,
  18. },
  19. Rules{
  20. "root": {
  21. {`<\?(php)?`, CommentPreproc, Push("php")},
  22. {`[^<]+`, Other, nil},
  23. {`<`, Other, nil},
  24. },
  25. }.Merge(phpCommonRules),
  26. ).SetAnalyser(func(text string) float32 {
  27. if strings.Contains(text, "<?php") {
  28. return 0.5
  29. }
  30. return 0.0
  31. })))