mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix yellow code by HtmlUnknownTagInspection on svg and mathml tags
This commit is contained in:
+8
-1
@@ -200,8 +200,15 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool {
|
||||
return descriptor == null || descriptor instanceof AnyXmlElementDescriptor;
|
||||
}
|
||||
|
||||
// this hack is needed, because we temporarily ignore svg and mathML namespaces
|
||||
// todo: provide schemas for svg and mathML and remove this in IDEA XI
|
||||
private static boolean isInSpecialHtml5Namespace(XmlTag tag) {
|
||||
final String ns = tag.getNamespace();
|
||||
return HtmlUtil.SVG_NAMESPACE.equals(ns) || HtmlUtil.MATH_ML_NAMESPACE.endsWith(ns);
|
||||
}
|
||||
|
||||
protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
|
||||
if (!(tag instanceof HtmlTag) || !XmlHighlightVisitor.shouldBeValidated(tag)) {
|
||||
if (!(tag instanceof HtmlTag) || !XmlHighlightVisitor.shouldBeValidated(tag) || isInSpecialHtml5Namespace(tag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package com.intellij.javaee;
|
||||
|
||||
import com.intellij.xml.util.HtmlUtil;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class InternalResourceProvider implements StandardResourceProvider{
|
||||
|
||||
|
||||
public void registerResources(ResourceRegistrar registrar) {
|
||||
ResourceRegistrarImpl impl = (ResourceRegistrarImpl)registrar;
|
||||
|
||||
@@ -54,5 +55,8 @@ public class InternalResourceProvider implements StandardResourceProvider{
|
||||
impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile10-flat.dtd", "xhtml-mobile/xhtml-mobile10-flat.dtd");
|
||||
impl.addInternalResource("http://www.wapforum.org/DTD/xhtml-mobile12.dtd", "xhtml-mobile/xhtml-mobile12.dtd");
|
||||
|
||||
// svg and mathML
|
||||
impl.addIgnoredResource(HtmlUtil.MATH_ML_NAMESPACE);
|
||||
impl.addIgnoredResource(HtmlUtil.SVG_NAMESPACE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,18 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag {
|
||||
|
||||
@NotNull
|
||||
public String getNamespace() {
|
||||
if(getNamespacePrefix().length() == 0)
|
||||
final String xmlNamespace = super.getNamespace();
|
||||
|
||||
if (getNamespacePrefix().length() > 0) {
|
||||
return xmlNamespace;
|
||||
}
|
||||
|
||||
if (xmlNamespace.length() == 0 || xmlNamespace.equals(XmlUtil.XHTML_URI)) {
|
||||
return XmlUtil.HTML_URI;
|
||||
return super.getNamespace();
|
||||
}
|
||||
|
||||
// ex.: mathML and SVG namespaces can be used inside html file
|
||||
return xmlNamespace;
|
||||
}
|
||||
|
||||
protected String getRealNs(final String value) {
|
||||
|
||||
@@ -87,6 +87,9 @@ public class HtmlUtil {
|
||||
, "video/quicktime", "video/x-msvideo", "video/x-sgi-movie", "x-conference/x-cooltalk", "x-world/x-vrml"};
|
||||
@NonNls public static final String LINK = "link";
|
||||
|
||||
@NonNls public static final String MATH_ML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
||||
@NonNls public static final String SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
||||
|
||||
private HtmlUtil() {}
|
||||
@NonNls private static final String[] EMPTY_TAGS = {
|
||||
"base","hr","meta","link","frame","br","basefont","param","img","area","input","isindex","col", /*html 5*/ "source","wbr"
|
||||
|
||||
Reference in New Issue
Block a user