IJPL-156597 Grammar rules should not be triggered on HTML classes

GitOrigin-RevId: 53010d82b8945d0c90a360b201664beabdd8417e
This commit is contained in:
Peter Gromov
2024-08-09 17:46:50 +02:00
committed by intellij-monorepo-bot
parent a3a6657b74
commit 61a2df00b5
2 changed files with 17 additions and 0 deletions

View File

@@ -8,6 +8,10 @@
<H1>Example <TYPO descr="Typo: In word 'hedder'">hedder</TYPO> with <GRAMMAR_ERROR descr="EN_A_VS_AN">a</GRAMMAR_ERROR> error, so what?</H1>\
<tag descr="<GRAMMAR_ERROR descr="UPPERCASE_SENTENCE_START">it</GRAMMAR_ERROR> <GRAMMAR_ERROR descr="IT_VBZ">are</GRAMMAR_ERROR> error in tag <TYPO descr="Typo: In word 'atributee'">atributee</TYPO>. And here are some correct English words to make the language detector work."></tag>
<div class="input-group-text handle">Hello</div>
<img alt="This is <GRAMMAR_ERROR descr="EN_A_VS_AN">an</GRAMMAR_ERROR> mistake" src="foo.png"/>
Some widely used comparison methods (e.g. <code>String.compareTo</code>)
actually return values.

View File

@@ -227,6 +227,19 @@ public class XmlTextExtractor extends TextExtractor {
super(HTMLLanguage.class);
}
@Override
protected @NotNull List<TextContent> buildTextContents(@NotNull PsiElement element,
@NotNull Set<TextContent.TextDomain> allowedDomains) {
if (PsiUtilCore.getElementType(element) == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN &&
element.getParent() instanceof XmlAttributeValue value &&
value.getParent() instanceof XmlAttribute attr &&
"class".equalsIgnoreCase(attr.getName())) {
return List.of();
}
return super.buildTextContents(element, allowedDomains);
}
@Override
protected Function<XmlTag, TagKind> tagClassifier(@NotNull PsiElement context) {
if (!Registry.is("grazie.html.concatenate.inline.tag.contents")) {