python-fragments 0.17__tar.gz → 0.19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_fragments-0.17 → python_fragments-0.19}/PKG-INFO +1 -1
- {python_fragments-0.17 → python_fragments-0.19}/fragments/ast_nodes.py +3 -2
- {python_fragments-0.17 → python_fragments-0.19}/fragments/html/elements.py +9 -5
- {python_fragments-0.17 → python_fragments-0.19}/pyproject.toml +1 -1
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/PKG-INFO +1 -1
- {python_fragments-0.17 → python_fragments-0.19}/tests/test_grammar.py +20 -0
- {python_fragments-0.17 → python_fragments-0.19}/README.md +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/__init__.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/cli.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/grammar.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/html/__init__.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/loader.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/__init__.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/based_proxy.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/__init__.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/code_actions.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/completion.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/definition.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/diagnostics.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/document_highlight.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/document_symbols.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/folding_range.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/hover.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/inlay_hints.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/lifecycle.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/references.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/rename.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/semantic_tokens.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/signature_help.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/file_state.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/message_queue.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/pyright_notification_handlers/__init__.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/pyright_notification_handlers/capability.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/pyright_notification_handlers/configuration.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/pyright_notification_handlers/diagnostics.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/types.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/source.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/fragments/transpiler.py +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/SOURCES.txt +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/dependency_links.txt +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/entry_points.txt +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/requires.txt +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/top_level.txt +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/setup.cfg +0 -0
- {python_fragments-0.17 → python_fragments-0.19}/tests/test_source_map.py +0 -0
|
@@ -389,7 +389,8 @@ class ASTHTMLAttribute:
|
|
|
389
389
|
self.transpiled_start = transpiled_start
|
|
390
390
|
|
|
391
391
|
if self.string_literal is not None:
|
|
392
|
-
|
|
392
|
+
escaped_literal = self.string_literal.replace("\n", "\\n").replace("\t", "\\t").replace("\r", "\\r").replace('"', '"')
|
|
393
|
+
self.transpiled_content = self.__template__.format(self.name, escaped_literal)
|
|
393
394
|
self.transpiled_end = self.transpiled_start + len(self.transpiled_content)
|
|
394
395
|
return
|
|
395
396
|
|
|
@@ -435,7 +436,7 @@ class ASTHTMLText:
|
|
|
435
436
|
__template__: str = '"{}"'
|
|
436
437
|
|
|
437
438
|
def transpile(self, transpiled_start: int) -> None:
|
|
438
|
-
self.transpiled_content = self.__template__.format(self.text)
|
|
439
|
+
self.transpiled_content = self.__template__.format(self.text.replace("\n", "\\n").replace("\t", "\\t").replace("\r", "\\r").replace('"', '"'))
|
|
439
440
|
self.transpiled_start = transpiled_start
|
|
440
441
|
self.transpiled_end = self.transpiled_start + len(self.transpiled_content)
|
|
441
442
|
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, Protocol
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class Stringable(Protocol):
|
|
5
|
+
def __str__(self) -> str: ...
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def sequence(children: list[str | Stringable]) -> str:
|
|
9
|
+
return "".join(str(child) for child in children)
|
|
6
10
|
|
|
7
11
|
|
|
8
12
|
def el(
|
|
9
13
|
name: str,
|
|
10
|
-
children: list[str],
|
|
14
|
+
children: list[str | Stringable],
|
|
11
15
|
oneline: bool,
|
|
12
16
|
attributes: dict[str, Any],
|
|
13
17
|
) -> str:
|
|
@@ -23,7 +27,7 @@ def el(
|
|
|
23
27
|
if oneline:
|
|
24
28
|
return f"""<{tag_contents_string} />"""
|
|
25
29
|
|
|
26
|
-
children_string =
|
|
30
|
+
children_string = sequence(children)
|
|
27
31
|
|
|
28
32
|
return f"""<{tag_contents_string}>{children_string}</{name}>"""
|
|
29
33
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-fragments"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.19"
|
|
8
8
|
description = "Modern HTML template rendering in Python"
|
|
9
9
|
authors = [{ name = "The Running Algorithm", email = "services@therunningalgorithm.info" }]
|
|
10
10
|
readme = "README.md"
|
|
@@ -94,6 +94,26 @@ def test_html_element_interpolation_attribute():
|
|
|
94
94
|
]))
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def test_html_attribute_multiline_string_literal_escaped_in_transpile():
|
|
98
|
+
source = Source.from_string('<><div class="foo\nbar">text</div></>')
|
|
99
|
+
_, fragment = grammar.expect_fragment(source)
|
|
100
|
+
fragment.transpile(0)
|
|
101
|
+
element = fragment.children[0]
|
|
102
|
+
assert isinstance(element, ASTHTMLElement)
|
|
103
|
+
assert "\\n" in element.attributes["class"].transpiled_content
|
|
104
|
+
assert "\n" not in element.attributes["class"].transpiled_content
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_html_attribute_tab_escaped_in_transpile():
|
|
108
|
+
source = Source.from_string('<><div class="foo\tbar">text</div></>')
|
|
109
|
+
_, fragment = grammar.expect_fragment(source)
|
|
110
|
+
fragment.transpile(0)
|
|
111
|
+
element = fragment.children[0]
|
|
112
|
+
assert isinstance(element, ASTHTMLElement)
|
|
113
|
+
assert "\\t" in element.attributes["class"].transpiled_content
|
|
114
|
+
assert "\t" not in element.attributes["class"].transpiled_content
|
|
115
|
+
|
|
116
|
+
|
|
97
117
|
def test_html_element_boolean_attribute():
|
|
98
118
|
source = Source.from_string("<><input disabled /></>")
|
|
99
119
|
source, fragment = grammar.expect_fragment(source)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/completion.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/definition.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/hover.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/inlay_hints.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/lifecycle.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/references.py
RENAMED
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/fragments/lsp/client_message_handlers/rename.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fragments-0.17 → python_fragments-0.19}/python_fragments.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|