Skip to content

Commit

Permalink
clean: Escape strings in clean CSS output
Browse files Browse the repository at this point in the history
  • Loading branch information
gvtulder committed Sep 4, 2024
1 parent 1a4af7c commit 23cd1b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion se/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def _format_css_component_list(content: list, in_selector=False, in_paren_block=
output += f"#{token.value}"

if token.type == "string":
output += f"\"{token.value}\""
output += token.representation

if token.type == "() block":
output += f"({_format_css_component_list(token.content, in_selector, True)})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ p:nth-of-type(1)::before{
#chapter-1 tr:first-child{
content: "test";
}

p::before{
content: "newlines \A \A \A quotes ' \" \"'backslash \\ letters áè";
}

p::after{
content: "newlines \A \A \A quotes ' \" \"'backslash \\ letters áè";
}
5 changes: 5 additions & 0 deletions tests/draft_commands/clean/test-2/in/src/epub/css/local.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ p:nth-of-type(1)::before{content: "test";}
#chapter-1::after {content: "test";}
#chapter-1 tr:first-child{
content: "test";}

p::before{
content: "newlines \a \A \00000A quotes ' \" \22 \27 backslash \\ letters \e1\E8";
}
p::after{content: 'newlines \a \A \00000A quotes \' " \22 \27 backslash \\ letters \e1\E8';}

0 comments on commit 23cd1b3

Please sign in to comment.