diff --git a/__tests__/no-bare-urls.test.ts b/__tests__/no-bare-urls.test.ts
index 4c7cab01..40e9d053 100644
--- a/__tests__/no-bare-urls.test.ts
+++ b/__tests__/no-bare-urls.test.ts
@@ -47,5 +47,14 @@ ruleTest({
\`http --headers --follow --all https://google.com\`
`,
},
+ {// https://github.com/platers/obsidian-linter/issues/588
+ testName: 'Make sure that anchor tags are not affected by the rule',
+ before: dedent`
+ https://www.google.com
+ `,
+ after: dedent`
+ https://www.google.com
+ `,
+ },
],
});
diff --git a/src/rules/no-bare-urls.ts b/src/rules/no-bare-urls.ts
index 52d7ccad..df3ac23a 100644
--- a/src/rules/no-bare-urls.ts
+++ b/src/rules/no-bare-urls.ts
@@ -25,7 +25,7 @@ export default class NoBareUrls extends RuleBuilder {
return RuleType.CONTENT;
}
apply(text: string, options: NoBareUrlsOptions): string {
- return ignoreListOfTypes([IgnoreTypes.code, IgnoreTypes.math, IgnoreTypes.yaml, IgnoreTypes.link, IgnoreTypes.wikiLink, IgnoreTypes.tag, IgnoreTypes.image, IgnoreTypes.inlineCode], text, (text) => {
+ return ignoreListOfTypes([IgnoreTypes.code, IgnoreTypes.math, IgnoreTypes.yaml, IgnoreTypes.link, IgnoreTypes.wikiLink, IgnoreTypes.tag, IgnoreTypes.image, IgnoreTypes.inlineCode, IgnoreTypes.anchorTag], text, (text) => {
const URLMatches = text.match(urlRegex);
if (!URLMatches) {
diff --git a/src/utils/ignore-types.ts b/src/utils/ignore-types.ts
index 718666ec..9cbb111d 100644
--- a/src/utils/ignore-types.ts
+++ b/src/utils/ignore-types.ts
@@ -1,4 +1,4 @@
-import {obsidianMultilineCommentRegex, tagWithLeadingWhitespaceRegex, wikiLinkRegex, yamlRegex, escapeDollarSigns, genericLinkRegex, tableRegex, urlRegex} from './regex';
+import {obsidianMultilineCommentRegex, tagWithLeadingWhitespaceRegex, wikiLinkRegex, yamlRegex, escapeDollarSigns, genericLinkRegex, tableRegex, urlRegex, anchorTagRegex} from './regex';
import {getPositions, MDAstTypes} from './mdast';
import type {Position} from 'unist';
import {replaceTextBetweenStartAndEndWithNewValue} from './strings';
@@ -29,6 +29,7 @@ export const IgnoreTypes: Record = {
footnoteAtStartOfLine: {replaceAction: /^(\[\^\w+\]) ?([,.;!:?])/gm, placeholder: '{FOOTNOTE_AT_START_OF_LINE_PLACEHOLDER}'},
footnoteAfterATask: {replaceAction: /- \[.] (\[\^\w+\]) ?([,.;!:?])/gm, placeholder: '{FOOTNOTE_AFTER_A_TASK_PLACEHOLDER}'},
url: {replaceAction: urlRegex, placeholder: '{URL_PLACEHOLDER}'},
+ anchorTag: {replaceAction: anchorTagRegex, placeholder: '{ANCHOR_PLACEHOLDER}'},
// custom functions
link: {replaceAction: replaceMarkdownLinks, placeholder: '{REGULAR_LINK_PLACEHOLDER}'},
} as const;
diff --git a/src/utils/regex.ts b/src/utils/regex.ts
index 3ea3b75e..0b3b84b9 100644
--- a/src/utils/regex.ts
+++ b/src/utils/regex.ts
@@ -22,6 +22,7 @@ export const lineStartingWithWhitespaceOrBlockquoteTemplate = `\\s*(>\\s*)*`;
// if this becomes an issue, we can address it then
export const tableRegex = /^((((>[ ]?)*)|([ ]{0,3}))\[.*?\][ \t]*\n)?((((>[ ]?)*)|([ ]{0,3}))\S+.*?\|.*?\n([^\n]*?\|[^\n]*?\n)*?)?(((>[ ]?)*)|([ ]{0,3}))[|\-+:.][ \-+|:.]*?\|[ \-+|:.]*(?:\n?[^\n]*?\|([^\n]*?)*)+/gm;
export const urlRegex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s`\]'"‘’“”>]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s`\]'"‘’“”>]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s`\]'"‘’“”>]{2,}|www\.[a-zA-Z0-9]+\.[^\s`\]'"‘’“”>]{2,})/gi;
+export const anchorTagRegex = /]+)>((?:.(?!<\/a>))*.)<\/a>/g;
// https://stackoverflow.com/questions/38866071/javascript-replace-method-dollar-signs
// Important to use this for any regex replacements where the replacement string