Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cairosvg/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def node_format(surface, node, reference=True):
def normalize(string):
"""Normalize a string corresponding to an array of various values."""
string = string.replace('E', 'e')
string = re.sub(r'(e[+-]?\d+)(?=\.)', r'\1 ', string)
string = re.sub('(?<!e)-', ' -', string)
string = re.sub('[ \n\r\t,]+', ' ', string)
string = re.sub(r'(\.[0-9-]+)(?=\.)', r'\1 ', string)
Expand Down
11 changes: 11 additions & 0 deletions cairosvg/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ def test_formats(format_name):
assert content.startswith(MAGIC_NUMBERS[format_name])


def test_path_number_after_exponent():
"""Render adjacent path numbers after an exponent."""
template = (
'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">'
'<path d="{}" />'
'</svg>')
adjacent = template.format('M1 1 A2e2 2e2.0 0 0 5 5').encode()
separated = template.format('M1 1 A2e2 2e2 .0 0 0 5 5').encode()
assert svg2png(adjacent) == svg2png(separated)


def read_file(filename):
"""Shortcut to return the whole content of a file as a byte string."""
with open(filename, 'rb') as file_object:
Expand Down