mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #100] Mapped header names for specific header tags #1931
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#1931
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ajithr on GitHub (Dec 26, 2017).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/100
It would be better, if it is possible to add the mapped headers for specific heading tags in a file. i.e. the required-headers can order the heading with specific header name, like wise the mapped headers can be useful to map a set of header names to specific heading tag.
Example:
So it will restrict the header tags with specified headings in the file contents. The unspecified header tags will be free from the restriction, in other words any heading name can be assigned to unspecified header tags.
@ajithr commented on GitHub (Dec 26, 2017):
A simple implementation for the above requirement,
@DavidAnson commented on GitHub (Dec 26, 2017):
The description and code above look very similar to existing rule MD043: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md043---required-header-structure
Could you please explain more about the scenario the proposed rule would improve and provide an example document?
My first thought is that this new rule is a subset of MD043 - an example would help clarify things.
Thank you!
@ajithr commented on GitHub (Dec 27, 2017):
I have addressed the difference between
required-headersandmapped-headersrules as below# Head
## Item
### Detail
## Foot
### Notes
# Changelog
### New Features
### Bug Fixes
From the above example,
required-headersprovides an ordered output for mdlint, whereas themapped-headerswill provide the support for specific header tag with its heading name.mapped-headerswon't need to be ordered likerequired-headersmapped-headersonly validates the heading names based on its header tag value. i.e. h1, h2mapped-headersvalidates the provided list of header tag with its corresponding header names. i.e. it will not check other header tags. from the example,mapped-headersonly validates the h1 and h3 tags with provided header names and it will not consider h2, h4, etc..Note: The behavior of both rules are differ, so
mapped-headerscan be used as a separate rule. I don't know it is possible to achieve the above requirement withrequired-headers.A simple testing behavior:
Input:
Output
### New Features
### New Features
@DavidAnson commented on GitHub (Dec 27, 2017):
Got it - thank you for clarifying!
required-headersallows you to skip using*, but I see thatmapped-headersis solving a slightly different problem.@ajithr commented on GitHub (Dec 28, 2017):
@DavidAnson Thanks for accepting this requirement as a new rule. May I know when it will be added in the markdownlint plugin. We need this requirement for md linting, so that only I have prepared a simple implementation mentioned above.
@DavidAnson commented on GitHub (Dec 28, 2017):
I do not have an estimate; I am working on a different set of changes for now. I am also looking at enabling user-defined rules, which would enable you to add this on your own. Thanks for your patience!
@ajithr commented on GitHub (Dec 28, 2017):
Thanks for the info. Can you please share the link for this enabling user-defined rules for tracking purpose. It will be helpful to me to add custom rules from my end.
@DavidAnson commented on GitHub (Dec 28, 2017):
It is not implemented yet. Once I have something working, I plan to release a new version soon afterward.