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

Bug: "Remove Multiple Spaces" rule ignores >1 spaces inside of tables #951

Open
2 of 3 tasks
redactedscribe opened this issue Nov 27, 2023 · 5 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@redactedscribe
Copy link

Describe the Bug

The "Remove Multiple Spaces" rule does not work inside of tables.

How to Reproduce

Steps to reproduce the behavior:

| Foo | Bar |
| --- | --- |
| Hello | World! Some  double  spaces  and a link [ here is link text1 ](link_here). |    

(Last | above has 4 spaces after it)

Double  spaces  outside of a table and a link [ here is link text1 ](link_here).

The example contains links only for the purposes of showing that Linter can and does process content inside of tables, but for some reason just ignores processing double spaces.

  1. Enable "Remove Multiple Spaces".
  2. Enable "Remove link spacing".
  3. Paste example above into Obsidian.
  4. Lint. Spaces for links are removed from both inside and outside of the table, but only double spaces outside of the table are removed.

Expected Behavior

Double spaces should be removed from everywhere in the note body (unless "Trailing Spaces" > "Two Space Linebreak" is enabled -- or any other space rule which should override).

Expected output if applicable:

| Foo | Bar |
| --- | --- |
| Hello | World! Some double spaces and a link [here is link text1](link_here). |

(Last | above has 4 spaces after it)

Double spaces outside of a table and a link [here is link text1](link_here).

Device

  • Desktop
  • Mobile

Additional Context

Assumed "Remove Multiple Spaces" rule would be under the Spacing tab in the settings, but in fact it is under Content. Perhaps it should be under Spacing?

Thanks.

@redactedscribe redactedscribe added the bug Something isn't working label Nov 27, 2023
@pjkaufman
Copy link
Collaborator

Hey @redactedscribe . I am not sure that this is a bug. If I recall, the reason tables are not affected is because removing multiple spaces in a table removes styling added to those tables like making sure all rows have the same length.

I am not sure I would want to change that behavior since it could mess up table styling which I have no intention of supporting in the Linter.

@redactedscribe
Copy link
Author

redactedscribe commented Nov 28, 2023

I understand your concerns @pjkaufman, however I do not style my tables so fixing >1 spaces would not be a problem in my case.

(Edit: By style I mean align the table using spaces. I do "style" it by having a space before and after vertical bars, which might require some support and is something I did not consider at first.)

Is "Remove Multiple Spaces" the only rule which doesn't run on tables? If so, Linter already supports tables you could say, it just doesn't touch spacing.

If that holds true, then instead of hardcoding skipping over the "Remove Multiple Spaces" rule, we could have an "Ignore rules from table linting" option with a list filter where we can add rule aliases (with "remove-multiple-spaces" listed by default).

This would then at least give us the option to remove "remove-multiple-spaces" if we don't want space-aligned tables in source.

@pjkaufman
Copy link
Collaborator

The issue with removing multiple spaces is that it will remove spaces before and after text in a table as well. It can be handled, but that would take treating tables as special and then handling them as a one off. That is possible, but it would likely be some time before I could take a look at it assuming there is not a lot of desire for this from the community.

However, I would be fine with accepting a PR for this.

@pjkaufman
Copy link
Collaborator

It would mess with the following table styling:

| Foo        | Bar                                                                                                        |
| --------- | -------------------------------------------------------------------------- |
|     Hello | World! Some double spaces and a link [here is link text1](link_here). |

would become

| Foo | Bar |
| --------- | -------------------------------------------------------------------------- |
| Hello | World! Some double spaces and a link [here is link text1](link_here). |

@redactedscribe
Copy link
Author

The issue with removing multiple spaces is that it will remove spaces before and after text in a table as well.

I understood this, which is why I suggested keeping the behaviour the same but letting users who don't want/need nicely spaced tables in their Markdown to opt out.

That is possible, but it would likely be some time before I could take a look at it assuming there is not a lot of desire for this from the community.

My assumption would be that some users do format their tables nicely, and others don't bother (which my guess would be the majority, but I don't know). For those that don't bother, I assume they'd also want them to be spaced like the rest of their file.

However, I would be fine with accepting a PR for this.

Thanks for being open to a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants