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

Feature request: exclude/ignore option #359

Closed
jspaezp opened this issue Sep 17, 2022 · 7 comments · Fixed by #451
Closed

Feature request: exclude/ignore option #359

jspaezp opened this issue Sep 17, 2022 · 7 comments · Fixed by #451
Labels
enhancement New feature or request

Comments

@jspaezp
Copy link

jspaezp commented Sep 17, 2022

Context

Hello!

I would love to use it as mdformat . (like black) and have it ignore all files I know should be ignored and include any that should be included but is not explicitly formatted with .md extension.

I understand that the current suggested usage as a pre-commit hook uses their exclusion argument to exclude files. But i feel like having it in the cli would be great.

Let me know what you think.

Proposal

I would like to propose adding exclude and include options to the cli (and by extension the configuration toml).
I believe it would be great for its usage in the command line.

Tasks and updates

No response

@jspaezp jspaezp added the enhancement New feature or request label Sep 17, 2022
@juhannc

This comment was marked as off-topic.

@jspaezp

This comment was marked as off-topic.

@juhannc

This comment was marked as off-topic.

@jspaezp

This comment was marked as off-topic.

@hukkin
Copy link
Owner

hukkin commented Sep 22, 2022

Thanks for the issue @jspaezp !

I'll have to consider whether I want the maintenance burden that this adds.

For now, as you mention, it is possible to use the pre-commit tool to achieve what you want. This means configuring mdformat and file inclusion/exclusion patterns in .pre-commit-config.yaml and running

pre-commit run mdformat

or

pre-commit run mdformat --files <filename>

instead of

mdformat <filename>

Is there a particular reason this does not suit your use case?


I think @juhannc could benefit from (currently unspecced and unimplemented) feature #53 or alternatively a plugin that makes mdformat special case the particular [TOC] macro. There's a small bit of documentation on how to build a plugin here and a list of existing plugins (of which you can check the source code of) here

@jspaezp
Copy link
Author

jspaezp commented Sep 25, 2022

Hello @hukkin, the main use case I can think of is ...

