@Override
  protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) {
    final Project project = psi.getProject();
    final Lexer lexer = new MarkdownMergingLexer();
    final CharSequence chars = new StringUtil.BombedCharSequence(chameleon.getChars()) {
      @Override
      protected void checkCanceled() {
        ProgressManager.checkCanceled();
      }
    };

    final var file = psi.getContainingFile();
    Objects.requireNonNull(file, () -> "Expected a non-null containing file for " + psi);
    final var flavour = obtainFlavour(file);
    final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, getLanguage(), chars);

    var startTime = System.nanoTime();
    final var parser = new MarkdownParser(flavour, true);
    final var nodeType = MarkdownElementType.markdownType(chameleon.getElementType());
    final var node = parser.parseInline(nodeType, chars, 0, chars.length());

    PsiBuilder.Marker rootMarker = builder.mark();

    //Flatten type is used to solve problem with trailing whitespaces
    new PsiBuilderFillingVisitor(builder, false).visitNode(node);
    assert builder.eof();

    rootMarker.done(this);

    final var tree = builder.getTreeBuilt();
    final var actualElement = tree.getFirstChildNode().getFirstChildNode();

    ParsingDiagnostics.registerParse(builder, getLanguage(), System.nanoTime() - startTime);

    return actualElement;
  }
@Override
  protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi)