Skip to content

Commit

Permalink
Fix various issues found by make check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anteru committed Feb 14, 2021
1 parent 41f25b1 commit 5f3db3a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
6 changes: 4 additions & 2 deletions pygments/formatters/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def format_unencoded(self, tokensource, outfile):

if self.linenos:
if counter % counter_step == 0:
outfile.write('<text x="%s" y="%s" %s text-anchor="end">%s</text>' % (x+self.linenowidth,y,counter_style,counter))
outfile.write('<text x="%s" y="%s" %s text-anchor="end">%s</text>' %
(x+self.linenowidth,y,counter_style,counter))
line_x += self.linenowidth + self.ystep
counter += 1

Expand All @@ -158,7 +159,8 @@ def format_unencoded(self, tokensource, outfile):
y += self.ystep
outfile.write('</text>\n')
if self.linenos and counter % counter_step == 0:
outfile.write('<text x="%s" y="%s" text-anchor="end" %s>%s</text>' % (x+self.linenowidth,y,counter_style,counter))
outfile.write('<text x="%s" y="%s" text-anchor="end" %s>%s</text>' %
(x+self.linenowidth,y,counter_style,counter))

counter += 1
outfile.write('<text x="%s" y="%s" ' 'xml:space="preserve">' % (line_x,y))
Expand Down
12 changes: 8 additions & 4 deletions pygments/lexers/amdgpu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.AMDGPULexer
~~~~~~~~~~~~~~~~~~~~~~~~
pygments.lexers.amdgpu
~~~~~~~~~~~~~~~~~~~~~~
Lexers for the AMDGPU ISA assembly.
Expand All @@ -10,13 +9,18 @@
"""

from pygments.lexer import RegexLexer
from pygments.token import *
from pygments.token import Name, Text, Keyword, Whitespace, Number, Comment

import re

__all__ = ['AMDGPULexer']

class AMDGPULexer(RegexLexer):
"""
For AMD GPU assembly.
.. versionadded:: 2.8
"""
name = 'AMDGPU'
aliases = ['amdgpu']
filenames = ['*.isa']
Expand Down
1 change: 0 additions & 1 deletion pygments/lexers/cddl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.cddl
~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pygments/lexers/futhark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Lexer for the Futhark language
:copyright: Copyright 2021 by the Pygments team, see AUTHORS.
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""

Expand Down
5 changes: 3 additions & 2 deletions pygments/lexers/graphviz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.graphviz
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -34,7 +33,9 @@ class GraphvizLexer(RegexLexer):
(r'(?i)(node|edge|graph|digraph|subgraph|strict)\b', Keyword),
(r'--|->', Operator),
(r'[{}[\]:;,]', Punctuation),
(r'(\b\D\w*)(\s*)(=)(\s*)', bygroups(Name.Attribute, Whitespace, Punctuation, Whitespace), 'attr_id'),
(r'(\b\D\w*)(\s*)(=)(\s*)',
bygroups(Name.Attribute, Whitespace, Punctuation, Whitespace),
'attr_id'),
(r'\b(n|ne|e|se|s|sw|w|nw|c|_)\b', Name.Builtin),
(r'\b\D\w*', Name.Tag), # node
(r'[-]?((\.[0-9]+)|([0-9]+(\.[0-9]*)?))', Number),
Expand Down
6 changes: 4 additions & 2 deletions pygments/lexers/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,10 @@ class TypeScriptLexer(RegexLexer):
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|'
r'this|async|await|debugger|yield|abstract|static|import|export|'
r'implements|super|extends|private|protected|public|readonly)\b', Keyword, 'slashstartsregex'),
(r'(var|let|const|with|function|class|type|enum|interface)\b', Keyword.Declaration, 'slashstartsregex'),
r'implements|super|extends|private|protected|public|readonly)\b',
Keyword, 'slashstartsregex'),
(r'(var|let|const|with|function|class|type|enum|interface)\b',
Keyword.Declaration, 'slashstartsregex'),
(r'(boolean|byte|char|double|final|float|goto|int|long|native|'
r'package|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
Expand Down
1 change: 0 additions & 1 deletion pygments/styles/material.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
pygments.styles.material
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pygments/styles/zenburn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
See: https://kippura.org/zenburnpage/
https://github.com/jnurmine/Zenburn
:copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""

Expand Down
12 changes: 8 additions & 4 deletions tests/test_html_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def test_happy_javascript_fragment(lexer_html):
start_time = time.time()
tokens = list(lexer_html.get_tokens(fragment))
assert all(x[1] != Token.Error for x in tokens)
assert time.time() - start_time < MAX_HL_TIME, 'The HTML lexer might have an expensive happy-path script case'
assert time.time() - start_time < MAX_HL_TIME, \
'The HTML lexer might have an expensive happy-path script case'


def test_happy_css_fragment(lexer_html):
Expand All @@ -38,7 +39,8 @@ def test_happy_css_fragment(lexer_html):
start_time = time.time()
tokens = list(lexer_html.get_tokens(fragment))
assert all(x[1] != Token.Error for x in tokens)
assert time.time() - start_time < MAX_HL_TIME, 'The HTML lexer might have an expensive happy-path style case'
assert time.time() - start_time < MAX_HL_TIME, \
'The HTML lexer might have an expensive happy-path style case'


def test_long_unclosed_javascript_fragment(lexer_html):
Expand All @@ -48,7 +50,8 @@ def test_long_unclosed_javascript_fragment(lexer_html):
fragment = "<script type=\"text/javascript\">"+"alert(\"hi\");"*reps
start_time = time.time()
tokens = list(lexer_html.get_tokens(fragment))
assert time.time() - start_time < MAX_HL_TIME, 'The HTML lexer might have an expensive error script case'
assert time.time() - start_time < MAX_HL_TIME, \
'The HTML lexer might have an expensive error script case'
tokens_intro = [
(Token.Punctuation, '<'),
(Token.Name.Tag, 'script'),
Expand Down Expand Up @@ -82,7 +85,8 @@ def test_long_unclosed_css_fragment(lexer_html):
fragment = "<style>"+".ui-helper-hidden{display:none}"*reps
start_time = time.time()
tokens = list(lexer_html.get_tokens(fragment))
assert time.time() - start_time < MAX_HL_TIME, 'The HTML lexer might have an expensive error style case'
assert time.time() - start_time < MAX_HL_TIME, \
'The HTML lexer might have an expensive error style case'

tokens_intro = [
(Token.Punctuation, '<'),
Expand Down

0 comments on commit 5f3db3a

Please sign in to comment.