escape.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export declare const getCodePoint: (c: string, index: number) => number;
  2. /**
  3. * Bitset for ASCII characters that need to be escaped in XML.
  4. */
  5. export declare const XML_BITSET_VALUE = 1342177476;
  6. /**
  7. * Encodes all non-ASCII characters, as well as characters not valid in XML
  8. * documents using XML entities. Uses a fast bitset scan instead of RegExp.
  9. *
  10. * If a character has no equivalent entity, a numeric hexadecimal reference
  11. * (eg. `ü`) will be used.
  12. */
  13. export declare function encodeXML(input: string): string;
  14. /**
  15. * Encodes all non-ASCII characters, as well as characters not valid in XML
  16. * documents using numeric hexadecimal reference (eg. `ü`).
  17. *
  18. * Have a look at `escapeUTF8` if you want a more concise output at the expense
  19. * of reduced transportability.
  20. *
  21. * @param data String to escape.
  22. */
  23. export declare const escape: typeof encodeXML;
  24. /**
  25. * Encodes all characters not valid in XML documents using XML entities.
  26. *
  27. * Note that the output will be character-set dependent.
  28. *
  29. * @param data String to escape.
  30. */
  31. export declare const escapeUTF8: (data: string) => string;
  32. /**
  33. * Encodes all characters that have to be escaped in HTML attributes,
  34. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  35. *
  36. * @param data String to escape.
  37. */
  38. export declare const escapeAttribute: (data: string) => string;
  39. /**
  40. * Encodes all characters that have to be escaped in HTML text,
  41. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  42. *
  43. * @param data String to escape.
  44. */
  45. export declare const escapeText: (data: string) => string;
  46. //# sourceMappingURL=escape.d.ts.map