Page 1 of 1

Unwrapping element inserts extra spaces

Posted: Fri Jan 03, 2020 5:08 pm
by zuza
Hi,

I am trying to remove unnecessary <p> elements inside <li>, <entry>, etc. I have found the following happens for this example:

Code: Select all

<ul>
  <li><p>something</p></li>
  <li>
    <p>else</p>
  </li>
</ul>
  • In Text mode, using either Refactoring>Delete Element Tags (Alt+Shift+X) or Refactoring>Elements>Unwrap element with target element "li/p", the result will be:

    Code: Select all

    <ul>
      <li>something</li>
      <li>
          else
       </li>
     </ul>
    This results in extra space before and after "else", which is not equivalent with the original. With Format and Indent we can see the extra spaces:

    Code: Select all

    <ul>
      <li>something</li>
      <li> else </li>
    </ul>
  • Looking at the same example in Author mode, Refactoring>Elements>Unwrap element with target element "li/p" gives the same result:

    Code: Select all

    <ul>
       <li>something</li>
      <li>
         else
      </li>
    </ul>
  • However, using Refactoring>Delete Element Tags (Alt+Shift+X) in Author mode does what I expect it to do and the result is:

    Code: Select all

    <ul>
      <li>something</li>
      <li>else</li>
    </ul>
From my point of view, the first 2 are bugs and the result should always be the same as with (3) ( Refactoring>Delete Element Tags (Alt+Shift+X) in Author mode) .


Thank you.

Best regards,
Ozana

Re: Unwrapping element inserts extra spaces

Posted: Mon Jan 06, 2020 11:02 am
by sorin_carbunaru
Hello Ozana,

I can't say the behavior you mentioned as unwanted for you is a bug. For XML Refactoring, it's just the way the script is working with the XML text. And actually, when the paragraph is on a new line, there are quite a lot of spaces before and after it...

Regarding the Delete Element Tags in the Author page, it is just implemented differently, and it works with Author-page-related structures and information, which is more than the information we have with plain XML text.

Kind regards,
Sorin Carbunaru
oXygen XML

Re: Unwrapping element inserts extra spaces

Posted: Tue Jan 07, 2020 2:59 pm
by zuza
Hello,

Thanks for your reply.

I tried switching on/off different options in Preference > Editor > XML to try to get from this:

Code: Select all

<li>
  <p>else</p>
 </li>
to this:

Code: Select all

<li><p>else</p></li>
when doing format+indent, so that I can then use the unwrap.

The only thing I managed to get is this:

Code: Select all

<li> <p>else</p> </li>
which has the extra spaces and will mess up the spacing in the published output if I do the unwrap.


Is there any option I have missed, or any steps I can follow to get what I need?

If not, is it possible to add an option in a future version of oXygen Editor? It's too much manual work as it is now.

Thank you.

Best regards,
Ozana

Re: Unwrapping element inserts extra spaces

Posted: Wed Jan 08, 2020 5:06 am
by chrispitude
It seems like the text-mode unwrap operation should be enhanced to be schema-aware so it knows which elements are space-preserved and which are not.

Re: Unwrapping element inserts extra spaces

Posted: Wed Jan 08, 2020 9:54 am
by sorin_carbunaru
Hello,

Ozana, I am afraid there is no format & indent option for this. I created an improvement request for this (EXM-44839 - for reference purposes).

Chris, thank you for your intervention! I also created an issue to investigate what could be done at the XML refactoring operation level (EXM-44840).

All the best wishes,
Sorin C.

Re: Unwrapping element inserts extra spaces

Posted: Sun Jan 12, 2020 2:39 pm
by chrispitude
Hi Sorin,

It was Radu that taught me about schema-awareness when we ran into a similar issue with extra blank lines showing up in the editor due to this effect. :)