scivision / linguist-python

Detect repo language(s) with thin Python wrapper of Github Linguist
https://github.com/github/linguist
MIT License
12 stars 4 forks source link

Language output is incorrect when the language name has one or more spaces #2

Open DecimalTurn opened 1 month ago

DecimalTurn commented 1 month ago

Example language: "Visual Basic .NET" Example repo: https://github.com/narekye/VB.NET

Expected output: "Visual Basic .NET" Actual output: ".NET"

DecimalTurn commented 1 month ago

One way to fix this would be to replace:

https://github.com/scivision/linguist-python/blob/6a4eda815b3f691550459321cdef32ae2cde952f/src/ghlinguist/__init__.py#L33

with:

        lang = ""
        # Loop over the elements of L starting from the end and append the elements until we reach the number of lines
        for i in range(len(L) - 1, -1, -1):
            if L[i].isdigit():
                break
            if lang:
                lang = L[i] + " " + lang
            else:
                lang = L[i]

        lpct.append((lang, L[0][:-1]))