tstring-html-bindings 0.1.5__tar.gz → 0.1.6__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.
Files changed (16) hide show
  1. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/Cargo.lock +5 -5
  2. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/Cargo.toml +1 -1
  3. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/PKG-INFO +1 -1
  4. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/pyproject.toml +1 -1
  5. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-bindings/Cargo.toml +2 -2
  6. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-bindings/src/lib.rs +32 -2
  7. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-rs/src/lib.rs +1 -1
  8. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-thtml-rs/Cargo.toml +1 -1
  9. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-thtml-rs/src/lib.rs +2 -2
  10. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/README.md +0 -0
  11. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/python/tstring_html_bindings/__init__.py +0 -0
  12. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-format-doc-rs/Cargo.toml +0 -0
  13. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-format-doc-rs/src/lib.rs +0 -0
  14. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-bindings/README.md +0 -0
  15. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-rs/Cargo.toml +0 -0
  16. {tstring_html_bindings-0.1.5 → tstring_html_bindings-0.1.6}/tstring-html-rs/src/formatter.rs +0 -0
@@ -290,14 +290,14 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
290
290
 
291
291
  [[package]]
292
292
  name = "tstring-format-doc"
293
- version = "0.1.5"
293
+ version = "0.1.6"
294
294
  dependencies = [
295
295
  "unicode-width",
296
296
  ]
297
297
 
298
298
  [[package]]
299
299
  name = "tstring-html"
