python-fragments 0.26__py3-none-any.whl → 0.28__py3-none-any.whl

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.
fragments/ast_nodes.py CHANGED
@@ -91,7 +91,8 @@ class ASTFragment:
91
91
  for child in self.children:
92
92
  child.transpile(transpiled_start)
93
93
  transpiled_start = child.transpiled_end + 1
94
- transpiled_start -= 1
94
+ if len(self.children) > 0:
95
+ transpiled_start -= 1
95
96
 
96
97
  self.transpiled_content = self.__template__.format(",".join(child.transpiled_content for child in self.children))
97
98
  self.transpiled_end = self.transpiled_start + len(self.transpiled_content)
@@ -133,7 +134,7 @@ class ASTHTMLElement:
133
134
  for child in self.children:
134
135
  child.transpile(transpiled_start)
135
136
  transpiled_start = child.transpiled_end + 1
136
- if self.children:
137
+ if len(self.children) > 0:
137
138
  transpiled_start -= 1
138
139
  children = ",".join(child.transpiled_content for child in self.children)
139
140
  oneline_offset = len(str(self.one_line))
@@ -406,7 +407,8 @@ class ASTHTMLComment:
406
407
 
407
408
  def transpile(self, transpiled_start: int) -> None:
408
409
  self.transpiled_start = transpiled_start
409
- self.transpiled_content = self.__template__.format(self.content)
410
+ escaped_content = self.content.replace("\n", "\\n").replace("\t", "\\t").replace("\r", "\\r").replace('"', '\\"')
411
+ self.transpiled_content = self.__template__.format(escaped_content)
410
412
  self.transpiled_end = self.transpiled_start + len(self.transpiled_content)
411
413
 
412
414
  def map_offset(self, offset: int) -> None:
fragments/grammar.py CHANGED
@@ -277,7 +277,7 @@ def expect_children(source: Source) -> tuple[Source, list[ASTHTMLChild]]:
277
277
 
278
278
  def expect_interpolation(source: Source) -> tuple[Source, ASTInterpolation]:
279
279
  """An interpolation block."""
280
- INTERPOLATION_EXPRESSION = r"([\s\S]*?)(?= }})"
280
+ INTERPOLATION_EXPRESSION = r"([\s\S]*?)(?=\s*}})"
281
281
  source_start = source.offset
282
282
  source = expect_string(source, "{{")
283
283
  source, leading_whitespace = source.eat_whitespace()
@@ -18,7 +18,7 @@ def el(
18
18
  name,
19
19
  className_to_string(attributes.pop("className")) if "className" in attributes else None,
20
20
  style_to_string(attributes.pop("style")) if "style" in attributes else None,
21
- attributes_to_string(attributes) if attributes is not None else None,
21
+ attributes_to_string(attributes) if attributes else None,
22
22
  ]
23
23
  tag_contents = [item for item in tag_contents if item is not None]
24
24
  tag_contents_string = " ".join(tag_contents)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fragments
3
- Version: 0.26
3
+ Version: 0.28
4
4
  Summary: Modern HTML template rendering in Python
5
5
  Author-email: The Running Algorithm <services@therunningalgorithm.info>
6
6
  License: Proprietary
@@ -1,13 +1,13 @@
1
1
  fragments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fragments/ast_nodes.py,sha256=LKj73eO04I01_po8F2vNT8yCziECt8bMS1Vfo12V70Y,19988
2
+ fragments/ast_nodes.py,sha256=qw0YrnrQOUaGnjfY3ZYFCF5yGMSOqhZ-MQ0vM6Mlekg,20161
3
3
  fragments/cli.py,sha256=9P9fvurRlROstWUh-tjneFt9IrVvgxcBEd3pn0wL_CE,1292
4
- fragments/grammar.py,sha256=5JzDukLFxhyxWOWUJQFzKNsfm0RTtSjF678vOLjDLW4,12887
4
+ fragments/grammar.py,sha256=pM7H0ZN3L6dLNG6xTHjg8lans4WcWZnOjsEoM5D3zeE,12889
5
5
  fragments/loader.py,sha256=7nlsXVjCpRRmd939UJQqd9NWbE2-3ZtbO0aFfz3zCs8,980
6
6
  fragments/source.py,sha256=cbDzLOlFy2C6xZe-ZWcroieGG-7PLTdLJi003aIdegg,1000
7
7
  fragments/transpiler.py,sha256=O4pusCuv_Hbms2J0AP3tun-uNkXfb27RBUugr_0dIVA,316
8
8
  fragments/types.py,sha256=tPD0YHT5rOaZMfrXWDz6W0HEQwu4EJyfVNR-pd_CX0A,152
9
9
  fragments/html/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- fragments/html/elements.py,sha256=admLd2C9hcxdSjAwA9XvS7BbxMfregzwb_4AuBtOF_0,1898
10
+ fragments/html/elements.py,sha256=iKzCCPvZNMYLIHW5ZVYy27zQcRxLnEP-B8fND_H4hF4,1886
11
11
  fragments/lsp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  fragments/lsp/based_proxy.py,sha256=pFH-70H7uvy8yqxmq2s3jOmHw_CrAUHzyqiQXmDpJEI,3746
13
13
  fragments/lsp/file_state.py,sha256=mghS-hcvZyPb8n9Ufypteu9DDZfv9Ktin-3C7GYxBh0,3292
@@ -32,8 +32,8 @@ fragments/lsp/pyright_notification_handlers/__init__.py,sha256=47DEQpj8HBSa-_TIm
32
32
  fragments/lsp/pyright_notification_handlers/capability.py,sha256=1xH6SttTtWKAovCfx8WeJApRI4rrVlZDGCWHtlyGTUE,868
33
33
  fragments/lsp/pyright_notification_handlers/configuration.py,sha256=Qomq8tCVcBg15MYDPby-PeRp4kJe7k8o6-2VRAYQ0hI,1009
34
34
  fragments/lsp/pyright_notification_handlers/diagnostics.py,sha256=n_YZ8k8PHKcpHrgmTYTU2-pKi0P_v_WC1irqtAcs_iI,1107
35
- python_fragments-0.26.dist-info/METADATA,sha256=3es1e7oJTxa5wcarNEWlor8W4oRTuzz3zmAOFMwBnX0,1545
36
- python_fragments-0.26.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
37
- python_fragments-0.26.dist-info/entry_points.txt,sha256=9xVMCpt9OucM3W3fh0UnEeErKEyI6CNIFqfQCIuGmi8,96
38
- python_fragments-0.26.dist-info/top_level.txt,sha256=4r1SNnHOK3BVhAT_KgV8MRq9kiV23yK_rnuTAEl5oRg,10
39
- python_fragments-0.26.dist-info/RECORD,,
35
+ python_fragments-0.28.dist-info/METADATA,sha256=jSi9Rcv_kLtNSzL3bf0r3j1K636d7IENZp3-OtU9eag,1545
36
+ python_fragments-0.28.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
37
+ python_fragments-0.28.dist-info/entry_points.txt,sha256=9xVMCpt9OucM3W3fh0UnEeErKEyI6CNIFqfQCIuGmi8,96
38
+ python_fragments-0.28.dist-info/top_level.txt,sha256=4r1SNnHOK3BVhAT_KgV8MRq9kiV23yK_rnuTAEl5oRg,10
39
+ python_fragments-0.28.dist-info/RECORD,,