fixed scientific notation numbers

This commit is contained in:
Will McGugan 2020-08-05 16:08:56 +01:00
parent 1501671a4d
commit c2716b2b14
3 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.0.1] - Unreleased
### Fixed
- Fixed deprecation warnings re backslash https://github.com/willmcgugan/rich/issues/210
- Fixed repr highlighting of scientific notation, e.g. 1e100
## [5.0.0] - 2020-08-02 ## [5.0.0] - 2020-08-02
### Changed ### Changed

View File

@ -75,7 +75,7 @@ class ReprHighlighter(RegexHighlighter):
r"(?P<tag_start>\<)(?P<tag_name>\w*)(?P<tag_contents>.*?)(?P<tag_end>\>)", r"(?P<tag_start>\<)(?P<tag_name>\w*)(?P<tag_contents>.*?)(?P<tag_end>\>)",
r"(?P<attrib_name>\w+?)=(?P<attrib_value>\"?[\w_]+\"?)", r"(?P<attrib_name>\w+?)=(?P<attrib_value>\"?[\w_]+\"?)",
r"(?P<bool_true>True)|(?P<bool_false>False)|(?P<none>None)", r"(?P<bool_true>True)|(?P<bool_false>False)|(?P<none>None)",
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*\b)", r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[\-\+]?\d+?)?\b)",
r"(?P<number>0x[0-9a-f]*)", r"(?P<number>0x[0-9a-f]*)",
r"(?P<path>\B(\/[\w\.\-\_\+]+)*\/)(?P<filename>[\w\.\-\_\+]*)?", r"(?P<path>\B(\/[\w\.\-\_\+]+)*\/)(?P<filename>[\w\.\-\_\+]*)?",
r"(?<!\\)(?P<str>b?\'\'\'.*?(?<!\\)\'\'\'|b?\'.*?(?<!\\)\'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")", r"(?<!\\)(?P<str>b?\'\'\'.*?(?<!\\)\'\'\'|b?\'.*?(?<!\\)\'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
@ -105,3 +105,7 @@ if __name__ == "__main__": # pragma: no cover
console.print("foo /foo/bar/baz/egg.py word") console.print("foo /foo/bar/baz/egg.py word")
console.print("foo /foo/bar/ba._++z/egg+.py word") console.print("foo /foo/bar/ba._++z/egg+.py word")
console.print("https://example.org?foo=bar") console.print("https://example.org?foo=bar")
console.print(1234567.34)
console.print(1 / 2)
console.print(-1 / 123123123123)

View File

@ -16,7 +16,6 @@ from typing import (
Deque, Deque,
Dict, Dict,
Iterable, Iterable,
Iterator,
List, List,
NamedTuple, NamedTuple,
NewType, NewType,