FHIR / sushi

SUSHI (aka "SUSHI Unshortens Short Hand Inputs") is a reference implementation command-line interpreter/compiler for FHIR Shorthand (FSH).
Apache License 2.0
145 stars 44 forks source link

Weird behaviour with span element in xhtml #1359

Closed joofio closed 1 year ago

joofio commented 1 year ago

Hi,

I have a div section for the composition with a lot of text. I the middle of that text I have """ ... <span class="ccc"> text text <p> text text </p> <ul> <li> even more text</li></ul></span> ..."""

What is happening in sushi is that when it transforms it in json (at least), the span is closed right before the <p>. I have removed all <p> and <ul> and works as intended. The moment i add one of them, the span is closed right before the start of the element. If i replace span with div works as intended.

For curiosity sake, the data is this: https://github.com/hl7-eu/gravitate-health/blob/2e5dd920822f3ef95dbc6401f394ff1d09caf972/input/fsh/examples/processedEPI/p_dovato.fsh#L212

So my question is: is this intended due to some HTML/XHTML rule that i am not aware of. Or is something going on?

sushi 3.4.0

possibly related with https://github.com/FHIR/sushi/pull/1002 or https://github.com/FHIR/sushi/issues/1048 ?

Thanks!!

joofio commented 1 year ago

Is this related to the fact that "this code embeds an HTML <p> element (a block-level element) inside a <span> element (an inline element). According to the HTML specification, this is not allowed." ??

cmoesel commented 1 year ago

Hi @joofio. I apologize for the delay in responding to this. I've looked into this and I think your last hunch is correct: XHTML disallows nesting block-level elements (like <p>) inside inline-level elements (like <span>). I expect there is a better reference somewhere, but here's one that I found. This can also be confirmed by the W3C Validator if you try validating your XHTML there.

SUSHI uses a 3rd party library to minify XHTML before exporting it into a FHIR resource. I expect that the library we are using either tries to remove invalid constructs in the XHTML or just flat-out doesn't handle them well. We have little control over this, but we'll see if there are any configuration settings that might help. That said, I think your best bet is to fix your XHTML so it follows the XHTML spec and doesn't put block-level elements in inline-level elements.

joofio commented 1 year ago

Thanks for the reply! Now i get it