Skip to content

Commit

Permalink
If the first character of a line is a number, the first letter after …
Browse files Browse the repository at this point in the history
…that number will not be capitalized (#84)

A lot of our edition statements particularly were looking odd for ordinal numbers with values like "1St edition". I double checked the MLA handbook, and "1st" is the correct behavior.
  • Loading branch information
maxkadel authored Oct 11, 2024
1 parent dc2bcb1 commit a5c2228
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/citeproc/ruby/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def apply_text_case
output.replace CiteProc.upcase output

when 'capitalize-first'
output.sub!(/^([^\p{L}]*)(\p{Ll})/) { "#{$1}#{CiteProc.upcase($2)}" }
output.sub!(/^([^\p{Alnum}]*)(\p{Ll})/) { "#{$1}#{CiteProc.upcase($2)}" }

when 'capitalize-all'
output.gsub!(/\b(\p{Ll})/) { CiteProc.upcase($1) }
Expand Down
7 changes: 7 additions & 0 deletions spec/citeproc/ruby/formats/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ module Ruby
expect(format.apply('én foo bar', node)).to eq('Én foo bar')
end

it 'supports capitalize-first with ordinal numbers' do
node[:'text-case'] = 'capitalize-first'

expect(format.apply('1st edition', node)).to eq('1st edition')
expect(format.apply('first edition', node)).to eq('First edition')
end

it 'supports capitalize-all' do
node[:'text-case'] = 'capitalize-all'

Expand Down

0 comments on commit a5c2228

Please sign in to comment.