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

Inconsistencies in Markdown Formatting #276

Open
furtni opened this issue Mar 6, 2025 · 0 comments
Open

Inconsistencies in Markdown Formatting #276

furtni opened this issue Mar 6, 2025 · 0 comments

Comments

@furtni
Copy link
Contributor

furtni commented Mar 6, 2025

While working on #275 I came across a few things I would like to discuss.

Prettier vs. Markdownlint

As per .vscode/extensions.json both Prettier and markdownlint are recommended extensions. I assume their usage is encouraged?

The indent_size = 4 specified in .editorconfig is respected by Prettier, since it parses it into it's own config.
However, the default rule-set of markdownlint is not compatible with the resulting format.

This causes linting issues after formatting with Prettier, especially with nested lists mixing unordered and ordered list:

Image

I tried to define a compatible ruleset as suggested here.

.markdownlint.json:

{
  "list-marker-space": {
    "ul_multi": 3,
    "ul_single": 3
  },
  "ul-indent": {
    "indent": 4
  }
}

Yet, this does not solve the issue. Even with manually tweaking the rules values:

Image

It seems to me that Prettier uses more complex conditional formatting than what can be specified with markdownlint's rule-sets.

Current State

Currently almost none of the markdown files in this repository conform to either format:

$ prettier -c ./content
Checking formatting...
[warn] content/de/_index.html
...
[warn] content/en/storage-backup/s3-storage/tutorials/versioning-in-s3.md
[warn] Code style issues found in 524 files. Run Prettier with --write to fix.
$ markdownlint-cli2 "./content/**/*.md" 2> /dev/null
markdownlint-cli2 v0.17.2 (markdownlint v0.37.4)
Finding: ./content/**/*.md
Linting: 586 file(s)
Summary: 7784 error(s)

Suggestions

If we want to enforce consistent formatting I would suggest that we:

  • Choose one of Prettier/markdownlint. (Or discover a solution I didn't find.)

  • Don't have the rules inferred by letting the formatter parse the .editorconfig. This is really annoying to debug.
    Explicitly specify the formatting rules in an appropriate configuration file for the formatter.
    Be it a .markdownlint.json or a .prettierrc.

  • Don't set the extension as recommended, but preinstall it via devcontainer.json:

    "customizations": {
      "vscode": {
        "extensions": [
          "esbenp.prettier-vscode"
        ],
        "settings": {
          "[markdown]": {
            "editor.defaultFormatter": "esbenp.prettier-vscode",
            "editor.formatOnSave": true // This might be a little too intrusive for some?
          }
        }
      }
  • Maybe even add a lint job to the existing workflows?
    This would guarantee only properly formatted code being merged.

    - name: Check Markdown format
      uses: creyD/[email protected]
      with:
        dry: true
        prettier_options: --check ./content/**/*.md

Conclusion

I think that to conform to what we defined for ourselves in ./guidelines, we need to ensure a consistent style/format.

Let me know what you think and feel free to suggest entirely different approaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant