Citation Style Language

Title and Sentence Casing

I’m having trouble squaring expected test results to the spec.

Sentence case conversion (with text-case set to “sentence”) is performed by:

  1. For uppercase strings, the first character of the string remains capitalized. All other letters are lowercased.
  2. For lower or mixed case strings, the first character of the first word is capitalized if the word is lowercase. The case of all other words stays the same.

So:

  • Example 1: THIS IS A SENTENCE is an uppercase string, which falls under rule 1, and I would expect This is a sentence
  • Example 2: This is a Sentence is a mixed case string, but strictly speaking falls under neither rule, because the first word is not lowercase, but mixed case. I would assume This is a Sentence
  • Example 3: this is a Sentence is a mixed case string, which falls under rule 2, so the first word is capitalised but the case of all other words stays the same: This is a Sentence.

However … textcase_SentenceCapitalization.txt takes the input

`This is a Pen that is a <span class=“nocase”>Smith Pencil

And expects the output

This is a pen that is a Smith pencil

That seems to be applying a different rule 2, in which for mixed case strings, the first letter of the string is capitalized, and all other words are converted to lower-case (unless “protected” with a nocase tag. If I apply the rules, I’d expect to get

This is a Pen that is a Smith Pencil

Is the test here wrong?

That does seem like a contradiction. I’d never looked that closely at the sentence case spec before, but the test behavior is what I’ve always expected and why the CSL styles repo prohibits using text-case=“sentence”.

In any event, neither the spec nor test behavior is very useful. Neither reliably produces correct sentence case—either proper nouns are incorrectly lowercased or non-proper noun words are incorrectly left in uppercase.

For those reasons, sentence case is deprecated and set for removal in CSL 1.1, so I wouldn’t worry too much about tests for it.

Thank you! It’s always good to have something that one doesn’t have to worry about.

1 Like