void (@NotNull PlainText plainText, @NotNull List<@NotNull LocationMarkupNode> activeNodes) { String content = plainText.content(); for (LocationMarkupNode node : activeNodes) { UnaryOperator<String> replacement; if (node instanceof Highlight highlight) { replacement = switch (highlight.type()) { case BOLD -> orig -> "<b>" + orig + "</b>"; case ITALIC -> orig -> "<i>" + orig + "</i>"; case HIGHLIGHTED -> { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); yield orig -> getStyledSpan(true, attributes, orig); } }; } else if (node instanceof Link link) { replacement = orig -> { StringBuilder buffer = new StringBuilder(); DocumentationManagerUtil.createHyperlink(buffer, link.target(), orig, link.linkType() == LinkType.LINKPLAIN); return buffer.toString(); }; } else { throw new AssertionError(node.toString()); } int pos = 0; StringBuilder sb = new StringBuilder(); for (TextRange range : node.selector().ranges(content)) { sb.append(content, pos, range.getStartOffset()); sb.append(replacement.apply(range.substring(content))); pos = range.getEndOffset(); } sb.append(content, pos, content.length()); content = sb.toString(); } buffer.append(content); }