mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Update MD033/no-inline-html to better handle inline code spans (fixes #182).
This commit is contained in:
parent
f003926a72
commit
608f875fc2
4 changed files with 46 additions and 10 deletions
|
|
@ -6,8 +6,9 @@ const { addError, bareUrlRe, forEachLine, unescapeMarkdown } =
|
|||
require("../helpers");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
const htmlElementRe = /<(([\w+.-]+)(?:[^>]*)?)>/g;
|
||||
const htmlElementRe = /<(([\w-]+)(?:[\s/][^>]*)?)>/g;
|
||||
const linkDestinationRe = /]\(\s*$/;
|
||||
const inlineCodeRe = /^[^`]*(`+[^`]+`+[^`]+)*`+[^`]*$/;
|
||||
// See https://spec.commonmark.org/0.29/#autolinks
|
||||
const emailAddressRe =
|
||||
// eslint-disable-next-line max-len
|
||||
|
|
@ -29,7 +30,7 @@ module.exports = {
|
|||
!tag.endsWith("\\>") && !bareUrlRe.test(content) &&
|
||||
!emailAddressRe.test(content)) {
|
||||
const prefix = line.substring(0, match.index);
|
||||
if (!linkDestinationRe.test(prefix) &&
|
||||
if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix) &&
|
||||
!unescapeMarkdown(prefix + "<", "_").endsWith("_")) {
|
||||
addError(onError, lineIndex + 1, "Element: " + element,
|
||||
null, [ match.index + 1, tag.length ]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue