syntax-tree/mdast-util-heading-range

Allow for heading range to end at heading with higher depth

Murderlon opened this issue · 5 comments

Initial checklist

Problem

The document I'm formatting looks like this in terms of headings:

<!-- more above -->

### `getUploadParameters(file)`

### `locale: {}`

## S3 Bucket configuration

## POST uploads

## S3 alternatives
### DigitalOcean Spaces
### Google Cloud Storage
#### JSON CORS configuration

## Examples
### Generating a presigned upload URL server-side
### Retrieving presign parameters of the uploaded file

I'm using headingRange with locale: {} passed as string.

As the readme.md states:

A “section” is a heading that passes test, until the next heading of the same or lower depth [...]

This means the entire document after locale: {} is deleted but for my use case it would be required to also stop at the next heading of a higher depth.

Solution

Perhaps an options.endAtNextHeading (boolean, default false)

Alternatives

  • Make the new default to also stop at a heading of a higher depth. This would be a breaking change.
  • Something more granular, an option to pass an array of heading depths to end at. Overkill?
  • Suggest mdast-zone if you want this. Although not preferable.

wait, you’re looking for locale, and it doesn’t stop at S3 Bucket configuration?

So it happened here and I figured that must be the case as the readme confirms it. But when I try to reproduce it it seems to work as expected. Might be an issue on my side after all.

Can confirm that something weird happened at some point, I don't know how, but it seems to work now so this can be ignored.

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

weird!