syntax.js 659 B

123456789101112131415161718192021222324
  1. /**
  2. * @import {Options} from 'micromark-extension-math'
  3. * @import {Extension} from 'micromark-util-types'
  4. */
  5. import {codes} from 'micromark-util-symbol'
  6. import {mathFlow} from './math-flow.js'
  7. import {mathText} from './math-text.js'
  8. /**
  9. * Create an extension for `micromark` to enable math syntax.
  10. *
  11. * @param {Options | null | undefined} [options={}]
  12. * Configuration (default: `{}`).
  13. * @returns {Extension}
  14. * Extension for `micromark` that can be passed in `extensions`, to
  15. * enable math syntax.
  16. */
  17. export function math(options) {
  18. return {
  19. flow: {[codes.dollarSign]: mathFlow},
  20. text: {[codes.dollarSign]: mathText(options)}
  21. }
  22. }