parseBlockKatex = (state, startLine, endLine) => {
    let haveEndMarker = false;
    let pos = state.bMarks[startLine] + state.tShift[startLine];
    let max = state.eMarks[startLine];

    if (pos + 1 > max) { return false; }

    const marker = state.src.charAt(pos);
    if (marker !== delimiter) { return false; }

    // scan marker length
    let mem = pos;
    pos = state.skipChars(pos, marker);
    let len = pos - mem;

    if (len !== 2) { return false; }

    // search end of block
    let nextLine = startLine;

    for (;;) {
      ++nextLine;
      if (nextLine >= endLine) { break; }

      pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
      max = state.eMarks[nextLine];

      if (pos < max && state.tShift[nextLine] < state.blkIndent) { break; }
      if (state.src.charAt(pos) !== delimiter) { continue; }
      if (state.tShift[nextLine] - state.blkIndent >= 4) { continue; }

      pos = state.skipChars(pos, marker);
      if (pos - mem < len) { continue; }

      pos = state.skipSpaces(pos);
      if (pos < max) { continue; }

      haveEndMarker = true;
      break;
    }

    // If a fence has heading spaces, they should be removed from its inner block
    len = state.tShift[startLine];
    state.line = nextLine + (haveEndMarker ? 1 : 0);
    const content = state.getLines(startLine + 1, nextLine, len, true)
            .replace(/[ \n]+/g, ' ')
            .trim();

    state.tokens.push({type: 'katex', params: null, content: content, lines: [startLine, state.line],
                       level: state.level, block: true});
    return true;
  }
Parse '$$' as a block. Based off of similar method in remarkable.