[GH-ISSUE #634] Reference link double on format #2333

Closed
opened 2026-03-07 20:06:47 +03:00 by kerem · 5 comments
Owner

Originally created by @MalcolmMielle on GitHub (Nov 11, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/634

On 2 or more save of a file, two list of references are generated. One outside off the begin/end tag and one in. I get really inconsistent results with setting in and out of the workspace but never one where it works.

Steps to Reproduce the Bug or Issue

  1. create a file with a wikilink to an exisiting file like:
# Python style guide

We use the [[Guidelines/Python-style-guide]] with some modifications.

[//begin]: # "Autogenerated link references for markdown compatibility"
[Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules"
[//end]: # "Autogenerated link references"
  1. Press control S and you get
# Python style guide

We use the [[Guidelines/Python-style-guide]] with some modifications.

[Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules"

[//begin]: # "Autogenerated link references for markdown compatibility"
[Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules"
[//end]: # "Autogenerated link references"

Expected behavior

You should get

# Python style guide

We use the [[Guidelines/Python-style-guide]] with some modifications.

[//begin]: # "Autogenerated link references for markdown compatibility"
[Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules"
[//end]: # "Autogenerated link references"

I have tried blocking all rules in mardownlint.config but it changed nothing

Originally created by @MalcolmMielle on GitHub (Nov 11, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/634 On 2 or more save of a file, two list of references are generated. One outside off the begin/end tag and one in. I get really inconsistent results with setting in and out of the workspace but never one where it works. ### Steps to Reproduce the Bug or Issue 1. create a file with a wikilink to an exisiting file like: ``` # Python style guide We use the [[Guidelines/Python-style-guide]] with some modifications. [//begin]: # "Autogenerated link references for markdown compatibility" [Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules" [//end]: # "Autogenerated link references" ``` 5. Press control S and you get ``` # Python style guide We use the [[Guidelines/Python-style-guide]] with some modifications. [Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules" [//begin]: # "Autogenerated link references for markdown compatibility" [Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules" [//end]: # "Autogenerated link references" ``` ### Expected behavior You should get ``` # Python style guide We use the [[Guidelines/Python-style-guide]] with some modifications. [//begin]: # "Autogenerated link references for markdown compatibility" [Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules" [//end]: # "Autogenerated link references" ``` I have tried blocking all rules in `mardownlint.config` but it changed nothing
kerem 2026-03-07 20:06:47 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@MalcolmMielle commented on GitHub (Nov 11, 2022):

God I open this and I fix it by realizing I badly named my config file...

{
    "MD053": false
}

in .markdownlint.json solves this.

Sorry for a bad case of didn't read the manual...

<!-- gh-comment-id:1311798785 --> @MalcolmMielle commented on GitHub (Nov 11, 2022): God I open this and I fix it by realizing I badly named my config file... ``` { "MD053": false } ``` in `.markdownlint.json` solves this. Sorry for a bad case of didn't read the manual...
Author
Owner

@DavidAnson commented on GitHub (Nov 11, 2022):

Glad you got this sorted out! I will have a look anyway, because this behavior is not expected. That rule is trying to remove the two definitions above and below that line and it works fine individually (see playground below). I can't test bulk fix from my phone, but will do so later. However, even with a bug, I don't understand how you would end up with two copies of the reference that isn't being removed.

https://dlaa.me/markdownlint/#%25m%23%20Python%20style%20guide%0A%0AWe%20use%20the%20%5B%5BGuidelines%2FPython-style-guide%5D%5D%20with%20some%20modifications.%0A%0A%5B%2F%2Fbegin%5D%3A%20%23%20%22Autogenerated%20link%20references%20for%20markdown%20compatibility%22%0A%5BGuidelines%2FPython-style-guide%5D%3A%20..%2F..%2FGuidelines%2FPython-style-guide%20%22Python%20language%20rules%22%0A%5B%2F%2Fend%5D%3A%20%23%20%22Autogenerated%20link%20references%22%0A

<!-- gh-comment-id:1311949799 --> @DavidAnson commented on GitHub (Nov 11, 2022): Glad you got this sorted out! I will have a look anyway, because this behavior is not expected. That rule is trying to remove the two definitions above and below that line and it works fine individually (see playground below). I can't test bulk fix from my phone, but will do so later. However, even with a bug, I don't understand how you would end up with two copies of the reference that isn't being removed. https://dlaa.me/markdownlint/#%25m%23%20Python%20style%20guide%0A%0AWe%20use%20the%20%5B%5BGuidelines%2FPython-style-guide%5D%5D%20with%20some%20modifications.%0A%0A%5B%2F%2Fbegin%5D%3A%20%23%20%22Autogenerated%20link%20references%20for%20markdown%20compatibility%22%0A%5BGuidelines%2FPython-style-guide%5D%3A%20..%2F..%2FGuidelines%2FPython-style-guide%20%22Python%20language%20rules%22%0A%5B%2F%2Fend%5D%3A%20%23%20%22Autogenerated%20link%20references%22%0A
Author
Owner

@MalcolmMielle commented on GitHub (Nov 11, 2022):

I generate the reference links using foam and it might be simply recreating the list after the formating.

<!-- gh-comment-id:1311977252 --> @MalcolmMielle commented on GitHub (Nov 11, 2022): I generate the reference links using [foam](https://github.com/foambubble/foam) and it might be simply recreating the list after the formating.
Author
Owner

@DavidAnson commented on GitHub (Nov 15, 2022):

@MalcolmMielle I assume you are using VS Code. If I create a new Markdown document with the content you show above and run the "Fix all supported markdownlint violations in the document" command, I get the following as expected:

# Python style guide

We use the [[Guidelines/Python-style-guide]] with some modifications.

[Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules"

If you want to leave the "//begin" and "//end" comments alone, the following configuration does so:

{
  "MD053": {
    "ignored_definitions": [
      "//begin",
      "//end"
    ]
  }
}

With that configuration in place, no issues are reported/fixed.

This all seems correct. If you see otherwise, please try running the markdownlint fix command as I am directly - you may have another extension trying to apply fixes on save and interfering.

I'm using the latest VS Code and markdownlint extension v0.48.1.

<!-- gh-comment-id:1314824542 --> @DavidAnson commented on GitHub (Nov 15, 2022): @MalcolmMielle I assume you are using VS Code. If I create a new Markdown document with the content you show above and run the "Fix all supported markdownlint violations in the document" command, I get the following as expected: ```md # Python style guide We use the [[Guidelines/Python-style-guide]] with some modifications. [Guidelines/Python-style-guide]: ../../Guidelines/Python-style-guide "Python language rules" ``` If you want to leave the "//begin" and "//end" comments alone, the following configuration does so: ```json { "MD053": { "ignored_definitions": [ "//begin", "//end" ] } } ``` With that configuration in place, no issues are reported/fixed. This all seems correct. If you see otherwise, please try running the markdownlint fix command as I am directly - you may have another extension trying to apply fixes on save and interfering. I'm using the latest VS Code and markdownlint extension v0.48.1.
Author
Owner

@MalcolmMielle commented on GitHub (Nov 15, 2022):

I'm using VSCode and the other extension rewritting the list of link is the foam app. Your configuration file is perfect :). Thanks a lot for chekcing it out!

<!-- gh-comment-id:1315145713 --> @MalcolmMielle commented on GitHub (Nov 15, 2022): I'm using VSCode and the other extension rewritting the list of link is the foam app. Your configuration file is perfect :). Thanks a lot for chekcing it out!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2333
No description provided.