[GH-ISSUE #310] Shebang support #2114

Closed
opened 2026-03-07 20:04:43 +03:00 by kerem · 5 comments
Owner

Originally created by @brandonkal on GitHub (Jul 31, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/310

The file's shebang line should be stripped before the text is passed to rules.
I found that rules 18 and 41 complain on the line. This should be simple to implement.

Originally created by @brandonkal on GitHub (Jul 31, 2020). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/310 The file's shebang line should be stripped before the text is passed to rules. I found that rules 18 and 41 complain on the line. This should be simple to implement.
kerem 2026-03-07 20:04:43 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Jul 31, 2020):

Can you please show an example? I’m not familiar with shebang in Markdown; the files are not usually executable.

https://en.m.wikipedia.org/wiki/Shebang_(Unix)

<!-- gh-comment-id:666872294 --> @DavidAnson commented on GitHub (Jul 31, 2020): Can you please show an example? I’m not familiar with shebang in Markdown; the files are not usually executable. https://en.m.wikipedia.org/wiki/Shebang_(Unix)
Author
Owner

@brandonkal commented on GitHub (Jul 31, 2020):

The pattern is not widespread but it enables some exciting use-cases.

<!-- gh-comment-id:666880377 --> @brandonkal commented on GitHub (Jul 31, 2020): The pattern is not widespread but it enables some exciting use-cases. - I support it in my https://github.com/brandonkal/inkjet tool to build rapid CLIs and as a project task runner. - There is also https://github.com/bashup/mdsh to compile markdown to bash scripts.
Author
Owner

@DavidAnson commented on GitHub (Jul 31, 2020):

It’s a slight abuse of the feature, but have you tried defining a front matter regular expression to match the shebang syntax? That should tell the tool to strip that first line out automatically.

<!-- gh-comment-id:666883194 --> @DavidAnson commented on GitHub (Jul 31, 2020): It’s a slight abuse of the feature, but have you tried defining a front matter regular expression to match the shebang syntax? That should tell the tool to strip that first line out automatically.
Author
Owner

@DavidAnson commented on GitHub (Sep 19, 2020):

For this use case, I the suggestion above seems to work fine:

pi@pi:~/shebang $ cat shebang.md
#!/usr/bin/env node

# Heading

Markdown text.
pi@pi:~/shebang $ cat .markdownlint-cli2.jsonc
{
  "frontMatter": "^#!.*(\r?\n)"
}
pi@pi:~/shebang $ markdownlint-cli2 shebang.md
Finding: shebang.md
Linting: 1 file(s)
Summary: 0 error(s)
pi@pi:~/shebang $
<!-- gh-comment-id:695162045 --> @DavidAnson commented on GitHub (Sep 19, 2020): For this use case, I the suggestion above seems to work fine: ```bash pi@pi:~/shebang $ cat shebang.md #!/usr/bin/env node # Heading Markdown text. pi@pi:~/shebang $ cat .markdownlint-cli2.jsonc { "frontMatter": "^#!.*(\r?\n)" } pi@pi:~/shebang $ markdownlint-cli2 shebang.md Finding: shebang.md Linting: 1 file(s) Summary: 0 error(s) pi@pi:~/shebang $ ```
Author
Owner

@DavidAnson commented on GitHub (Oct 16, 2020):

Closing issue since this seems to be an uncommon scenario and the approach outlined above works.

<!-- gh-comment-id:710583579 --> @DavidAnson commented on GitHub (Oct 16, 2020): Closing issue since this seems to be an uncommon scenario and the approach outlined above works.
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#2114
No description provided.