retorquere / bibtex-parser

A node/npm package for parsing bibtex (.bib) files. This is the parser that drives Better BibTeX for Zotero bib(la)tex imports.
http://retorque.re/bibtex-parser/
MIT License
22 stars 3 forks source link

In abstract <> are changed to ¡¿ #8

Closed crystalfp closed 4 years ago

crystalfp commented 4 years ago

Thanks for the library! I have the entry below that contains some markdown in the abstract field. Maybe it is a bibtex rule I don't remember, but my links <http://something.com> are changed to ¡http://something¿. Is setting the option raw: true the only alternative to preserve <>? I tried to use {markup: {enquote: {open: "<", close: ">"}}} but has no effect. Any suggestions about how to change the interpretation of only <>? Thanks a lot! mario

@article{Caspi2016,
  doi = {10.1038/s41562-016-0005},
  url = {https://www.nature.com/articles/s41562-016-0005},
  date  = {2016-12-12},
  publisher = {Springer Nature},
  volume = {1},
  number = {1},
  pages = {0005},
  author = {Avshalom Caspi and Renate M. Houts and Daniel W. Belsky and Honalee Harrington and Sean Hogan and Sandhya Ramrakha and Richie Poulton and Terrie E. Moffitt},
  title = {Childhood forecasting of a small segment of the population with large economic burden},
  journaltitle = {Nature Human Behaviour},
  abstract = {Policymakers are interested in early-years interventions to ameliorate childhood risks. They hope for improved adult outcomes in the long run that bring a return on investment. The size of the return that can be expected partly depends on how strongly childhood risks forecast adult outcomes, but there is disagreement about whether childhood determines adulthood. We integrated multiple nationwide administrative databases and electronic medical records with the four-decade-long Dunedin birth cohort study to test child-to-adult prediction in a different way, using a population-segmentation approach. A segment comprising 22% of the cohort accounted for 36% of the cohort’s injury insurance claims; 40% of excess obese kilograms; 54% of cigarettes smoked; 57% of hospital nights; 66% of welfare benefits; 77% of fatherless child-rearing; 78% of prescription fills; and 81% of criminal convictions. Childhood risks, including poor brain health at three years of age, predicted this segment with large effect sizes. Early-years interventions that are effective for this population segment could yield very large returns on investment.

Around the world, the population is ageing and total fertility rates are declining. As a result, nations increasingly view children and young people as valuable resources for the economic and social well-being of whole societies. This view is accompanied by public-policy interest in early interventions to help as many children as possible achieve their full potential. A key question concerns the potential size of the impact that might be brought about by interventions in the early years of children’s lives. Research teams that have followed up on small samples of children who were enrolled in intervention experiments carried out decades ago point to reductions in school leaving, unemployment, crime, obesity and even blood pressure. Some argue that today’s better-designed interventions might achieve greater reductions in adult problems than previous efforts (see also <http://www.nuffieldfoundation.org>, <http://www.blueprintsprograms.com>, <http://ies.ed.gov/ncee/wwc> and <http://incredibleyears.com>). Others assert that interventions for the youngest children will bring an even greater return on investment compared with interventions that begin when children are older. However, a skeptic could point out that return on investment for society will depend not only on an intervention’s capacity to ameliorate childhood risks, but also on how relevant those risks are for downstream adult functioning in the general population. Thus, to a large extent, the question of how much early-years intervention can lift health and social well-being and reduce costs depends on how strongly early-years risk factors are tied to adult outcomes in the population. Our own research and that of others suggests that while childhood risk factors do predict adult outcomes with statistical significance, the effect sizes are typically modest. The interpretation of these modest child-to-adult effect sizes is polarizing, and has sown confusion among scientists, policy makers and the public. On the one hand, claims are made that the ‘child is father of the man’, because continuity from childhood risks to adult outcomes is stronger than expected, given the long duration of follow-up. On the other hand, on the basis of the same data, warnings are issued about the myth of early-childhood determinism and about unwarranted overemphasis on childhood.

  Here, we tackled the prediction question anew in the context of the Dunedin Longitudinal Study, a population-representative 1972–1973 birth cohort of 1,037 New Zealanders assessed at ages 3, 5, 7, 9, 11, 13, 15, 18, 21, 26, 32 and 38 years and followed from birth to midlife with 95% retention. We first integrated our longitudinal survey data and clinical data with multiple nationwide government administrative databases and electronic medical records. Then, using a novel segmentation approach, we tested the hypothesis that a small segment of the adult population accounts for a large cumulative economic burden and that this segment can be predicted with good accuracy from early childhood.}
}
retorquere commented 4 years ago

You can condigure abstract to be a verbatim field, or replace < and > with $<$ and $>$ before parsing, but the latter will give you wrong results if you actually do have formulas with < or > somewhere.

How did you get this bibtex? No bibtex fields are expected to hold markdown, and from a latex point of view, the interpretation you found is the correct one. Outside formulas, < and > really do mean those upside down ! and ? to latex.

retorquere commented 4 years ago

Unescaped % signs in bibtex is also likely to give you unwanted behavior in bibtex. % means "ignore the rest of this line" in latex.

crystalfp commented 4 years ago

Thanks @retorquere for your observations!

I have notes written in markdown that contains a BibTeX reference as verbatim block. What I was trying to do is to put the note inside the reference in the abstract field and use tools like JabRef to manage the reference files. This way I don't lose my notes and can cite the entry in a document.

So seems better if I put my markdown notes in a different field (notes or comment) and declare this field verbatim for the library.

Thanks! mario

crystalfp commented 4 years ago

Leaving under abstract the first paragraph, moving the 2nd and 3rd to a note field and calling the library this way: const bibliography = parse(src, {verbatimFields: ["url", "note", "doi"]}) as Bibliography; solved the problem.

BTW, the percentages (22%, 66% etc.) in the abstract fields seems to be not interpreted by BibTex as comments.

Thanks! mario

retorquere commented 4 years ago

In my experience percent-handling is inconsistent, which I think is worse than it just failing. But this parser will just read them as percent.

crystalfp commented 4 years ago

Problem understood, issue solved, so I close it. Thanks!