[GH-ISSUE #119] Include filename in mardown-it objects #1948

Closed
opened 2026-03-07 20:03:03 +03:00 by kerem · 4 comments
Owner

Originally created by @johntron on GitHub (May 3, 2018).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/119

I'd like to add a custom rule to check for broken links and orphaned pages in my Markdown documents. I've been using Markdown in a personal knowledgebase, and have a lot of relative paths I want to maintain.

This would be simple with the customRules API, but it doesn't provide the filename in the line-annotated markdown-it objects. I believe this could be added by modifying this call in lintFile() and the called function, lintContent() to accept the filename as an argument. I can submit a PR if this makes sense.

Originally created by @johntron on GitHub (May 3, 2018). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/119 I'd like to add a custom rule to check for broken links and orphaned pages in my Markdown documents. I've been using Markdown in a personal knowledgebase, and have a lot of relative paths I want to maintain. This would be simple with the customRules API, but it doesn't provide the filename in the line-annotated markdown-it objects. I believe this could be added by modifying [this call in lintFile()](https://github.com/DavidAnson/markdownlint/blob/e938f421a9a0bbb6c3ff82d7b41c2cb227e9414e/lib/markdownlint.js#L413) and the called function, [lintContent()](https://github.com/DavidAnson/markdownlint/blob/e938f421a9a0bbb6c3ff82d7b41c2cb227e9414e/lib/markdownlint.js#L285) to accept the filename as an argument. I can submit a PR if this makes sense.
kerem 2026-03-07 20:03:03 +03:00
Author
Owner

@DavidAnson commented on GitHub (May 3, 2018):

Sure! If you want to start with a sketch, I’d be happy to review that to be sure we are on the same page.

<!-- gh-comment-id:386458136 --> @DavidAnson commented on GitHub (May 3, 2018): Sure! If you want to start with a sketch, I’d be happy to review that to be sure we are on the same page.
Author
Owner

@DavidAnson commented on GitHub (May 4, 2018):

Thinking about this, I propose:

  • Add it to params
  • Call it file
  • Pass it exactly as provided to options.files
  • Use null when not available (strings)
  • Update the README and CustomRules docs
  • Update the tests
<!-- gh-comment-id:386497504 --> @DavidAnson commented on GitHub (May 4, 2018): Thinking about this, I propose: - Add it to `params` - Call it `file` - Pass it exactly as provided to `options.files` - Use `null` when not available (strings) - Update the README and CustomRules docs - Update the tests
Author
Owner

@DavidAnson commented on GitHub (May 4, 2018):

Update: The value of file should be the same path already used to open it successfully. I don’t think we should commit to normalizing it.

<!-- gh-comment-id:386631673 --> @DavidAnson commented on GitHub (May 4, 2018): Update: The value of `file` should be the same path already used to open it successfully. I don’t think we should commit to normalizing it.
Author
Owner

@DavidAnson commented on GitHub (May 25, 2018):

(Don't worry about a PR - I did this just now and will push it tomorrow after reviewing the changes.)

<!-- gh-comment-id:391944274 --> @DavidAnson commented on GitHub (May 25, 2018): (Don't worry about a PR - I did this just now and will push it tomorrow after reviewing the changes.)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#1948
No description provided.