public List<Block> mergeWithTemplateBlocks(List<Block> markupBlocks,
                                             CodeStyleSettings settings,
                                             XmlFormattingPolicy xmlFormattingPolicy,
                                             Indent childrenIndent) throws FragmentedTemplateException {
    int templateLangRangeStart = Integer.MAX_VALUE;
    int templateLangRangeEnd = -1;
    int rangeStart = Integer.MAX_VALUE;
    int rangeEnd = -1;
    PsiFile templateFile = null;
    List<Block> pureMarkupBlocks = new ArrayList<>();
    for (Block block : markupBlocks) {
      TextRange currRange = block.getTextRange();
      rangeStart = Math.min(currRange.getStartOffset(), rangeStart);
      rangeEnd = Math.max(currRange.getEndOffset(), rangeEnd);
      boolean isMarkupBlock = true;
      if (block instanceof AnotherLanguageBlockWrapper wrapper) {
        PsiElement otherLangElement = wrapper.getNode().getPsi();
        if (isOuterLanguageElement(otherLangElement)) {
          isMarkupBlock = false;
          if (templateFile == null) {
            FileViewProvider provider = otherLangElement.getContainingFile().getViewProvider();
            templateFile = provider.getPsi(provider.getBaseLanguage());
          }
          templateLangRangeStart = Math.min(currRange.getStartOffset(), templateLangRangeStart);
          templateLangRangeEnd = Math.max(currRange.getEndOffset(), templateLangRangeEnd);
        }
      }
      if (isMarkupBlock) {
        pureMarkupBlocks.add(block);
      }
    }
    if (templateLangRangeEnd > templateLangRangeStart && templateFile != null) {
      List<Block> templateBlocks =
        buildTemplateLanguageBlocksInside(templateFile, new TextRange(templateLangRangeStart, templateLangRangeEnd), settings,
                                          xmlFormattingPolicy, childrenIndent);
      if (pureMarkupBlocks.isEmpty()) {
        return afterMerge(templateBlocks, true, settings, xmlFormattingPolicy);
      }
      return afterMerge(TemplateFormatUtil.mergeBlocks(pureMarkupBlocks, templateBlocks, new TextRange(rangeStart, rangeEnd)), false,
                        settings, xmlFormattingPolicy);
    }
    return markupBlocks;
  }
public List<Block> mergeWithTemplateBlocks(List<Block> markupBlocks,
                                             CodeStyleSettings settings,
                                             XmlFormattingPolicy xmlFormattingPolicy,
                                             Indent childrenIndent)