Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs indentation support #804

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
======

Expand Down
13 changes: 7 additions & 6 deletions lib/yaml/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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':
Expand All @@ -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:
Expand All @@ -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

Expand Down
16 changes: 9 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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",
Expand All @@ -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 = """
Expand Down