Inconsistent line breaks in ODK Collect?

I am a little confused about the support for line breaks. I'm using Google Play's ODK Collect 1.4.10. I have attached a sample XLSForm and XForm that demonstrates the differences I am noticing.

In this text, the line breaks are stripped. In XML

"You indicated that the age in the ROSTER is correct.

Go back and update the age in this interview."

and what is shown in ODK Collect is

"You indicated that the age in the ROSTER is correct. Go back and update the age in this interview."

Meanwhile,

"WARNING: The age in this interview does not agree with the household roster.

This interview:
Roster: "

in XML becomes

"WARNING: The age in this interview does not agree with the household roster.

This interview:

Roster: "

in ODK Collect (with the output tags filled in correctly). What is happening here? Is this the expected outcome from the ODK Developers' perspective?

Also, is all the text cleaning/preparation happening in src/main/java/org/odk/collect/android/utilities/TextUtils.java or do I need to look in any different files?

line-break-test.xlsx (30.1 KB)

line-break-test.xml (1.73 KB)

Consistency would be good. This is a bug.

The problem is probably in a combination of places.

(1) Within TextUtils, there is logic to interpret \nstring\n as a paragraph
and wrap it with html styling. This likely has a bug in it that would cause
\nfirstp\nsecondp\n to pick up firstp as a paragraph, but not secondp
because the intermediate \n is consumed by the firstp matching clause and
therefore not available for the matching of secondp.

(and TextUtils also has a few bugs related to the appendReplacement() usage
that are being worked on).

The aim of TextUtils is to implement markdown support. If you see the same
problems in ODK Collect 1.4.6, then it is not related to TextUtils
processing.

(2) The parsing of the XML file within the Javarosa library does some
suspect transforms. I.e.,

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-1016

And, most importantly:

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-2751

which almost always calls trim().

(3) Finally, there is the substitution logic that finds and replaces the
directives (which have been transformed into ${foo} substitution
strings during the XML parsing). This might also reassemble things
incorrectly:

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/core/model/FormDef.java?at=default&fileviewer=file-view-default#FormDef.java-912

(but I haven't followed that deeply, so I don't know)

··· ======================== If you are able, work with Yaw and Carl on any TextUtils changes/bugs. And if you find problems in the javarosa layer, work with me.

On Tue, May 24, 2016 at 10:43 AM, jameskpringle@gmail.com wrote:

I am a little confused about the support for line breaks. I'm using Google
Play's ODK Collect 1.4.10. I have attached a sample XLSForm and XForm that
demonstrates the differences I am noticing.

In this text, the line breaks are stripped. In XML

"You indicated that the age in the ROSTER is correct.

Go back and update the age in this interview."

and what is shown in ODK Collect is

"You indicated that the age in the ROSTER is correct. Go back and update
the age in this interview."

Meanwhile,

"WARNING: The age in this interview does not agree with the household
roster.

This interview:
Roster: "

in XML becomes

"WARNING: The age in this interview does not agree with the household
roster.

This interview:

Roster: "

in ODK Collect (with the output tags filled in correctly). What is
happening here? Is this the expected outcome from the ODK Developers'
perspective?

Also, is all the text cleaning/preparation happening in
src/main/java/org/odk/collect/android/utilities/TextUtils.java or do I need
to look in any different files?

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Hi James,

I'd love help on TextUtils bugs!

The code is at https://github.com/opendatakit/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/utilities/TextUtils.java

You think you'll be able to chip in with a pull request?

Yaw