If I change the configuration of my mdformat (lets say ... lines from 120 to 80), and I want to apply it to ALL of my files in the repo, I would much rather use mdformat . instead of mdformat *.md ; mdformat */*.md ; mdformat */*/*.md ; mdformat *.qmd ....

And in addition, it feels natural. It would be consistent with the behavior of many other formatting tools that are also released as pre-commit hooks.

  • black .
  • isort .
  • pylint {python_module}
  • ruff .
  • pyright .
  • mypy .

LMK what you think

lyz-code added a commit to lyz-code/blue-book that referenced this issue Nov 24, 2022
…s locally

If you're with the VPN connected, turn it off.

feat(aleph#PDB behaves weird): PDB behaves weird

Sometimes you have two traces at the same time, so each time you run a PDB
command it jumps from pdb trace. Quite confusing. Try to `c` the one you don't
want so that you're left with the one you want. Or put the `pdb` trace in a
conditional that only matches one of both threads.

fix(gitpython): Deprecate tmpdir in favour of tmp_path

feat(pytest#The tmp_path fixture): The tmp_path fixture

You can use the `tmp_path` fixture which will provide a temporary directory
unique to the test invocation, created in the base temporary directory.

`tmp_path` is a `pathlib.Path` object. Here is an example test usage:

```python
def test_create_file(tmp_path):
    d = tmp_path / "sub"
    d.mkdir()
    p = d / "hello.txt"
    p.write_text(CONTENT)
    assert p.read_text() == CONTENT
    assert len(list(tmp_path.iterdir())) == 1
    assert 0
```

fix(pytest#The tmpdir fixture): Deprecate the tmpdir fixture

Warning: Don't use `tmpdir` use `tmp_path` instead because `tmpdir` uses `py`
which is unmaintained and has unpatched vulnerabilities.

feat(python_snippets#Pad integer with zeros): Pad integer with zeros

```python
>>> length = 1
>>> print(f'length = {length:03}')
length = 001
```

feat(elasticsearch#Get documents that match a string): Get documents that match a string

```bash
curl \
    -H 'Content-Type: application/json' \
    -XPOST "https://localhost:9200/_search" \
    -d' { "query": { "query_string": {"query": "test company"} }}'
```

feat(linux_snippets#df and du showing different results): df and du showing different results

Sometimes on a linux machine you will notice that both `df` command (display
free disk space) and `du` command (display disk usage statistics) report
different output. Usually, `df` will output a bigger disk usage than `du`.

The `du` command estimates file space usage, and the `df` command shows file
system disk space usage.

There are many reasons why this could be happening:

* [Disk mounted over data](linux_snippets.md#disk-mounted-over-data)
* [Used deleted files](linux_snippets.md#used-deleted-files)

feat(linux_snippets#Clean up docker data): Clean up docker data

To remove unused `docker` data you can run `docker system prune -a`. This will
remove:

- All stopped containers
- All networks not used by at least one container
- All images without at least one container associated to them
- All build cache

Sometimes that's not enough, and your `/var/lib/docker` directory still weights
more than it should. In those cases:

- Stop the `docker` service.
- Remove or move the data to another directory
- Start the `docker` service.

In order not to loose your persisted data, you need to configure your dockers to
mount the data from a directory that's not within `/var/lib/docker`.

feat(mdformat#issues): Issues

- It doesn't yet
  [support admonitions](hukkin/mdformat#309)
- You can't
  [ignore some files](hukkin/mdformat#359),
  nor
  [some part of the file](hukkin/mdformat#53)
tpdownes added a commit to tpdownes/slurm-gcp that referenced this issue Feb 26, 2024
mdformat has a known issue where it will escape brackets (to become
literals) when it encounters GitHub-Flavored Markdown extensions:
hukkin/mdformat#359 (comment)
It is also fairly agressive in ways that, on net, probably reduce
readability in ASCII form. Swap automation in favor of pymarkdown,
configured identically as in GoogleCloudPlatform/hpc-toolkit.
tpdownes added a commit to tpdownes/slurm-gcp that referenced this issue Feb 26, 2024
mdformat has a known issue where it will escape brackets (to become
literals) when it encounters GitHub-Flavored Markdown extensions:
hukkin/mdformat#359 (comment)
It is also fairly agressive in ways that, on net, probably reduce
readability in ASCII form. Swap automation in favor of pymarkdown,
configured identically as in GoogleCloudPlatform/hpc-toolkit.

This hook will be disabled until all markdown files honor the linter
tpdownes added a commit to GoogleCloudPlatform/slurm-gcp that referenced this issue Feb 26, 2024
mdformat has a known issue where it will escape brackets (to become
literals) when it encounters GitHub-Flavored Markdown extensions:
hukkin/mdformat#359 (comment)
It is also fairly agressive in ways that, on net, probably reduce
readability in ASCII form. Swap automation in favor of pymarkdown,
configured identically as in GoogleCloudPlatform/hpc-toolkit.

This hook will be disabled until all markdown files honor the linter
@twmht
Copy link

twmht commented Mar 16, 2024

this is an important feature since it violates the CHANGELOG.md generated by https://github.com/google-github-actions/release-please-action

cdunbar13 pushed a commit to GoogleCloudPlatform/slurm-gcp that referenced this issue Jun 20, 2024
mdformat has a known issue where it will escape brackets (to become
literals) when it encounters GitHub-Flavored Markdown extensions:
hukkin/mdformat#359 (comment)
It is also fairly agressive in ways that, on net, probably reduce
readability in ASCII form. Swap automation in favor of pymarkdown,
configured identically as in GoogleCloudPlatform/hpc-toolkit.

This hook will be disabled until all markdown files honor the linter
bsngardner pushed a commit to bsngardner/slurm-gcp that referenced this issue Jul 26, 2024
mdformat has a known issue where it will escape brackets (to become
literals) when it encounters GitHub-Flavored Markdown extensions:
hukkin/mdformat#359 (comment)
It is also fairly agressive in ways that, on net, probably reduce
readability in ASCII form. Swap automation in favor of pymarkdown,
configured identically as in GoogleCloudPlatform/hpc-toolkit.

This hook will be disabled until all markdown files honor the linter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants