citeproc-ruby icon indicating copy to clipboard operation
citeproc-ruby copied to clipboard

Still seeing nil pointer exception in squeeze on MLA

Open jcoyne opened this issue 6 months ago • 3 comments

Same problem as #88. But this occurs even after upgrading to 2.1.2

On this line: https://github.com/inukshuk/citeproc-ruby/blob/master/lib/citeproc/ruby/format.rb#L81

 NoMethodError: undefined method 'end_with?' for nil squeezable?(c) && string.end_with?(suffix[0, i + 1]) ^^^^^^^^^^ 
        suffix = suffix.each_char.drop_while.with_index { |c, i|
          squeezable?(c) && string.end_with?(suffix[0, i + 1])
        }.join('')

jcoyne avatar Jun 20 '25 19:06 jcoyne

In 2.1.2, it did fix the case where publisher was <[Arhiv Kosova]>, but it does not fix the case where publisher is <Narodni muzej>

jcoyne avatar Jun 20 '25 20:06 jcoyne

I think in this case you should encode angle braces with &lt; and &gt; before rendering using the HTML formatter. With content like this you could run into issues when processing the result even if we make the squeeze function not fail. If I remember correctly, it's difficult to do this in the processor because there are cases where you legitimately have HTML or XML tags in the content and you're rendering out HTML/XML.

inukshuk avatar Jun 22 '25 11:06 inukshuk

@inukshuk I agree with that. It turns out this is some markup from the (somewhat obsolete) AACR2 (https://www.librarianshipstudies.com/2018/12/anglo-american-cataloguing-rules-aacr.html). I will be stripping this off because the consumers here are not aware of these rules. However, it would be best if it didn't crash.

jcoyne avatar Jun 23 '25 15:06 jcoyne