··· On Wed, May 25, 2016 at 12:18 AM, Mitch Sundt wrote: > Consistency would be good. This is a bug. > > The problem is probably in a combination of places. > > (1) Within TextUtils, there is logic to interpret \nstring\n as a paragraph > and wrap it with html styling. This likely has a bug in it that would cause > \nfirstp\nsecondp\n to pick up firstp as a paragraph, but not secondp > because the intermediate \n is consumed by the firstp matching clause and > therefore not available for the matching of secondp. > > (and TextUtils also has a few bugs related to the appendReplacement() usage > that are being worked on). > > The aim of TextUtils is to implement markdown support. If you see the same > problems in ODK Collect 1.4.6, then it is not related to TextUtils > processing. > > (2) The parsing of the XML file within the Javarosa library does some > suspect transforms. I.e., > > https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-1016 > > And, most importantly: > > https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-2751 > > which almost always calls trim(). > > (3) Finally, there is the substitution logic that finds and replaces the > directives (which have been transformed into ${foo} substitution > strings during the XML parsing). This might also reassemble things > incorrectly: > > https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/core/model/FormDef.java?at=default&fileviewer=file-view-default#FormDef.java-912 > > (but I haven't followed that deeply, so I don't know) > > ======================== > If you are able, work with Yaw and Carl on any TextUtils changes/bugs. And > if you find problems in the javarosa layer, work with me. > > > On Tue, May 24, 2016 at 10:43 AM, wrote: >> >> I am a little confused about the support for line breaks. I'm using Google >> Play's ODK Collect 1.4.10. I have attached a sample XLSForm and XForm that >> demonstrates the differences I am noticing. >> >> In this text, the line breaks are stripped. In XML >> >> "You indicated that the age in the ROSTER is correct. >> >> Go back and update the age in this interview." >> >> and what is shown in ODK Collect is >> >> "You indicated that the age in the ROSTER is correct. Go back and update >> the age in this interview." >> >> Meanwhile, >> >> "WARNING: The age in this interview does not agree with the household >> roster. >> >> This interview: >> Roster: " >> >> in XML becomes >> >> "WARNING: The age in this interview does not agree with the household >> roster. >> >> This interview: >> >> Roster: " >> >> in ODK Collect (with the output tags filled in correctly). What is >> happening here? Is this the expected outcome from the ODK Developers' >> perspective? >> >> Also, is all the text cleaning/preparation happening in >> src/main/java/org/odk/collect/android/utilities/TextUtils.java or do I need >> to look in any different files? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "ODK Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit-developers+unsubscribe@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. > > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitchellsundt@gmail.com

James,

I've committed a rewrite that is as close to a port of the Enketo code
as possible.

I'd love a code review:

Yaw

··· -- Need ODK consultants? Nafundi provides form design, server setup, in-field training, and software development for ODK. Go to https://nafundi.com to get started.

On Wed, May 25, 2016 at 6:11 PM, Yaw Anokwa yanokwa@nafundi.com wrote:

Hi James,

I'd love help on TextUtils bugs!

The code is at https://github.com/opendatakit/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/utilities/TextUtils.java

You think you'll be able to chip in with a pull request?

Yaw

On Wed, May 25, 2016 at 12:18 AM, Mitch Sundt mitchellsundt@gmail.com wrote:

Consistency would be good. This is a bug.

The problem is probably in a combination of places.

(1) Within TextUtils, there is logic to interpret \nstring\n as a paragraph
and wrap it with html styling. This likely has a bug in it that would cause
\nfirstp\nsecondp\n to pick up firstp as a paragraph, but not secondp
because the intermediate \n is consumed by the firstp matching clause and
therefore not available for the matching of secondp.

(and TextUtils also has a few bugs related to the appendReplacement() usage
that are being worked on).

The aim of TextUtils is to implement markdown support. If you see the same
problems in ODK Collect 1.4.6, then it is not related to TextUtils
processing.

(2) The parsing of the XML file within the Javarosa library does some
suspect transforms. I.e.,

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-1016

And, most importantly:

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-2751

which almost always calls trim().

(3) Finally, there is the substitution logic that finds and replaces the
directives (which have been transformed into ${foo} substitution
strings during the XML parsing). This might also reassemble things
incorrectly:

https://bitbucket.org/m.sundt/javarosa/src/4622e5cd9d62b759097a80c5130adfdb667c01f0/core/src/org/javarosa/core/model/FormDef.java?at=default&fileviewer=file-view-default#FormDef.java-912

(but I haven't followed that deeply, so I don't know)

========================
If you are able, work with Yaw and Carl on any TextUtils changes/bugs. And
if you find problems in the javarosa layer, work with me.

On Tue, May 24, 2016 at 10:43 AM, jameskpringle@gmail.com wrote:

I am a little confused about the support for line breaks. I'm using Google
Play's ODK Collect 1.4.10. I have attached a sample XLSForm and XForm that
demonstrates the differences I am noticing.

In this text, the line breaks are stripped. In XML

"You indicated that the age in the ROSTER is correct.

Go back and update the age in this interview."

and what is shown in ODK Collect is

"You indicated that the age in the ROSTER is correct. Go back and update
the age in this interview."

Meanwhile,

"WARNING: The age in this interview does not agree with the household
roster.

This interview:
Roster: "

in XML becomes

"WARNING: The age in this interview does not agree with the household
roster.

This interview:

Roster: "

in ODK Collect (with the output tags filled in correctly). What is
happening here? Is this the expected outcome from the ODK Developers'
perspective?

Also, is all the text cleaning/preparation happening in
src/main/java/org/odk/collect/android/utilities/TextUtils.java or do I need
to look in any different files?

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com