Skip to content

GH formatting linguist-language=Markdown for ChangeLog incorrectly #5799

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

Closed
sebres opened this issue Feb 21, 2022 · 2 comments
Closed

GH formatting linguist-language=Markdown for ChangeLog incorrectly #5799

sebres opened this issue Feb 21, 2022 · 2 comments
Labels

Comments

@sebres
Copy link

sebres commented Feb 21, 2022

Describe the bug

At some point fail2ban's ChangeLog set within .gitattributes as ChangeLog linguist-language=Markdown (initially in https://github.com/fail2ban/fail2ban/pull/3126/files) became an invalid formatting later - it looks like plaintext without any line feed or rather like a totally unformatted HTML.

Example:

Expected behaviour

Correctly formatted Markdown layout for ChangeLog

Observed behaviour

Not formatted layout as it would be "plain" HTML without new lines etc.

Additional notes

I don't know whether it is some conflicting rule of ChangeLog layout only or whether it is some issue of GH (not a linguist) which avoid correct formatting of the layout.

Anyway, commenting out the entry in .gitattributes in fail2ban/fail2ban@1e5d5a4 "solves" the issue, but it looks again like plain text document now.
Reverting this in my clone illustrates how it looks wrong again.

@lildude
Copy link
Member

lildude commented Feb 21, 2022

Yup, this isn't really Linguist at play.

Markdown rendering is handled by the github/markup library. Whilst it uses Linguist to detect languages, it doesn't however honour the .gitattributes overrides because it asks Linguist to look at the file in isolation here which means it'll only use one of these methods of determining the language and not consider the .gitattributes file at all:

https://github.com/github/linguist/blob/97bc889ce840208652bf09b45f3b7859de43fe8e/lib/linguist.rb#L63-L70

None of these strategies will detect your Changelog file as Markdown hence you get plaintext.

In order to get the file rendered as Markdown, you'll have to use one of these extensions:

https://github.com/github/linguist/blob/dea6d4733b4fd68c67d248bfd0cfc5e1fa3cfa29/lib/linguist/languages.yml#L3607-L3620

Or add a modeline like <!-- vim: syntax=Markdown --> to the file.

See github/markup#1102 and github/markup#1069 for old known issues around this.

@sebres
Copy link
Author

sebres commented Feb 21, 2022

OK, thx!
Thus closed here as 3rd party issue.

@sebres sebres closed this as completed Feb 21, 2022
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants