Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add horizontal line after heading (H2) #1211

Open
Bad3r opened this issue Oct 28, 2024 · 5 comments
Open

FR: Add horizontal line after heading (H2) #1211

Bad3r opened this issue Oct 28, 2024 · 5 comments
Labels
rule suggestion Suggestion to add or edit a rule

Comments

@Bad3r
Copy link

Bad3r commented Oct 28, 2024

Is Your Feature Request Related to a Problem? Please Describe.

Automatically add a horizontal line or horizontal rule after type 2 headings or 1

Describe the Solution You'd Like

A toggle option to enable automatically adding a horizontal line after H2 heading

Please include an example where applicable:

## Title
content
## Title
---

Content

Describe Alternatives You've Considered

A clear and concise description of any alternative solutions or features you've considered.

Additional Context

Add any other context or screenshots about the feature request here.

@Bad3r Bad3r added the rule suggestion Suggestion to add or edit a rule label Oct 28, 2024
@pjkaufman
Copy link
Collaborator

Hey @Bad3r . Thanks for the request. Is there a reason you are not trying to solve this via a custom replacement (i.e. regex)?

@Bad3r
Copy link
Author

Bad3r commented Oct 28, 2024

Hey @Bad3r . Thanks for the request. Is there a reason you are not trying to solve this via a custom replacement (i.e. regex)?

While it's possible to solve by regex I feel like it's a common use case. For example, GitHub automatically does that for markdown files.

It would be a great & “simple” feature to add.

@Bad3r
Copy link
Author

Bad3r commented Oct 29, 2024

Hey @Bad3r . Thanks for the request. Is there a reason you are not trying to solve this via a custom replacement (i.e. regex)?

I am having an issue with regex sloution..

I am using the following:

  • find regex (## [^\n]+)\n(?!---)
  • the replace regex $1\n---\n

even though the find regex should exclude H2 headers that are already followed by a horizontal line ((?!---)) the linter matches them and endlessly adds a new horizontal line after every H2.

When I text it in regex 101 (https://regex101.com/) the issue is not reproducible

link to test: https://regex101.com/r/npn3HT/1

test case:

## Header A
---

## Header B 
test

## header C

@pjkaufman
Copy link
Collaborator

Hey @Bad3r . Thanks for the request. Is there a reason you are not trying to solve this via a custom replacement (i.e. regex)?

I am having an issue with regex sloution..

I am using the following:

  • find regex (## [^\n]+)\n(?!---)
  • the replace regex $1\n---\n

even though the find regex should exclude H2 headers that are already followed by a horizontal line ((?!---)) the linter matches them and endlessly adds a new horizontal line after every H2.

When I text it in regex 101 (https://regex101.com/) the issue is not reproducible

link to test: https://regex101.com/r/npn3HT/1

test case:

## Header A
---

## Header B 
test

## header C

I will have to take a look at this when I get a chance. It could be that the regex is getting escaped improperly which could cause the issue.

@Bad3r
Copy link
Author

Bad3r commented Nov 3, 2024

Hey @Bad3r . Thanks for the request. Is there a reason you are not trying to solve this via a custom replacement (i.e. regex)?

I am having an issue with regex sloution..
I am using the following:

  • find regex (## [^\n]+)\n(?!---)
  • the replace regex $1\n---\n

even though the find regex should exclude H2 headers that are already followed by a horizontal line ((?!---)) the linter matches them and endlessly adds a new horizontal line after every H2.
When I text it in regex 101 (regex101.com) the issue is not reproducible
link to test: regex101.com/r/npn3HT/1
test case:

## Header A
---

## Header B 
test

## header C

I will have to take a look at this when I get a chance. It could be that the regex is getting escaped improperly which could cause the issue.

Fixed it by using the regex (## [^\n]+)\n(?!\s*---) its not an escaping issue but seems like something I was using wasn't supported by the engine.

I still think this should be a builtin feature. Feel free to close if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule suggestion Suggestion to add or edit a rule
Projects
None yet
Development

No branches or pull requests

2 participants