Skip to content

Commit

Permalink
Be more restrictive when highlighting missing images (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Dec 1, 2024
1 parent b91fd10 commit ca80c47
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This document provides a high-level view of the changes introduced by release.

- Fix text color of non-icon admonitions in dark preview
- Adding an intent to add the option to disable validation on individual code blocks (#830)
- Be more restrictive when highlighting missing images (#1727)

=== 0.43.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void visitElement(@NotNull PsiElement o) {
} else if (o instanceof AsciiDocLink && ((AsciiDocLink) o).getMacroName().equals("link") && resolvedBody.startsWith("about:")) {
// this is a special about: URL, don't report this as an error
return;
} else if (AsciiDocFileReference.URL.matcher(resolvedBody).find() && (macroName.equals("image") || macroName.equals("video"))) {
} else if ((AsciiDocUtil.URL_PREFIX_PATTERN.matcher(resolvedBody).find() || resolvedBody.startsWith("data:")) && (macroName.equals("image") || macroName.equals("video"))) {
// this is a data URI for an image, don't
return;
} else if (resolvedBody.startsWith("/")) {
Expand Down Expand Up @@ -239,7 +239,7 @@ private boolean hasImagesDirAsUrl(PsiElement o) {
if (decl.getContainingFile().equals(o.getContainingFile()) &&
decl.getTextOffset() < o.getTextOffset() &&
val != null &&
AsciiDocFileReference.URL.matcher(val).find()) {
(AsciiDocUtil.URL_PREFIX_PATTERN.matcher(val).find() || val.startsWith("data:"))) {
continueResolving = false;
break;
}
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/org/asciidoc/intellij/psi/AsciiDocFileReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,7 @@

public class AsciiDocFileReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private static final int MAX_DEPTH = 10;
/**
* Detects strings that resemble URIs.
* <p>
* Examples:
* <ul>
* <li>http://domain</li>
* <li>https://domain
* <li>file:///path</li>
* <li>data:info</li>
* </ul>
* <p>
* not c:/sample.adoc or c:\sample.adoc.
* <p>
* taken from Asciidoctor rx.rb, UriSniffRx
*/
public static final Pattern URL = Pattern.compile("^\\p{Alpha}[\\p{Alnum}.+-]+:/{0,2}", Pattern.UNICODE_CHARACTER_CLASS);
public static final String FILE_PREFIX = "file:///";



private final String key;
private final String macroName;
private final String base;
Expand Down

0 comments on commit ca80c47

Please sign in to comment.