index.ts 439 B

123456789101112131415
  1. // Reference: https://github.com/andrejewski/himalaya — rewritten in TypeScript with simplified functionality
  2. import { lexer } from './lexer';
  3. import { parser } from './parser';
  4. import { format } from './format';
  5. import { toHTML } from './stringify';
  6. export type { AST } from './types';
  7. export const toAST = (str: string) => {
  8. const tokens = lexer(str);
  9. const nodes = parser(tokens);
  10. return format(nodes);
  11. };
  12. export { toHTML };