diff --git a/README.md b/README.md index 7d01da24..c3fe9eb2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +## About this fork + +This fork adds tabs indentation support to PyYAML. + +Use at your own risk. + +Please note I'm not checking if the content is mixing tabs and spaces (which should raise an exception). + +Why to use tabs for indentation? Sorry, but that's a very silly question 😡 + +Install with `pip install PyYAML_tabs` + +--- + PyYAML ====== diff --git a/lib/yaml/scanner.py b/lib/yaml/scanner.py index de925b07..ab4f6035 100644 --- a/lib/yaml/scanner.py +++ b/lib/yaml/scanner.py @@ -773,7 +773,8 @@ def scan_to_next_token(self): self.forward() found = False while not found: - while self.peek() == ' ': + # TODO: Throw exception when mixing spaces and tabs + while self.peek() in [' ', "\t"]: self.forward() if self.peek() == '#': while self.peek() not in '\0\r\n\x85\u2028\u2029': @@ -1091,7 +1092,7 @@ def scan_block_scalar_indicators(self, start_mark): def scan_block_scalar_ignored_line(self, start_mark): # See the specification for details. - while self.peek() == ' ': + while self.peek() in [' ', "\t"]: self.forward() if self.peek() == '#': while self.peek() not in '\0\r\n\x85\u2028\u2029': @@ -1108,8 +1109,8 @@ def scan_block_scalar_indentation(self): chunks = [] max_indent = 0 end_mark = self.get_mark() - while self.peek() in ' \r\n\x85\u2028\u2029': - if self.peek() != ' ': + while self.peek() in ' \t\r\n\x85\u2028\u2029': + if self.peek() not in [' ', "\t"]: chunks.append(self.scan_line_break()) end_mark = self.get_mark() else: @@ -1122,12 +1123,12 @@ def scan_block_scalar_breaks(self, indent): # See the specification for details. chunks = [] end_mark = self.get_mark() - while self.column < indent and self.peek() == ' ': + while self.column < indent and self.peek() in [' ', "\t"]: self.forward() while self.peek() in '\r\n\x85\u2028\u2029': chunks.append(self.scan_line_break()) end_mark = self.get_mark() - while self.column < indent and self.peek() == ' ': + while self.column < indent and self.peek() in [' ', "\t"]: self.forward() return chunks, end_mark diff --git a/setup.py b/setup.py index c9b5dc6f..66d3e4e2 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ -NAME = 'PyYAML' -VERSION = '6.0.1' -DESCRIPTION = "YAML parser and emitter for Python" +NAME = 'PyYAML_tabs' +VERSION = '6.0.3' +DESCRIPTION = "YAML parser and emitter for Python with tabs indentation support" LONG_DESCRIPTION = """\ +This is a fork of PyYAML with tabs indentation support. + YAML is a data serialization format designed for human readability and interaction with scripting languages. PyYAML is a YAML parser and emitter for Python. @@ -19,7 +21,7 @@ LICENSE = "MIT" PLATFORMS = "Any" URL = "https://pyyaml.org/" -DOWNLOAD_URL = "https://pypi.org/project/PyYAML/" +DOWNLOAD_URL = "https://pypi.org/project/PyYAML_tabs/" CLASSIFIERS = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -40,11 +42,11 @@ "Topic :: Text Processing :: Markup", ] PROJECT_URLS = { - 'Bug Tracker': 'https://github.com/yaml/pyyaml/issues', - 'CI': 'https://github.com/yaml/pyyaml/actions', + 'Bug Tracker': 'https://github.com/kripper/pyyaml_tabs/issues', + 'CI': 'https://github.com/kripper/pyyaml_tabs/actions', 'Documentation': 'https://pyyaml.org/wiki/PyYAMLDocumentation', 'Mailing lists': 'http://lists.sourceforge.net/lists/listinfo/yaml-core', - 'Source Code': 'https://github.com/yaml/pyyaml', + 'Source Code': 'https://github.com/kripper/pyyaml_tabs', } LIBYAML_CHECK = """