lib/citeproc/ruby/format.rb in citeproc-ruby-1.1.0 vs lib/citeproc/ruby/format.rb in citeproc-ruby-1.1.1

- old
+ new

@@ -229,19 +229,32 @@ # TODO add support for stop words consisting of multiple words #output.gsub!(/\b(\p{Lu})(\p{Lu}+)\b/) { "#{$1}#{CiteProc.downcase($2)}" } # TODO exceptions: word followed by colon first = true - output.gsub!(/\b(\p{Ll})(\p{L}+)\b/) do |word| - if Format.stopword?(word) and not first + output.gsub!(/\b(\p{L})([\p{L}\.]+)\b/) do |word| + first_letter = $1 + rest_of_word = $2 + result = word + + if first_letter.match(/^\p{Ll}/) && (!Format.stopword?(word) || first) + result = "#{CiteProc.upcase(first_letter)}#{rest_of_word}" + end + first = false + result + end + + output.gsub!(/(\.|\b)(\p{Ll})([\p{L}\.]+)\b$/) do |word| + word_boundary = $1 + first_letter = $2 + rest_of_word = $3 + + if word_boundary == '.' word else - first = false - "#{CiteProc.upcase($1)}#{$2}" + "#{CiteProc.upcase($2)}#{$3}" end end - output.gsub!(/\b(\p{Ll})(\p{L}+)\b$/) { "#{CiteProc.upcase($1)}#{$2}" } - end end def punctuation_in_quotes? !locale.nil? && locale.punctuation_in_quotes?