Skip to content

Commit

Permalink
Report possibly unrendered Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Aug 3, 2024
1 parent 08d0c73 commit 04f83f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/warning-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ This rule reports internal image links (ending in one of the image extensions).

This rule reports pages without a sidebar. All pages should be associated with a sidebar.

## Possibly unrendered Markdown

This rule reports plain text that looks like Markdown. This can either be because the Markdown is nested within other HTML (usually tables), or because it's using awkward text that must be escaped. The former should be replaced with the HTML equivalent and the latter should preferably be put into code spans.

## Redirected external link

This rule reports external links that are redirected to a different URL, including when the trailing slash is different. Replace the link with the redirected location.
Expand Down
13 changes: 12 additions & 1 deletion src/server/create-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,23 @@ graph.forEachNode((node) => {
report(node, "Bad DL", $(li).text().slice(0, 50));
}
});
if (part.value.content.includes("-: "))
if (part.value.content.includes("-: ")) {
report(
node,
"Bad DL",
part.value.content.match(/-: .*$/m)?.[0].slice(0, 50)
);
}
$(":not(code, code *, pre, pre *, math, math *)").each((i, el) => {
const texts = $(el)
.contents()
.filter((i, el) => el.type === "text");
for (const text of texts) {
if (/`.*`|\*.*\*|\[.*\]\(.*\)|\b_.*_\b/.test(text.data)) {
report(node, "Possibly unrendered Markdown", text.data);
}
}
});
$("a:not(svg a)").each((i, a) => {
const href = $(a).attr("href");
if (!href) {
Expand Down

0 comments on commit 04f83f6

Please sign in to comment.