table-cell.js 685 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @import {Element} from 'hast'
  3. * @import {TableCell} from 'mdast'
  4. * @import {State} from '../state.js'
  5. */
  6. /**
  7. * Turn an mdast `tableCell` node into hast.
  8. *
  9. * @param {State} state
  10. * Info passed around.
  11. * @param {TableCell} node
  12. * mdast node.
  13. * @returns {Element}
  14. * hast node.
  15. */
  16. export function tableCell(state, node) {
  17. // Note: this function is normally not called: see `table-row` for how rows
  18. // and their cells are compiled.
  19. /** @type {Element} */
  20. const result = {
  21. type: 'element',
  22. tagName: 'td', // Assume body cell.
  23. properties: {},
  24. children: state.all(node)
  25. }
  26. state.patch(node, result)
  27. return state.applyData(node, result)
  28. }