racket/scribble

bibtex doesn't handle escapes properly

wilbowma opened this issue · 0 comments

There are three kinds of mishandled escapes below:

  • bibtex escapes:
    • escaping # when it appears in a string \#. The \ gets rendered as a URL escape character, but should have been ignored.
    • escaping capital letters {CPS}. This escapes gets rendered as capital but eats the whitespace following it.
  • latex such as {\"u} and {$\Sigma$}.

I suppose handling the latex escapes is non-trivial, but the bibtex escapes should probably be handled properly. Could possibly handle the latex escapes by passing them on as literal, and assuming the backend knows how to handle them.

#lang scribble/base
@(require
  racket/dict
  racket/port
  scriblib/bibtex
  scriblib/autobib
  rackunit)

@(require/expose scriblib/bibtex (generate-bib))

@(define mybibs
  (call-with-input-string
     @string-append|{@Article{bowman2018:cps-sigma,
       author   = {Bowman, William J. and Cong, Youyou and Rioux, Nick and Ahmed, Amal},
       title    = {Type-preserving {CPS} Translation of {$\Sigma$} and {$\Pi$} Types Is Not Not Possible},
       url      = {https://www.williamjbowman.com/papers\#cps-sigma},
       journal  = {PACMPL},
       year = 2018,
     }

     @Article{flueckiger2018:jit,
       author    = {Fl{\"u}ckiger, Olivier and Scherer, Gabriel and Yee, Ming-Ho and Goel, Aviral and Ahmed, Amal and Vitek, Jan},
       title     = {Correctness of speculative optimizations with dynamic deoptimization},
       year = 2018,
       journal  = {PACMPL},
       }}| bibtex-parse))

@(define-cite a~cite acitet generate-bibliography)

@(define (~cite str)
  (a~cite (generate-bib mybibs str)))

@~cite{bowman2018:cps-sigma}
@~cite{flueckiger2018:jit}

@(generate-bibliography)