codecollabspace / chatgpt_citations

A browser extension designed to generate BibTeX citations from chat conversations in OpenAI's ChatGPT interface.
MIT License
0 stars 0 forks source link

Latex code inside the prompt #5

Closed mcquenji closed 8 months ago

mcquenji commented 8 months ago

When latex code is present inside the prompt and you paste the citation into bibtex, it will try to interpret the latex code and most likely throw an error. if it doesn't throw you'll have subheadings in your references like this:

image

beautiful isn't it :)


we should escape characters with the following snippet:

function escapeLaTeX(str) {
  return str
    .replace(/\\/g, '\\\\')
    .replace(/~/g, '\\~')
    .replace(/\^/g, '\\^')
    .replace(/&/g, '\\&')
    .replace(/%/g, '\\%')
    .replace(/\$/g, '\\$')
    .replace(/#/g, '\\#')
    .replace(/_/g, '\\_')
    .replace(/{/g, '\\{')
    .replace(/}/g, '\\}');
}
officialbishowb commented 8 months ago

escapeLaTeX has been added. Apparently it works if you add \textbackslash before any latex code.