format-smart.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Configurable ways to encode a character yielding pretty or small results.
  3. *
  4. * @param {number} code
  5. * @param {number} next
  6. * @param {FormatSmartOptions} options
  7. * @returns {string}
  8. */
  9. export function formatSmart(code: number, next: number, options: FormatSmartOptions): string;
  10. export type FormatSmartOptions = {
  11. /**
  12. * Prefer named character references (`&`) where possible.
  13. */
  14. useNamedReferences?: boolean;
  15. /**
  16. * Prefer the shortest possible reference, if that results in less bytes.
  17. * **Note**: `useNamedReferences` can be omitted when using `useShortestReferences`.
  18. */
  19. useShortestReferences?: boolean;
  20. /**
  21. * Whether to omit semicolons when possible.
  22. * **Note**: This creates what HTML calls “parse errors” but is otherwise still valid HTML — don’t use this except when building a minifier.
  23. * Omitting semicolons is possible for certain named and numeric references in some cases.
  24. */
  25. omitOptionalSemicolons?: boolean;
  26. /**
  27. * Create character references which don’t fail in attributes.
  28. * **Note**: `attribute` only applies when operating dangerously with
  29. * `omitOptionalSemicolons: true`.
  30. */
  31. attribute?: boolean;
  32. };