300
- version = "0.1.5"
300
+ version = "0.1.6"
301
301
  dependencies = [
302
302
  "tstring-format-doc",
303
303
  "tstring-syntax",
@@ -305,7 +305,7 @@ dependencies = [
305
305
 
306
306
  [[package]]
307
307
  name = "tstring-html-backend-e2e-tests"
308
- version = "0.1.5"
308
+ version = "0.1.6"
309
309
  dependencies = [
310
310
  "serde",
311
311
  "toml",
@@ -316,7 +316,7 @@ dependencies = [
316
316
 
317
317
  [[package]]
318
318
  name = "tstring-html-bindings"
319
- version = "0.1.5"
319
+ version = "0.1.6"
320
320
  dependencies = [
321
321
  "pyo3",
322
322
  "tstring-html",
@@ -335,7 +335,7 @@ dependencies = [
335
335
 
336
336
  [[package]]
337
337
  name = "tstring-thtml"
338
- version = "0.1.5"
338
+ version = "0.1.6"
339
339
  dependencies = [
340
340
  "tstring-html",
341
341
  "tstring-syntax",
@@ -9,7 +9,7 @@ homepage = "https://github.com/koxudaxi/tstring-html"
9
9
  license = "MIT"
10
10
  repository = "https://github.com/koxudaxi/tstring-html"
11
11
  rust-version = "1.94.0"
12
- version = "0.1.5"
12
+ version = "0.1.6"
13
13
 
14
14
  [workspace.dependencies]
15
15
  pyo3 = "0.27.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tstring-html-bindings
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tstring-html-bindings"
3
- version = "0.1.5"
3
+ version = "0.1.6"
4
4
  description = "Native Python bindings for tstring-html"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -19,8 +19,8 @@ extension-module = ["pyo3/extension-module"]
19
19
 
20
20
  [dependencies]
21
21
  pyo3 = { workspace = true, features = ["abi3-py314"] }
22
- tstring-html = { version = "0.1.5", path = "../tstring-html-rs" }
23
- tstring-thtml = { version = "0.1.5", path = "../tstring-thtml-rs" }
22
+ tstring-html = { version = "0.1.6", path = "../tstring-html-rs" }
23
+ tstring-thtml = { version = "0.1.6", path = "../tstring-thtml-rs" }
24
24
  tstring-syntax.workspace = true
25
25
 
26
26
  [dev-dependencies]
@@ -607,7 +607,9 @@ fn render_thtml_node(
607
607
  for child in &element.children {
608
608
  match child {
609
609
  Node::Text(text) => out.push_str(&text.value),
610
- Node::Interpolation(interpolation) if element.name == "title" => {
610
+ Node::Interpolation(interpolation)
611
+ if element.name.eq_ignore_ascii_case("title") =>
612
+ {
611
613
  let Some(value) = context.values.get(interpolation.interpolation_index)
612
614
  else {
613
615
  return Err(runtime_error_to_py(
@@ -929,7 +931,9 @@ fn tstring_html_bindings(py: Python<'_>, module: &Bound<'_, PyModule>) -> PyResu
929
931
 
930
932
  #[cfg(test)]
931
933
  mod tests {
932
- use super::ParseCache;
934
+ use super::{ParseCache, render_thtml_node};
935
+ use pyo3::Python;
936
+ use tstring_html::{Node, RuntimeContext, RuntimeValue};
933
937
 
934
938
  #[test]
935
939
  fn parse_cache_reuses_entries() {
@@ -1020,4 +1024,30 @@ mod tests {
1020
1024
  assert_eq!(*value, 7);
1021
1025
  assert_eq!(attempts, 2);
1022
1026
  }
1027
+
1028
+ #[test]
1029
+ fn render_thtml_node_treats_uppercase_title_as_escaped_text() {
1030
+ Python::attach(|py| {
1031
+ let node = Node::RawTextElement(tstring_html::RawTextElementNode {
1032
+ name: "TITLE".to_string(),
1033
+ attributes: Vec::new(),
1034
+ children: vec![Node::Interpolation(tstring_html::InterpolationNode {
1035
+ interpolation_index: 0,
1036
+ expression: "title".to_string(),
1037
+ raw_source: Some("{title}".to_string()),
1038
+ conversion: None,
1039
+ format_spec: String::new(),
1040
+ span: None,
1041
+ })],
1042
+ span: None,
1043
+ });
1044
+ let context = RuntimeContext {
1045
+ values: vec![RuntimeValue::RawHtml("<safe>".to_string())],
1046
+ };
1047
+ let mut out = String::new();
1048
+ render_thtml_node(py, &node, &context, None, None, &mut out)
1049
+ .expect("render uppercase title");
1050
+ assert_eq!(out, "<TITLE>&lt;safe&gt;</TITLE>");
1051
+ });
1052
+ }
1023
1053
  }
@@ -830,7 +830,7 @@ pub fn is_raw_text_tag(name: &str) -> bool {
830
830
  }
831
831
 
832
832
  fn raw_text_allows_interpolation(name: &str) -> bool {
833
- name == "title"
833
+ name.eq_ignore_ascii_case("title")
834
834
  }
835
835
 
836
836
  fn validate_html_document(document: &Document) -> BackendResult<()> {
@@ -9,5 +9,5 @@ rust-version.workspace = true
9
9
  version.workspace = true
10
10
 
11
11
  [dependencies]
12
- tstring-html = { version = "0.1.5", path = "../tstring-html-rs" }
12
+ tstring-html = { version = "0.1.6", path = "../tstring-html-rs" }
13
13
  tstring-syntax.workspace = true
@@ -115,7 +115,7 @@ fn validate_raw_text_children(element: &tstring_html::RawTextElementNode) -> Bac
115
115
  for child in &element.children {
116
116
  match child {
117
117
  Node::Text(_) => {}
118
- Node::Interpolation(_) if element.name == "title" => {}
118
+ Node::Interpolation(_) if element.name.eq_ignore_ascii_case("title") => {}
119
119
  Node::Interpolation(interpolation) => {
120
120
  return Err(semantic_error(
121
121
  "html.semantic.raw_text_interpolation",
@@ -124,7 +124,7 @@ fn validate_raw_text_children(element: &tstring_html::RawTextElementNode) -> Bac
124
124
  ));
125
125
  }
126
126
  _ => {
127
- let message = if element.name == "title" {
127
+ let message = if element.name.eq_ignore_ascii_case("title") {
128
128
  format!(
129
129
  "Only text and interpolations are allowed inside <{}>.",
130
130
  element.name