summaryrefslogtreecommitdiff
path: root/scss/source.py
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-12-10 14:06:42 -0800
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-12-10 14:06:42 -0800
commit77a58288ded8506cf8ca161fa2df5d8bd9876ece (patch)
tree3c600bddfbe6f5fc4def7bb9d5602db876b09ded /scss/source.py
parentbe4f062b8caafb88299b4047b5944d9f73dc6a3b (diff)
downloadpyscss-77a58288ded8506cf8ca161fa2df5d8bd9876ece.tar.gz
Make line numbers in errors moderately less wrong.
Diffstat (limited to 'scss/source.py')
-rw-r--r--scss/source.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/scss/source.py b/scss/source.py
index 7f99c1f..462278d 100644
--- a/scss/source.py
+++ b/scss/source.py
@@ -12,7 +12,7 @@ import six
from scss.cssdefs import (
_ml_comment_re, _sl_comment_re,
- _expand_rules_space_re, _collapse_properties_space_re,
+ _collapse_properties_space_re,
_strings_re,
)
from scss.cssdefs import determine_encoding
@@ -261,7 +261,7 @@ class SourceFile(object):
if line is None:
line = ''
- line = state['line_buffer'] + line.rstrip() # remove EOL character
+ line = state['line_buffer'] + line
if line and line[-1] == '\\':
state['line_buffer'] = line[:-1]
@@ -274,10 +274,8 @@ class SourceFile(object):
state['prev_line'] = line
- if output:
- output += '\n'
- ret += output
-
+ ret += output
+ ret += '\n'
return ret
def parse_sass_line(self, line, state):
@@ -286,7 +284,7 @@ class SourceFile(object):
if line is None:
line = ''
- line = state['line_buffer'] + line.rstrip() # remove EOL character
+ line = state['line_buffer'] + line
if line and line[-1] == '\\':
state['line_buffer'] = line[:-1]
@@ -327,9 +325,8 @@ class SourceFile(object):
state['prev_indent'] = indent
state['prev_line'] = line
- if output:
- output += '\n'
- ret += output
+ ret += output
+ ret += '\n'
return ret
def prepare_source(self, codestr, sass=False):
@@ -351,6 +348,9 @@ class SourceFile(object):
# parse the last line stored in prev_line buffer
codestr += parse_line(None, state)
+ # pop off the extra \n parse_line puts at the beginning
+ codestr = codestr[1:]
+
# protects codestr: "..." strings
codestr = _strings_re.sub(
lambda m: _reverse_safe_strings_re.sub(
@@ -366,9 +366,6 @@ class SourceFile(object):
codestr = _safe_strings_re.sub(
lambda m: _safe_strings[m.group(0)], codestr)
- # expand the space in rules
- codestr = _expand_rules_space_re.sub(' {', codestr)
-
# collapse the space in properties blocks
codestr = _collapse_properties_space_re.sub(r'\1{', codestr)