void (Document document) { String text = document.getText(); Set<String> markers = myHighlightingTypes.keySet(); String typesRx = String.join("|", markers); String openingTagRx = "<(?<marker>" + typesRx + ")" + "(?:\\s+" + "(?:descr=\"(?<descr>(?:\\\\\"|[^\"])*)\"" + "|type=\"(?<type>[0-9A-Z_]+)\"" + "|foreground=\"(?<foreground>[0-9xa-f]+)\"" + "|background=\"(?<background>[0-9xa-f]+)\"" + "|effectcolor=\"(?<effectcolor>[0-9xa-f]+)\"" + "|effecttype=\"(?<effecttype>[A-Z]+)\"" + "|fonttype=\"(?<fonttype>[0-9]+)\"" + "|textAttributesKey=\"(?<textAttributesKey>(?:\\\\\"|[^\"])*)\"" + "|bundleMsg=\"(?<bundleMsg>(?:\\\\\"|[^\"])*)\"" + "|tooltip=\"(?<tooltip>(?:\\\\\"|[^\"])*)\"" + "))*" + "\\s*(?<closed>/)?>"; Matcher matcher = Pattern.compile(openingTagRx).matcher(text); Ref<Integer> textOffset = Ref.create(0); int pos = 0; while (matcher.find(pos)) { textOffset.set(textOffset.get() + matcher.start() - pos); pos = extractExpectedHighlight(matcher, text, document, textOffset); } }