mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix parsing comments
This commit is contained in:
@@ -93,7 +93,8 @@ def parse(css: str) -> Iterable[RuleSet]:
|
||||
if __name__ == "__main__":
|
||||
test = """
|
||||
.foo.bar baz:focus, #egg {
|
||||
display: block
|
||||
/* ignore me, I'm a comment */
|
||||
display: block;
|
||||
visibility: visible;
|
||||
border: solid green !important;
|
||||
outline: red;
|
||||
@@ -103,7 +104,10 @@ if __name__ == "__main__":
|
||||
|
||||
from .stylesheet import Stylesheet
|
||||
|
||||
print(test)
|
||||
print()
|
||||
stylesheet = Stylesheet()
|
||||
stylesheet.parse(test)
|
||||
print(stylesheet)
|
||||
print()
|
||||
print(stylesheet.css)
|
||||
|
||||
@@ -180,7 +180,7 @@ class Styles:
|
||||
yield "display", self.display, "block"
|
||||
yield "visibility", self.visibility, "visible"
|
||||
yield "padding", self.padding, NULL_SPACING
|
||||
yield "margin", self.padding, NULL_SPACING
|
||||
yield "margin", self.margin, NULL_SPACING
|
||||
|
||||
yield "border_top", self.border_top, None
|
||||
yield "border_right", self.border_right, None
|
||||
@@ -274,7 +274,6 @@ class Styles:
|
||||
raise DeclarationError(name, token, f"{msg} (line {line + 1}, col {col + 1})")
|
||||
|
||||
def add_declaration(self, declaration: Declaration) -> None:
|
||||
|
||||
if not declaration.tokens:
|
||||
return
|
||||
process_method = getattr(self, f"process_{declaration.name.replace('-', '_')}")
|
||||
|
||||
@@ -76,9 +76,11 @@ def tokenize(code: str) -> Iterable[Token]:
|
||||
get_state = _STATES.get
|
||||
while True:
|
||||
token = get_token(expect)
|
||||
|
||||
name = token.name
|
||||
if name == "comment_start":
|
||||
tokenizer.skip_to(expect_comment_end)
|
||||
continue
|
||||
elif name == "eof":
|
||||
break
|
||||
expect = get_state(name, expect)
|
||||
|
||||
Reference in New Issue
Block a user