Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

README.md 1.9 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. sanitize [![GoDoc](https://godoc.org/github.com/kennygrant/sanitize?status.svg)](https://godoc.org/github.com/kennygrant/sanitize) [![Go Report Card](https://goreportcard.com/badge/github.com/kennygrant/sanitize)](https://goreportcard.com/report/github.com/kennygrant/sanitize) [![CircleCI](https://circleci.com/gh/kennygrant/sanitize.svg?style=svg)](https://circleci.com/gh/kennygrant/sanitize)
  2. ========
  3. Package sanitize provides functions to sanitize html and paths with go (golang).
  4. FUNCTIONS
  5. ```go
  6. sanitize.Accents(s string) string
  7. ```
  8. Accents replaces a set of accented characters with ascii equivalents.
  9. ```go
  10. sanitize.BaseName(s string) string
  11. ```
  12. BaseName makes a string safe to use in a file name, producing a sanitized basename replacing . or / with -. Unlike Name no attempt is made to normalise text as a path.
  13. ```go
  14. sanitize.HTML(s string) string
  15. ```
  16. HTML strips html tags with a very simple parser, replace common entities, and escape < and > in the result. The result is intended to be used as plain text.
  17. ```go
  18. sanitize.HTMLAllowing(s string, args...[]string) (string, error)
  19. ```
  20. HTMLAllowing parses html and allow certain tags and attributes from the lists optionally specified by args - args[0] is a list of allowed tags, args[1] is a list of allowed attributes. If either is missing default sets are used.
  21. ```go
  22. sanitize.Name(s string) string
  23. ```
  24. Name makes a string safe to use in a file name by first finding the path basename, then replacing non-ascii characters.
  25. ```go
  26. sanitize.Path(s string) string
  27. ```
  28. Path makes a string safe to use as an url path.
  29. Changes
  30. -------
  31. Version 1.2
  32. Adjusted HTML function to avoid linter warning
  33. Added more tests from https://githubengineering.com/githubs-post-csp-journey/
  34. Chnaged name of license file
  35. Added badges and change log to readme
  36. Version 1.1
  37. Fixed type in comments.
  38. Merge pull request from Povilas Balzaravicius Pawka
  39. - replace br tags with newline even when they contain a space
  40. Version 1.0
  41. First release