bio-guoda / preston

a biodiversity dataset tracker
MIT License
25 stars 1 forks source link

add support for selecting lines of text files with Mac line endings '\r' #276

Closed jhpoelen closed 5 months ago

jhpoelen commented 5 months ago

There's three kinds of line endings:

unix '\n' DOS '\r'\n' Mac '\r'

Currently, preston supports unix/DOS, but when selecting a line in a file with Mac line endings (like with TaxoDros), nothing shows up:

e.g.,

preston cat 'line:hash://sha256/6cf7b4e856bce735b7e687d7cb76210a567d2e7f2e58d779a41cde75f05c9fd3!/L58651-L58661'

tells preston to select line L58651 - L58661 of content with id hash://sha256/6cf7b4e856bce735b7e687d7cb76210a567d2e7f2e58d779a41cde75f05c9fd3 .

currently, no result is returned, even though,

preston cat 'hash://sha256/6cf7b4e856bce735b7e687d7cb76210a567d2e7f2e58d779a41cde75f05c9fd3' | tr '\r' '\n' | tail -n+58651 | head -n11 

produced:

.TEXT;
garcia et al., 2020
.A Garcia-Cancino, M.D., Gonzalez-Cabrera, J.,
Sanchez-Gonzalez, J.A., & Arredondo-Bernal, H.C.,
.J 2020
.S Biological and Population Parameters, as well as
Oviposition Preference, of Two Pupal Parasitoids
of Drosophila suzukii (Diptera: Drosophilidae) in Mexico.
.Z J. Entomol. Sci., 55(1):87�97.
.K ocr++ / DOI:10.18474/0749- 8004-55.1.87
.P Garcia et al., 2020.pdf

Suggest to add support for mac line endings when selecting files for inclusion.

jhpoelen commented 5 months ago

with recent changes, the desired result was obtained -

preston cat 'line:hash://sha256/6cf7b4e856bce735b7e687d7cb76210a567d2e7f2e58d779a41cde75f05c9fd3!/L58651-L58661' | tr '\r' '\n'

yielding

.TEXT;
garcia et al., 2020
.A Garcia-Cancino, M.D., Gonzalez-Cabrera, J.,
Sanchez-Gonzalez, J.A., & Arredondo-Bernal, H.C.,
.J 2020
.S Biological and Population Parameters, as well as
Oviposition Preference, of Two Pupal Parasitoids
of Drosophila suzukii (Diptera: Drosophilidae) in Mexico.
.Z J. Entomol. Sci., 55(1):87�97.
.K ocr++ / DOI:10.18474/0749- 8004-55.1.87
.P Garcia et al., 2020.pdf
jhpoelen commented 5 months ago

Note that running preston in server mode using

preston s

produced the following result in a web browser

image