grammar.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. type Value = boolean | string;
  2. export type State = {
  3. [key: string]: Value;
  4. };
  5. interface Flags {
  6. adjust?: boolean;
  7. preprocess?: boolean;
  8. correct?: boolean;
  9. translate?: boolean;
  10. }
  11. type Correction = (text: string, parameter?: Value) => string;
  12. export declare const ATTRIBUTE = "grammar";
  13. export declare class Grammar {
  14. private static instance;
  15. currentFlags: Flags;
  16. private parameters_;
  17. private corrections_;
  18. private preprocessors_;
  19. private stateStack_;
  20. private singles;
  21. static getInstance(): Grammar;
  22. static parseInput(grammar: string): State;
  23. static parseState(stateStr: string): State;
  24. private static translateString;
  25. private static translateUnit;
  26. private static prepareUnit;
  27. private static cleanUnit;
  28. clear(): void;
  29. setParameter(parameter: string, value: Value): Value;
  30. getParameter(parameter: string): Value;
  31. setCorrection(correction: string, func: Correction): void;
  32. setPreprocessor(preprocessor: string, func: Correction): void;
  33. getCorrection(correction: string): Correction;
  34. getState(): string;
  35. processSingles(): void;
  36. pushState(assignment: {
  37. [key: string]: Value;
  38. }): void;
  39. popState(): void;
  40. setAttribute(node: Element): void;
  41. preprocess(text: string): string;
  42. correct(text: string): string;
  43. apply(text: string, opt_flags?: Flags): string;
  44. private runProcessors;
  45. private constructor();
  46. }
  47. export declare function correctFont(text: string, correction: string): string;
  48. export {};