inukshuk / citeproc-ruby

A Citation Style Language (CSL) Cite Processor
101 stars 22 forks source link

Case protecting braces are passed through to HTML #81

Open luc-j-bourhis opened 1 year ago

luc-j-bourhis commented 1 year ago

Consider

require 'bibtex'
require 'citeproc'
require 'csl/styles'

bib = BibTeX::Bibliography.parse(<<~'BIB'
  @book{Grant:2018,
    author = {Grant, Keith J.},
    publisher = {Manning},
    title = {{CSS} in depth},
    year = {2018}}
BIB
)
cp = CiteProc::Processor.new(style: 'apa', format: 'html')
cp.import(bib.to_citeproc)
puts cp.render(:bibliography, id: 'Grant:2018')

This produces

Grant, K. J. (2018). <i>{CSS} in depth</i>. Manning.

The braces are passed through all the way from BibTeX to HTML, leading to an incorrect rendering. The correct one would obviously be

Grant, K. J. (2018). <i>CSS in depth</i>. Manning.

since HTML respect the input case.

The issue might be in bibtex though: if so, I apologise for bugging you here.

inukshuk commented 1 year ago

I think the latex decode filter would strip those braces off by default. Something like bib.convert(:latex).to_citeproc

luc-j-bourhis commented 1 year ago

Yes, sure but in the LaTeX world, removing those braces would not be correct because BibTeX styles may then put CSS in lower case (or more likely capitalise it in my example). Is there not the same issue with citeproc and csl/styles? My question may be completely dumb: I am just starting to use citeproc, coming from a LaTeX background.

inukshuk commented 1 year ago

Ah, I see. I might be missing something, but I don't think there's a standardized way in CSL to protect words like that.

luc-j-bourhis commented 1 year ago

I see, thank you. Cognitive dissonance of mine then, and your solution works perfectly then (I already used it because there might be other LaTeX formatting that needs to be put in HTML form of course). I reckon this can be closed then.