1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-12 08:38:10 +00:00

Merge pull request #251 from thewhodidthis/bf#246--line-breaks

data/TrialHandler: allow for doubly escaped LFs in xlsx cells
This commit is contained in:
Alain Pitiot 2021-02-20 08:50:38 +01:00 committed by GitHub
commit 5374d199e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -485,10 +485,20 @@ export class TrialHandler extends PsychObject
value = arrayMaybe;
}
// if value is a numerical string, convert it to a number:
if (typeof value === 'string' && !isNaN(value))
if (typeof value === 'string')
{
value = Number.parseFloat(value);
const numberMaybe = Number.parseFloat(value);
// if value is a numerical string, convert it to a number:
if (!isNaN(numberMaybe) && numberMaybe.toString().length === value.length)
{
value = numberMaybe;
}
else
{
// Parse doubly escaped line feeds
value = value.replace(/(\n)/g, '\n');
}
}
trial[fields[l]] = value;