Newline-wrapped titles and summaries in API responses

52 views
Skip to first unread message

lukas....@gmail.com

unread,
Oct 4, 2020, 10:17:43 PM10/4/20
to arXiv API
Hello––a question about the API's design that came in via my wrapper library's GitHub issues:

Titles and summaries seem to be line-wrapped at ~80 characters, though it seems they can also include user-submitted newlines. I see mention in arXiv's documentation of line-wrapping for emails, but no mention in the API docs.

Was this an intentional API design decision?

I, for one, would prefer if it didn't; it forces users who want to un-wrap the text to retransform the string, which risks modifying more than the line wraps arXiv introduced. In general, enforcing a representational decision in the API seems like a violation of the separation of concerns an API can offer: the API manages the data, and the consumer manages the representation.

An example request yielding a line-wrapped title and summary:
curl --request GET \
  --cookie browser=162.238.31.217.1582174072289109

Thanks,
Lukas

Thorsten

unread,
Oct 4, 2020, 10:23:06 PM10/4/20
to arXiv API

Hi Lukas,

I don't think that was intentional and in fact I believe it is due to some recent changes.

The original API code (ca 2007) explicitly removed such wrapping from the stored abstract files

    226     # Remove fixed width formatting. Leave multiple spaces for  
   227     # para indent after return as these might show up and help to  
   228     # separate paragraph in some display.
   229     $abstract=~s/^\s+//;
   230     $abstract=~s/\n(?!\s)/ /g;
   231     $abstract=~s/\s+$//;

and

   223     $atom_entry->title(_unwrap_unindent($self->field('Title')));

where

    416 sub _unwrap_unindent {
   417   my ($str)=@_;
   418   $str=~s/\n\s+/ /g;
   419   return($str);
   420 }


Anyhow, the intention is to replace the legacy Atom API with a modernized json based REST API 

Cheers
T.
Reply all
Reply to author
Forward
0 new messages