Browse Source

Fix capitalization hook.

scossu 2 months ago
parent
commit
a255131c57
1 changed files with 7 additions and 5 deletions
  1. 7 5
      scriptshifter/hooks/general/__init__.py

+ 7 - 5
scriptshifter/hooks/general/__init__.py

@@ -45,7 +45,6 @@ def capitalize_post_assembly(ctx):
     return " ".join(dest_ls)
     return " ".join(dest_ls)
 
 
 
 
-
 def normalize_spacing_post_assembly(ctx):
 def normalize_spacing_post_assembly(ctx):
     """
     """
     Remove duplicate and unwanted whitespace around punctuation.
     Remove duplicate and unwanted whitespace around punctuation.
@@ -76,14 +75,17 @@ def normalize_spacing_post_assembly(ctx):
 
 
 def _capitalize(src, which):
 def _capitalize(src, which):
     """
     """
-    Only capitalize first word and words preceded by space.
+    capitalize first word only or all words.
 
 
     NOTE: this function is only used for capitalizing hook-generated
     NOTE: this function is only used for capitalizing hook-generated
     transliterations, which are not normally processed. Double cap rules are
     transliterations, which are not normally processed. Double cap rules are
     not applicable here.
     not applicable here.
     """
     """
     if which == "first":
     if which == "first":
-        ctx.dest_ls[0] = ctx.dest_ls[0].upper()
+        src[0] = src[0].capitalize()
+        return src
+
+    if which == "all":
+        return [tk[0].upper() + tk[1:] for tk in src]
 
 
-    elif which == "all":
-        ctx.dest_ls = [tk[0].upper() + tk[1:] for tk in ctx.dest_ls]
+    return src