aboutcode-org / aboutcode-org/typecode

Incorrect Pygments lexer guessed

未关闭
#8 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
10
派生
15
PR 合并指标
30 天内没有已合并 PR

描述

See https://github.com/pygments/pygments/issues/1563

With the attached file (to rename to a `.JAVA` UPPERCASE extension) the lexer is guessed incorrectly as Python.
See [Logger.JAVA.txt](https://github.com/nexB/typecode/files/5322954/Logger.JAVA.txt)

When the extension is lowercased to '.java`, the lexer is guessed OK from the filename.
In all cases, the content-based guess is not correct

```
$ python
Python 3.6.10 (default, Jun 13 2020, 08:53:46)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygments
>>> pygments.__version__
'2.7.1'
>>> from pygments import lexers
>>> fn='Logger.JAVA'
>>> code=open(f).read()
>>> lexers.get_lexer_for_filename(fn, code)
Traceback (most recent call last):
File "", line 1, in
File "/tmp/lib/python3.6/site-packages/pygments/lexers/__init__.py", line 210, in get_lexer_for_filename
raise ClassNotFound('no lexer for filename %r found' % _fn)
pygments.util.ClassNotFound: no lexer for filename 'Logger.JAVA' found
>>> lexers.guess_lexer(code)

>>> fn='Logger.java'
>>> lexers.get_lexer_for_filename(fn, code)

```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。