Repository: typst/hayagriva (rust)

Issue:
`font-variant="small-caps"` not supported for `<name>`
Hi folks,

I want to make a minor adjustment to the IEEE CSL definition, basically just having all author names in small caps. However, if I use small-caps as the `@font-variant` of the `<name>` element itself, Typst does not render it correctly, it gets ignored.
When I move it up in the hierarchy to `<names>` it works, but will also show non-name words like "and" in small caps which I don't want.

Here is a screenshot showing that small-caps is ignored (see line 115):
![image](https://github.com/typst/hayagriva/assets/8217108/1d8df618-cd95-4c9f-bed0-cfdb72bcf23a)

Pull request description:
Propagate font-variant from name element to name parts
When using font-variant="small-caps" on the <name> element in CSL styles, this formatting wasn't properly inherited by the individual name parts, causing the styling to be ignored. This fix ensures that font-variant styling is correctly propagated from the parent <name> element to child name parts (given name and family name) while maintaining the behavior where connector words like "and" remain in normal text.

This allows for proper small-caps styling of author names in bibliography styles like IEEE while keeping connector words in regular formatting.

![image](https://github.com/user-attachments/assets/275f2b2b-97b0-4efb-86a5-db634aacf075)

Fixes #175.

Patch:
diff --git a/src/csl/rendering/names.rs b/src/csl/rendering/names.rs
index 3c93675..f39af7e 100644
--- a/src/csl/rendering/names.rs
+++ b/src/csl/rendering/names.rs
@@ -367,7 +367,9 @@ impl RenderCsl for Names {
             }
 
             do_label(NameLabelPosition::BeforeName, ctx);
+            let idx = ctx.push_format(cs_name.formatting);
             add_names(self, ctx, persons, &cs_name, forms, variable);
+            ctx.pop_format(idx);
             do_label(NameLabelPosition::AfterName, ctx);
         }
 


Test patch:
diff --git a/tests/citeproc-pass.txt b/tests/citeproc-pass.txt
index f325435..d086c50 100644
--- a/tests/citeproc-pass.txt
+++ b/tests/citeproc-pass.txt
@@ -9,6 +9,7 @@ affix_TextNodeWithMacro
 bugreports_Abnt
 bugreports_ArabicLocale
 bugreports_AsaSpacing
+bugreports_AsmJournals
 bugreports_AuthorYear
 bugreports_BadCitationUpdate
 bugreports_ChineseCharactersFamilyOnlyPluralLabel
diff --git a/tests/citeproc.rs b/tests/citeproc.rs
index b3f09ce..d9216b4 100644
--- a/tests/citeproc.rs
+++ b/tests/citeproc.rs
@@ -625,7 +625,9 @@ where
 mod citeproc_bib {
     use core::fmt;
 
-    use citationberg::{Display, FontStyle, FontVariant, FontWeight, VerticalAlign};
+    use citationberg::{
+        Display, FontStyle, FontVariant, FontWeight, TextDecoration, VerticalAlign,
+    };
     use hayagriva::{BufWriteFormat, Elem, ElemChild, Formatting};
 
     pub(super) fn render(
@@ -741,6 +743,13 @@ mod citeproc_bib {
             FontVariant::Normal => {}
         }
 
+        match formatting.text_decoration {
+            // NOTE: No existing citeproc tests use this, so this is guesswork.
+            // However, we can use this in local tests.
+            TextDecoration::Underline => push_elem("<u>", "</u>"),
+            TextDecoration::None => {}
+        }
+
         if !css.is_empty() {
             push_elem(&format!("<span style=\"{css}\">"), "</span>");
         }
diff --git a/tests/local/name_PartInheritsFormatting.txt b/tests/local/name_PartInheritsFormatting.txt
new file mode 100644
index 0000000..127930f
--- /dev/null
+++ b/tests/local/name_PartInheritsFormatting.txt
@@ -0,0 +1,93 @@
+
+>>===== MODE =====>>
+bibliography
+<<===== MODE =====<<
+
+
+
+>>===== RESULT =====>>
+<div class="csl-bib-body">
+  <div class="csl-entry">
+    <b>Doe Co.</b>
+    <span style="font-variant:small-caps;">Doe Co.</span>
+    <i>Doe Co.</i>
+    <i>Doe Co.</i>
+    <b><i><span style="font-variant:small-caps;">Doe Co.</span></i></b>
+    <sup><b><i><u><span style="font-variant:small-caps;">Doe Co.</span></u></i></b></sup>
+  </div>
+</div>
+<<===== RESULT =====<<
+
+
+>>===== CSL =====>>
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0">
+   <info>
+      <id />
+      <title />
+      <updated>2009-08-10T04:49:00+09:00</updated>
+   </info>
+   <citation>
+      <layout>
+        <text value="Bib only" />
+      </layout>
+   </citation>
+   <bibliography>
+      <layout>
+        <names variable="author">
+          <name font-weight="bold"/>
+        </names>
+        <names variable="author">
+          <name font-variant="small-caps"/>
+        </names>
+        <names variable="author">
+          <name font-style="italic"/>
+        </names>
+        <names variable="author" font-style="italic">
+          <name/>
+        </names>
+        <names variable="author">
+          <name font-weight="bold" font-variant="small-caps" >
+            <name-part name="family" font-style="italic"/>
+          </name>
+        </names>
+        <names variable="author">
+          <name font-style="italic" text-decoration="underline" vertical-align="sup">
+            <name-part name="family" font-weight="bold" font-variant="small-caps"/>
+          </name>
+        </names>
+      </layout>
+   </bibliography>
+</style>
+<<===== CSL =====<<
+
+
+>>===== INPUT =====>>
+[
+    {
+        "author": [
+            {
+                "family": "Doe Co.",
+                "isInstitution": true
+            }
+        ],
+        "id": "ITEM-1",
+        "issued": {
+            "date-parts": [
+                [
+                    "1965",
+                    "6",
+                    "1"
+                ]
+            ]
+        },
+        "title": "His Collectively Anonymous Life",
+        "type": "book"
+    }
+]
+<<===== INPUT =====<<
+
+
+>>===== VERSION =====>>
+1.0
+<<===== VERSION =====<<